README.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. .. image:: http://docs.celeryproject.org/en/latest/_images/celery-banner-small.png
  2. |build-status| |coverage| |license| |wheel| |pyversion| |pyimp| |ocbackerbadge| |ocsponsorbadge|
  3. :Version: 4.2.1 (windowlicker)
  4. :Web: http://celeryproject.org/
  5. :Download: https://pypi.org/project/celery/
  6. :Source: https://github.com/celery/celery/
  7. :Keywords: task, queue, job, async, rabbitmq, amqp, redis,
  8. python, distributed, actors
  9. Donations
  10. =========
  11. This project relies on your generous donations.
  12. If you are using Celery to create a commercial product, please consider becoming our `backer`_ or our `sponsor`_ to ensure Celery's future.
  13. .. _`backer`: https://opencollective.com/celery#backer
  14. .. _`sponsor`: https://opencollective.com/celery#sponsor
  15. Sponsors
  16. --------
  17. |ImageLink|_
  18. .. |ImageLink| image:: https://i.imgur.com/ULmQEib.png
  19. .. _ImageLink: https://getstream.io/try-the-api/?utm_source=celery&utm_medium=banner&utm_campaign=github
  20. What's a Task Queue?
  21. ====================
  22. Task queues are used as a mechanism to distribute work across threads or
  23. machines.
  24. A task queue's input is a unit of work, called a task, dedicated worker
  25. processes then constantly monitor the queue for new work to perform.
  26. Celery communicates via messages, usually using a broker
  27. to mediate between clients and workers. To initiate a task a client puts a
  28. message on the queue, the broker then delivers the message to a worker.
  29. A Celery system can consist of multiple workers and brokers, giving way
  30. to high availability and horizontal scaling.
  31. Celery is written in Python, but the protocol can be implemented in any
  32. language. In addition to Python there's node-celery_ for Node.js,
  33. and a `PHP client`_.
  34. Language interoperability can also be achieved by using webhooks
  35. in such a way that the client enqueues an URL to be requested by a worker.
  36. .. _node-celery: https://github.com/mher/node-celery
  37. .. _`PHP client`: https://github.com/gjedeer/celery-php
  38. What do I need?
  39. ===============
  40. Celery version 4.2 runs on,
  41. - Python (2.7, 3.4, 3.5, 3.6)
  42. - PyPy (6.0)
  43. This is the last version to support Python 2.7,
  44. and from the next version (Celery 5.x) Python 3.5 or newer is required.
  45. If you're running an older version of Python, you need to be running
  46. an older version of Celery:
  47. - Python 2.6: Celery series 3.1 or earlier.
  48. - Python 2.5: Celery series 3.0 or earlier.
  49. - Python 2.4 was Celery series 2.2 or earlier.
  50. Celery is a project with minimal funding,
  51. so we don't support Microsoft Windows.
  52. Please don't open any issues related to that platform.
  53. *Celery* is usually used with a message broker to send and receive messages.
  54. The RabbitMQ, Redis transports are feature complete,
  55. but there's also experimental support for a myriad of other solutions, including
  56. using SQLite for local development.
  57. *Celery* can run on a single machine, on multiple machines, or even
  58. across datacenters.
  59. Get Started
  60. ===========
  61. If this is the first time you're trying to use Celery, or you're
  62. new to Celery 4.2 coming from previous versions then you should read our
  63. getting started tutorials:
  64. - `First steps with Celery`_
  65. Tutorial teaching you the bare minimum needed to get started with Celery.
  66. - `Next steps`_
  67. A more complete overview, showing more features.
  68. .. _`First steps with Celery`:
  69. http://docs.celeryproject.org/en/latest/getting-started/first-steps-with-celery.html
  70. .. _`Next steps`:
  71. http://docs.celeryproject.org/en/latest/getting-started/next-steps.html
  72. Celery is...
  73. =============
  74. - **Simple**
  75. Celery is easy to use and maintain, and does *not need configuration files*.
  76. It has an active, friendly community you can talk to for support,
  77. like at our `mailing-list`_, or the IRC channel.
  78. Here's one of the simplest applications you can make::
  79. from celery import Celery
  80. app = Celery('hello', broker='amqp://guest@localhost//')
  81. @app.task
  82. def hello():
  83. return 'hello world'
  84. - **Highly Available**
  85. Workers and clients will automatically retry in the event
  86. of connection loss or failure, and some brokers support
  87. HA in way of *Primary/Primary* or *Primary/Replica* replication.
  88. - **Fast**
  89. A single Celery process can process millions of tasks a minute,
  90. with sub-millisecond round-trip latency (using RabbitMQ,
  91. py-librabbitmq, and optimized settings).
  92. - **Flexible**
  93. Almost every part of *Celery* can be extended or used on its own,
  94. Custom pool implementations, serializers, compression schemes, logging,
  95. schedulers, consumers, producers, broker transports, and much more.
  96. It supports...
  97. ================
  98. - **Message Transports**
  99. - RabbitMQ_, Redis_, Amazon SQS
  100. - **Concurrency**
  101. - Prefork, Eventlet_, gevent_, single threaded (``solo``)
  102. - **Result Stores**
  103. - AMQP, Redis
  104. - memcached
  105. - SQLAlchemy, Django ORM
  106. - Apache Cassandra, IronCache, Elasticsearch
  107. - **Serialization**
  108. - *pickle*, *json*, *yaml*, *msgpack*.
  109. - *zlib*, *bzip2* compression.
  110. - Cryptographic message signing.
  111. .. _`Eventlet`: http://eventlet.net/
  112. .. _`gevent`: http://gevent.org/
  113. .. _RabbitMQ: https://rabbitmq.com
  114. .. _Redis: https://redis.io
  115. .. _SQLAlchemy: http://sqlalchemy.org
  116. Framework Integration
  117. =====================
  118. Celery is easy to integrate with web frameworks, some of which even have
  119. integration packages:
  120. +--------------------+------------------------+
  121. | `Django`_ | not needed |
  122. +--------------------+------------------------+
  123. | `Pyramid`_ | `pyramid_celery`_ |
  124. +--------------------+------------------------+
  125. | `Pylons`_ | `celery-pylons`_ |
  126. +--------------------+------------------------+
  127. | `Flask`_ | not needed |
  128. +--------------------+------------------------+
  129. | `web2py`_ | `web2py-celery`_ |
  130. +--------------------+------------------------+
  131. | `Tornado`_ | `tornado-celery`_ |
  132. +--------------------+------------------------+
  133. The integration packages aren't strictly necessary, but they can make
  134. development easier, and sometimes they add important hooks like closing
  135. database connections at ``fork``.
  136. .. _`Django`: https://djangoproject.com/
  137. .. _`Pylons`: http://pylonsproject.org/
  138. .. _`Flask`: http://flask.pocoo.org/
  139. .. _`web2py`: http://web2py.com/
  140. .. _`Bottle`: https://bottlepy.org/
  141. .. _`Pyramid`: http://docs.pylonsproject.org/en/latest/docs/pyramid.html
  142. .. _`pyramid_celery`: https://pypi.org/project/pyramid_celery/
  143. .. _`celery-pylons`: https://pypi.org/project/celery-pylons/
  144. .. _`web2py-celery`: https://code.google.com/p/web2py-celery/
  145. .. _`Tornado`: http://www.tornadoweb.org/
  146. .. _`tornado-celery`: https://github.com/mher/tornado-celery/
  147. .. _celery-documentation:
  148. Documentation
  149. =============
  150. The `latest documentation`_ is hosted at Read The Docs, containing user guides,
  151. tutorials, and an API reference.
  152. .. _`latest documentation`: http://docs.celeryproject.org/en/latest/
  153. .. _celery-installation:
  154. Installation
  155. ============
  156. You can install Celery either via the Python Package Index (PyPI)
  157. or from source.
  158. To install using ``pip``:
  159. ::
  160. $ pip install -U Celery
  161. .. _bundles:
  162. Bundles
  163. -------
  164. Celery also defines a group of bundles that can be used
  165. to install Celery and the dependencies for a given feature.
  166. You can specify these in your requirements or on the ``pip``
  167. command-line by using brackets. Multiple bundles can be specified by
  168. separating them by commas.
  169. ::
  170. $ pip install "celery[librabbitmq]"
  171. $ pip install "celery[librabbitmq,redis,auth,msgpack]"
  172. The following bundles are available:
  173. Serializers
  174. ~~~~~~~~~~~
  175. :``celery[auth]``:
  176. for using the ``auth`` security serializer.
  177. :``celery[msgpack]``:
  178. for using the msgpack serializer.
  179. :``celery[yaml]``:
  180. for using the yaml serializer.
  181. Concurrency
  182. ~~~~~~~~~~~
  183. :``celery[eventlet]``:
  184. for using the ``eventlet`` pool.
  185. :``celery[gevent]``:
  186. for using the ``gevent`` pool.
  187. Transports and Backends
  188. ~~~~~~~~~~~~~~~~~~~~~~~
  189. :``celery[librabbitmq]``:
  190. for using the librabbitmq C library.
  191. :``celery[redis]``:
  192. for using Redis as a message transport or as a result backend.
  193. :``celery[sqs]``:
  194. for using Amazon SQS as a message transport.
  195. :``celery[tblib``]:
  196. for using the ``task_remote_tracebacks`` feature.
  197. :``celery[memcache]``:
  198. for using Memcached as a result backend (using ``pylibmc``)
  199. :``celery[pymemcache]``:
  200. for using Memcached as a result backend (pure-Python implementation).
  201. :``celery[cassandra]``:
  202. for using Apache Cassandra as a result backend with DataStax driver.
  203. :``celery[azureblockblob]``:
  204. for using Azure Storage as a result backend (using ``azure-storage``)
  205. :``celery[couchbase]``:
  206. for using Couchbase as a result backend.
  207. :``celery[elasticsearch]``:
  208. for using Elasticsearch as a result backend.
  209. :``celery[riak]``:
  210. for using Riak as a result backend.
  211. :``celery[zookeeper]``:
  212. for using Zookeeper as a message transport.
  213. :``celery[sqlalchemy]``:
  214. for using SQLAlchemy as a result backend (*supported*).
  215. :``celery[pyro]``:
  216. for using the Pyro4 message transport (*experimental*).
  217. :``celery[slmq]``:
  218. for using the SoftLayer Message Queue transport (*experimental*).
  219. :``celery[consul]``:
  220. for using the Consul.io Key/Value store as a message transport or result backend (*experimental*).
  221. :``celery[django]``:
  222. specifies the lowest version possible for Django support.
  223. You should probably not use this in your requirements, it's here
  224. for informational purposes only.
  225. .. _celery-installing-from-source:
  226. Downloading and installing from source
  227. --------------------------------------
  228. Download the latest version of Celery from PyPI:
  229. https://pypi.org/project/celery/
  230. You can install it by doing the following,:
  231. ::
  232. $ tar xvfz celery-0.0.0.tar.gz
  233. $ cd celery-0.0.0
  234. $ python setup.py build
  235. # python setup.py install
  236. The last command must be executed as a privileged user if
  237. you aren't currently using a virtualenv.
  238. .. _celery-installing-from-git:
  239. Using the development version
  240. -----------------------------
  241. With pip
  242. ~~~~~~~~
  243. The Celery development version also requires the development
  244. versions of ``kombu``, ``amqp``, ``billiard``, and ``vine``.
  245. You can install the latest snapshot of these using the following
  246. pip commands:
  247. ::
  248. $ pip install https://github.com/celery/celery/zipball/master#egg=celery
  249. $ pip install https://github.com/celery/billiard/zipball/master#egg=billiard
  250. $ pip install https://github.com/celery/py-amqp/zipball/master#egg=amqp
  251. $ pip install https://github.com/celery/kombu/zipball/master#egg=kombu
  252. $ pip install https://github.com/celery/vine/zipball/master#egg=vine
  253. With git
  254. ~~~~~~~~
  255. Please see the Contributing section.
  256. .. _getting-help:
  257. Getting Help
  258. ============
  259. .. _mailing-list:
  260. Mailing list
  261. ------------
  262. For discussions about the usage, development, and future of Celery,
  263. please join the `celery-users`_ mailing list.
  264. .. _`celery-users`: https://groups.google.com/group/celery-users/
  265. .. _irc-channel:
  266. IRC
  267. ---
  268. Come chat with us on IRC. The **#celery** channel is located at the `Freenode`_
  269. network.
  270. .. _`Freenode`: https://freenode.net
  271. .. _bug-tracker:
  272. Bug tracker
  273. ===========
  274. If you have any suggestions, bug reports, or annoyances please report them
  275. to our issue tracker at https://github.com/celery/celery/issues/
  276. .. _wiki:
  277. Wiki
  278. ====
  279. https://wiki.github.com/celery/celery/
  280. Credits
  281. =======
  282. .. _contributing-short:
  283. Contributors
  284. ------------
  285. This project exists thanks to all the people who contribute. Development of
  286. `celery` happens at GitHub: https://github.com/celery/celery
  287. You're highly encouraged to participate in the development
  288. of `celery`. If you don't like GitHub (for some reason) you're welcome
  289. to send regular patches.
  290. Be sure to also read the `Contributing to Celery`_ section in the
  291. documentation.
  292. .. _`Contributing to Celery`:
  293. http://docs.celeryproject.org/en/master/contributing.html
  294. |oc-contributors|
  295. .. |oc-contributors| image:: https://opencollective.com/celery/contributors.svg?width=890&button=false
  296. :target: https://github.com/celery/celery/graphs/contributors
  297. Backers
  298. -------
  299. Thank you to all our backers! 🙏 [`Become a backer`_]
  300. .. _`Become a backer`: https://opencollective.com/celery#backer
  301. |oc-backers|
  302. .. |oc-backers| image:: https://opencollective.com/celery/backers.svg?width=890
  303. :target: https://opencollective.com/celery#backers
  304. Sponsors
  305. --------
  306. Support this project by becoming a sponsor. Your logo will show up here with a
  307. link to your website. [`Become a sponsor`_]
  308. .. _`Become a sponsor`: https://opencollective.com/celery#sponsor
  309. |oc-sponsors|
  310. .. |oc-sponsors| image:: https://opencollective.com/celery/sponsor/0/avatar.svg
  311. :target: https://opencollective.com/celery/sponsor/0/website
  312. .. _license:
  313. License
  314. =======
  315. This software is licensed under the `New BSD License`. See the ``LICENSE``
  316. file in the top distribution directory for the full license text.
  317. .. # vim: syntax=rst expandtab tabstop=4 shiftwidth=4 shiftround
  318. .. |build-status| image:: https://secure.travis-ci.org/celery/celery.png?branch=master
  319. :alt: Build status
  320. :target: https://travis-ci.org/celery/celery
  321. .. |coverage| image:: https://codecov.io/github/celery/celery/coverage.svg?branch=master
  322. :target: https://codecov.io/github/celery/celery?branch=master
  323. .. |license| image:: https://img.shields.io/pypi/l/celery.svg
  324. :alt: BSD License
  325. :target: https://opensource.org/licenses/BSD-3-Clause
  326. .. |wheel| image:: https://img.shields.io/pypi/wheel/celery.svg
  327. :alt: Celery can be installed via wheel
  328. :target: https://pypi.org/project/celery/
  329. .. |pyversion| image:: https://img.shields.io/pypi/pyversions/celery.svg
  330. :alt: Supported Python versions.
  331. :target: https://pypi.org/project/celery/
  332. .. |pyimp| image:: https://img.shields.io/pypi/implementation/celery.svg
  333. :alt: Support Python implementations.
  334. :target: https://pypi.org/project/celery/
  335. .. |ocbackerbadge| image:: https://opencollective.com/celery/backers/badge.svg
  336. :alt: Backers on Open Collective
  337. :target: #backers
  338. .. |ocsponsorbadge| image:: https://opencollective.com/celery/sponsors/badge.svg
  339. :alt: Sponsors on Open Collective
  340. :target: #sponsors