| 1 |
:Version: 5.6.3 (recovery) |
| 2 |
:Web: https://docs.celeryq.dev/en/stable/index.html |
| 3 |
:Download: https://pypi.org/project/celery/ |
| 4 |
:Source: https://github.com/celery/celery/ |
| 5 |
:Keywords: task, queue, job, async, rabbitmq, amqp, redis, |
| 6 |
python, distributed, actors |
| 7 |
|
| 8 |
-- |
| 9 |
|
| 10 |
What's a Task Queue? |
| 11 |
==================== |
| 12 |
|
| 13 |
Task queues are used as a mechanism to distribute work across threads or |
| 14 |
machines. |
| 15 |
|
| 16 |
A task queue's input is a unit of work, called a task, dedicated worker |
| 17 |
processes then constantly monitor the queue for new work to perform. |
| 18 |
|
| 19 |
Celery communicates via messages, usually using a broker |
| 20 |
to mediate between clients and workers. To initiate a task a client puts a |
| 21 |
message on the queue, the broker then delivers the message to a worker. |
| 22 |
|
| 23 |
A Celery system can consist of multiple workers and brokers, giving way |
| 24 |
to high availability and horizontal scaling. |
| 25 |
|
| 26 |
Celery is written in Python, but the protocol can be implemented in any |
| 27 |
language. In addition to Python there's node-celery_ and node-celery-ts_ for Node.js, |
| 28 |
and a `PHP client`_. |
| 29 |
|
| 30 |
Language interoperability can also be achieved by using webhooks |
| 31 |
in such a way that the client enqueues an URL to be requested by a worker. |
| 32 |
|
| 33 |
.. _node-celery: https://github.com/mher/node-celery |
| 34 |
.. _`PHP client`: https://github.com/gjedeer/celery-php |
| 35 |
.. _node-celery-ts: https://github.com/IBM/node-celery-ts |
| 36 |
|
| 37 |
What do I need? |
| 38 |
=============== |
| 39 |
|
| 40 |
Celery version 5.1.x runs on, |
| 41 |
|
| 42 |
- Python 3.6 or newer versions |
| 43 |
- PyPy3.6 (7.3) or newer |
| 44 |
|
| 45 |
|
| 46 |
From the next major version (Celery 6.x) Python 3.7 or newer is required. |
| 47 |
|
| 48 |
If you're running an older version of Python, you need to be running |
| 49 |
an older version of Celery: |
| 50 |
|
| 51 |
- Python 2.6: Celery series 3.1 or earlier. |
| 52 |
- Python 2.5: Celery series 3.0 or earlier. |
| 53 |
- Python 2.4 was Celery series 2.2 or earlier. |
| 54 |
|
| 55 |
Celery is a project with minimal funding, |
| 56 |
so we don't support Microsoft Windows. |
| 57 |
Please don't open any issues related to that platform. |
| 58 |
|
| 59 |
*Celery* is usually used with a message broker to send and receive messages. |
| 60 |
The RabbitMQ, Redis transports are feature complete, |
| 61 |
but there's also experimental support for a myriad of other solutions, including |
| 62 |
using SQLite for local development. |
| 63 |
|
| 64 |
*Celery* can run on a single machine, on multiple machines, or even |
| 65 |
across datacenters. |
| 66 |
|
| 67 |
Get Started |
| 68 |
=========== |
| 69 |
|
| 70 |
If this is the first time you're trying to use Celery, or you're |
| 71 |
new to Celery 5.0.x or 5.1.x coming from previous versions then you should read our |
| 72 |
getting started tutorials: |
| 73 |
|
| 74 |
- `First steps with Celery`_ |
| 75 |
|
| 76 |
Tutorial teaching you the bare minimum needed to get started with Celery. |
| 77 |
|
| 78 |
- `Next steps`_ |
| 79 |
|
| 80 |
A more complete overview, showing more features. |
| 81 |
|
| 82 |
.. _`First steps with Celery`: |
| 83 |
https://docs.celeryq.dev/en/latest/getting-started/first-steps-with-celery.html |
| 84 |
|
| 85 |
.. _`Next steps`: |
| 86 |
https://docs.celeryq.dev/en/latest/getting-started/next-steps.html |
| 87 |
|
| 88 |
Celery is… |
| 89 |
============= |
| 90 |
|
| 91 |
- **Simple** |
| 92 |
|
| 93 |
Celery is easy to use and maintain, and does *not need configuration files*. |
| 94 |
|
| 95 |
It has an active, friendly community you can talk to for support, |
| 96 |
like at our `mailing-list`_, or the IRC channel. |
| 97 |
|
| 98 |
Here's one of the simplest applications you can make:: |
| 99 |
|
| 100 |
from celery import Celery |
| 101 |
|
| 102 |
app = Celery('hello', broker='amqp://guest@localhost//') |
| 103 |
|
| 104 |
@app.task |
| 105 |
def hello(): |
| 106 |
return 'hello world' |
| 107 |
|
| 108 |
- **Highly Available** |
| 109 |
|
| 110 |
Workers and clients will automatically retry in the event |
| 111 |
of connection loss or failure, and some brokers support |
| 112 |
HA in way of *Primary/Primary* or *Primary/Replica* replication. |
| 113 |
|
| 114 |
- **Fast** |
| 115 |
|
| 116 |
A single Celery process can process millions of tasks a minute, |
| 117 |
with sub-millisecond round-trip latency (using RabbitMQ, |
| 118 |
py-librabbitmq, and optimized settings). |
| 119 |
|
| 120 |
- **Flexible** |
| 121 |
|
| 122 |
Almost every part of *Celery* can be extended or used on its own, |
| 123 |
Custom pool implementations, serializers, compression schemes, logging, |
| 124 |
schedulers, consumers, producers, broker transports, and much more. |
| 125 |
|
| 126 |
It supports… |
| 127 |
================ |
| 128 |
|
| 129 |
- **Message Transports** |
| 130 |
|
| 131 |
- RabbitMQ_, Redis_, Amazon SQS |
| 132 |
|
| 133 |
- **Concurrency** |
| 134 |
|
| 135 |
- Prefork, Eventlet_, gevent_, single threaded (``solo``), thread |
| 136 |
|
| 137 |
- **Result Stores** |
| 138 |
|
| 139 |
- AMQP, Redis |
| 140 |
- memcached |
| 141 |
- SQLAlchemy, Django ORM |
| 142 |
- Apache Cassandra, IronCache, Elasticsearch |
| 143 |
|
| 144 |
- **Serialization** |
| 145 |
|
| 146 |
- *pickle*, *json*, *yaml*, *msgpack*. |
| 147 |
- *zlib*, *bzip2* compression. |
| 148 |
- Cryptographic message signing. |
| 149 |
|
| 150 |
.. _`Eventlet`: http://eventlet.net/ |
| 151 |
.. _`gevent`: http://gevent.org/ |
| 152 |
|
| 153 |
.. _RabbitMQ: https://rabbitmq.com |
| 154 |
.. _Redis: https://redis.io |
| 155 |
.. _SQLAlchemy: http://sqlalchemy.org |
| 156 |
|
| 157 |
Framework Integration |
| 158 |
===================== |
| 159 |
|
| 160 |
Celery is easy to integrate with web frameworks, some of which even have |
| 161 |
integration packages: |
| 162 |
|
| 163 |
+--------------------+------------------------+ |
| 164 |
| `Django`_ | not needed | |
| 165 |
+--------------------+------------------------+ |
| 166 |
| `Pyramid`_ | `pyramid_celery`_ | |
| 167 |
+--------------------+------------------------+ |
| 168 |
| `Pylons`_ | `celery-pylons`_ | |
| 169 |
+--------------------+------------------------+ |
| 170 |
| `Flask`_ | not needed | |
| 171 |
+--------------------+------------------------+ |
| 172 |
| `web2py`_ | `web2py-celery`_ | |
| 173 |
+--------------------+------------------------+ |
| 174 |
| `Tornado`_ | `tornado-celery`_ | |
| 175 |
+--------------------+------------------------+ |
| 176 |
|
| 177 |
The integration packages aren't strictly necessary, but they can make |
| 178 |
development easier, and sometimes they add important hooks like closing |
| 179 |
database connections at ``fork``. |
| 180 |
|
| 181 |
.. _`Django`: https://djangoproject.com/ |
| 182 |
.. _`Pylons`: http://pylonsproject.org/ |
| 183 |
.. _`Flask`: http://flask.pocoo.org/ |
| 184 |
.. _`web2py`: http://web2py.com/ |
| 185 |
.. _`Bottle`: https://bottlepy.org/ |
| 186 |
.. _`Pyramid`: http://docs.pylonsproject.org/en/latest/docs/pyramid.html |
| 187 |
.. _`pyramid_celery`: https://pypi.org/project/pyramid_celery/ |
| 188 |
.. _`celery-pylons`: https://pypi.org/project/celery-pylons/ |
| 189 |
.. _`web2py-celery`: https://code.google.com/p/web2py-celery/ |
| 190 |
.. _`Tornado`: http://www.tornadoweb.org/ |
| 191 |
.. _`tornado-celery`: https://github.com/mher/tornado-celery/ |
| 192 |
|
| 193 |
.. _celery-documentation: |
| 194 |
|
| 195 |
Documentation |
| 196 |
============= |
| 197 |
|
| 198 |
The `latest documentation`_ is hosted at Read The Docs, containing user guides, |
| 199 |
tutorials, and an API reference. |
| 200 |
|
| 201 |
.. _`latest documentation`: https://docs.celeryq.dev/en/latest/ |