whatsnew-3.1.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. .. _whatsnew-3.1:
  2. ===========================================
  3. What's new in Celery 3.1 (Cipater)
  4. ===========================================
  5. Celery is a simple, flexible and reliable distributed system to
  6. process vast amounts of messages, while providing operations with
  7. the tools required to maintain such a system.
  8. It's a task queue with focus on real-time processing, while also
  9. supporting task scheduling.
  10. Celery has a large and diverse community of users and contributors,
  11. you should come join us :ref:`on IRC <irc-channel>`
  12. or :ref:`our mailing-list <mailing-list>`.
  13. To read more about Celery you should go read the :ref:`introduction <intro>`.
  14. While this version is backward compatible with previous versions
  15. it's important that you read the following section.
  16. This version is officially supported on CPython 2.6, 2.7, 3.2 and 3.3,
  17. as well as PyPy and Jython.
  18. Highlights
  19. ==========
  20. .. topic:: Overview
  21. - XXX1
  22. YYY1
  23. - XXX2
  24. - XXX3
  25. YYY3
  26. .. _`website`: http://celeryproject.org/
  27. .. _`django-celery changelog`:
  28. http://github.com/celery/django-celery/tree/master/Changelog
  29. .. _`django-celery 3.0`: http://pypi.python.org/pypi/django-celery/
  30. .. contents::
  31. :local:
  32. :depth: 2
  33. .. _v310-important:
  34. Important Notes
  35. ===============
  36. XXX
  37. ---
  38. YYY
  39. .. _v310-news:
  40. News
  41. ====
  42. XXX
  43. ---
  44. YYY
  45. In Other News
  46. -------------
  47. - No longer supports Python 2.5
  48. From this version Celery requires Python 2.6 or later.
  49. - No longer depends on ``python-dateutil``
  50. Instead a dependency on :mod:`pytz` has been added, which was already
  51. recommended in the documentation for accurate timezone support.
  52. This also means that dependencies are on the same on both Python 2 and
  53. Python 3, and that the :file:`requirements/default-py3k.txt` file has
  54. been removed.
  55. - Time limits can now be set by the client for individual tasks (Issue #802).
  56. You can set both hard and soft time limits using the ``timeout`` and
  57. ``soft_timeout`` calling options:
  58. .. code-block:: python
  59. >>> res = add.apply_async((2, 2), timeout=10, soft_timeout=8)
  60. >>> res = add.subtask((2, 2), timeout=10, soft_timeout=8)()
  61. >>> res = add.s(2, 2).set(timeout=10, soft_timeout=8)()
  62. Contributed by Mher Movsisyan.
  63. - Old command-line programs removed and deprecated
  64. The goal is that everyone should move the new :program:`celery` umbrella
  65. command, so with this version we deprecate the old command names,
  66. and remove commands that are not used in init scripts.
  67. +-------------------+--------------+-------------------------------------+
  68. | Program | New Status | Replacement |
  69. +===================+==============+=====================================+
  70. | ``celeryd`` | *DEPRECATED* | :program:`celery worker` |
  71. +-------------------+--------------+-------------------------------------+
  72. | ``celerybeat`` | *DEPRECATED* | :program:`celery beat` |
  73. +-------------------+--------------+-------------------------------------+
  74. | ``celeryd-multi`` | *DEPRECATED* | :program:`celery multi` |
  75. +-------------------+--------------+-------------------------------------+
  76. | ``celeryctl`` | **REMOVED** | :program:`celery` |
  77. +-------------------+--------------+-------------------------------------+
  78. | ``celeryev`` | **REMOVED** | :program:`celery events` |
  79. +-------------------+--------------+-------------------------------------+
  80. | ``camqadm`` | **REMOVED** | :program:`celery amqp` |
  81. +-------------------+--------------+-------------------------------------+
  82. Please see :program:`celery --help` for help using the umbrella command.
  83. - Celery now support Django out of the box.
  84. The fixes and improvements applied by the django-celery library is now
  85. automatically applied by core Celery when it detects that
  86. the :envvar:`DJANGO_SETTINGS_MODULE` environment setting is set.
  87. The distribution ships with a new example project using Django
  88. in :file:`examples/django`:
  89. http://github.com/celery/celery/tree/master/examples/django
  90. There are cases where you would want to use django-celery still
  91. as:
  92. - Celery does not implement the Django database or cache backends.
  93. - Celery does not automatically read configuration from Django settings.
  94. - Celery does not ship with the database-based periodic task
  95. scheduler.
  96. If you are using django-celery then it is crucial that you have
  97. ``djcelery.setup_loader()`` in your settings module, as this
  98. no longer happens as a side-effect of importing the :mod:`djcelery`
  99. module.
  100. - The consumer part of the worker has been rewritten to use Bootsteps.
  101. By writing bootsteps you can now easily extend the consumer part
  102. of the worker to add additional features, or even message consumers.
  103. See the :ref:`guide-extending` guide for more information.
  104. - New Bootsteps implementation.
  105. The bootsteps and namespaces have been refactored for the better,
  106. sadly this means that bootsteps written for older versions will
  107. not be compatible with this version.
  108. Bootsteps were never publicly documented and was considered
  109. experimental, so chances are no one has ever implemented custom
  110. bootsteps, but if you did please contact the mailing-list
  111. and we'll help you port them.
  112. - Module ``celery.worker.bootsteps`` renamed to :mod:`celery.bootsteps`
  113. - The name of a bootstep no longer contain the name of the namespace.
  114. - A bootstep can now be part of multiple namespaces.
  115. - Namespaces must instantiate individual bootsteps, and
  116. there's no global registry of bootsteps.
  117. - New result backend with RPC semantics (``rpc``).
  118. This version of the ``amqp`` result backend is a very good alternative
  119. to use in classical RPC scenarios, where the process that initiates
  120. the task is always the process to retrieve the result.
  121. It uses Kombu to send and retrieve results, and each client
  122. will create a unique queue for replies to be sent to. Avoiding
  123. the significant overhead of the original amqp backend which creates
  124. one queue per task, but it's important to consider that it will
  125. not be possible to retrieve the result from another process,
  126. and that results sent using this backend is not persistent and so will
  127. not survive a broker restart.
  128. It has only been tested with the AMQP and Redis transports.
  129. - App instances can now add additional command line options
  130. to the worker and beat programs.
  131. The :attr:`@Celery.user_options` attribute can be used
  132. to add additional command-line arguments, and expects
  133. optparse-style options:
  134. .. code-block:: python
  135. from celery import Celery
  136. from optparse import make_option as Option
  137. celery = Celery()
  138. celery.user_options['worker'].add(
  139. Option('--my-argument'),
  140. )
  141. See :ref:`guide-extending` for more information.
  142. - Events are now ordered using logical time.
  143. Timestamps are not a reliable way to order events in a distributed system,
  144. for one the floating point value does not have enough precision, but
  145. also it's impossible to keep physical clocks in sync.
  146. Celery event messages have included a logical clock value for some time,
  147. but starting with this version that field is also used to order them
  148. (if the monitor is using ``celery.events.state``).
  149. The logical clock is currently implemented using Lamport timestamps,
  150. which does not have a high degree of accuracy, but should be good
  151. enough to casually order the events.
  152. - All events now include a ``pid`` field, which is the process id of the
  153. process that sent the event.
  154. - Events now supports timezones.
  155. A new ``utcoffset`` field is now sent with every event. This is a
  156. signed integer telling the difference from UTC time in hours,
  157. so e.g. an even sent from the Europe/London timezone in daylight savings
  158. time will have an offset of 1.
  159. :class:`@events.Receiver` will automatically convert the timestamps
  160. to the destination timezone.
  161. - Event heartbeats are now calculated based on the time when the event
  162. was received by the monitor, and not the time reported by the worker.
  163. This means that a worker with an out-of-sync clock will no longer
  164. show as 'Offline' in monitors.
  165. A warning is now emitted if the difference between the senders
  166. time and the internal time is greater than 15 seconds, suggesting
  167. that the clocks are out of sync.
  168. - :program:`celery worker` now supports a ``--detach`` argument to start
  169. the worker as a daemon in the background.
  170. - :class:`@events.Receiver` now sets a ``local_received`` field for incoming
  171. events, which is set to the time of when the event was received.
  172. - :class:`@events.Dispatcher` now accepts a ``groups`` argument
  173. which decides a whitelist of event groups that will be sent.
  174. The type of an event is a string separated by '-', where the part
  175. before the first '-' is the group. Currently there are only
  176. two groups: ``worker`` and ``task``.
  177. A dispatcher instantiated as follows:
  178. .. code-block:: python
  179. app.events.Dispatcher(connection, groups=['worker'])
  180. will only send worker related events and silently drop any attempts
  181. to send events related to any other group.
  182. - Better support for link and link_error tasks for chords.
  183. Contributed by Steeve Morin.
  184. - There's a now an 'inspect clock' command which will collect the current
  185. logical clock value from workers.
  186. - `celery inspect stats` now contains the process id of the worker's main
  187. process.
  188. Contributed by Mher Movsisyan.
  189. - New remote control command to dump a workers configuration.
  190. Example:
  191. .. code-block:: bash
  192. $ celery inspect conf
  193. Configuration values will be converted to values supported by JSON
  194. where possible.
  195. Contributed by Mher Movisyan.
  196. - Now supports Setuptools extra requirements.
  197. +-------------+-------------------------+---------------------------+
  198. | Extension | Requirement entry | Type |
  199. +=============+=========================+===========================+
  200. | Redis | ``celery[redis]`` | transport, result backend |
  201. +-------------+-------------------------+---------------------------+
  202. | MongoDB`` | ``celery[mongodb]`` | transport, result backend |
  203. +-------------+-------------------------+---------------------------+
  204. | CouchDB | ``celery[couchdb]`` | transport |
  205. +-------------+-------------------------+---------------------------+
  206. | Beanstalk | ``celery[beanstalk]`` | transport |
  207. +-------------+-------------------------+---------------------------+
  208. | ZeroMQ | ``celery[zeromq]`` | transport |
  209. +-------------+-------------------------+---------------------------+
  210. | Zookeeper | ``celery[zookeeper]`` | transport |
  211. +-------------+-------------------------+---------------------------+
  212. | SQLAlchemy | ``celery[sqlalchemy]`` | transport, result backend |
  213. +-------------+-------------------------+---------------------------+
  214. | librabbitmq | ``celery[librabbitmq]`` | transport (C amqp client) |
  215. +-------------+-------------------------+---------------------------+
  216. Examples using :program:`pip install`:
  217. .. code-block:: bash
  218. pip install celery[redis]
  219. pip install celery[librabbitmq]
  220. pip install celery[redis,librabbitmq]
  221. pip install celery[mongodb]
  222. pip install celery[couchdb]
  223. pip install celery[beanstalk]
  224. pip install celery[zeromq]
  225. pip install celery[zookeeper]
  226. pip install celery[sqlalchemy]
  227. - Worker node names now consists of a name and a hostname separated by '@'.
  228. This change is to more easily identify multiple instances running
  229. on the same machine.
  230. If a custom name is not specified then the
  231. worker will use the name 'celery' in default, resulting in a
  232. fully qualified node name of 'celery@hostname':
  233. .. code-block:: bash
  234. $ celery worker -n example.com
  235. celery@example.com
  236. To set the name you must include the @:
  237. .. code-block:: bash
  238. $ celery worker -n worker1@example.com
  239. worker1@example.com
  240. This also means that the worker will identify itself using the full
  241. nodename in events and broadcast messages, so where before
  242. a worker would identify as 'worker1.example.com', it will now
  243. use 'celery@worker1.example.com'.
  244. Remember that the ``-n`` argument also supports simple variable
  245. substitutions, so if the current hostname is *jerry.example.com*
  246. then ``%h`` will expand into that:
  247. .. code-block:: bash
  248. $ celery worker -n worker1@%h
  249. worker1@jerry.example.com
  250. The table of substitutions is as follows:
  251. +---------------+---------------------------------------+
  252. | Variable | Substitution |
  253. +===============+=======================================+
  254. | ``%h`` | Full hostname (including domain name) |
  255. +---------------+---------------------------------------+
  256. | ``%d`` | Domain name only |
  257. +---------------+---------------------------------------+
  258. | ``%n`` | Hostname only (without domain name) |
  259. +---------------+---------------------------------------+
  260. | ``%%`` | The character ``%`` |
  261. +---------------+---------------------------------------+
  262. - Workers now synchronizes revoked tasks with its neighbors.
  263. This happens at startup and causes a one second startup delay
  264. to collect broadcast responses from other workers.
  265. - Workers logical clock value is now persisted so that the clock
  266. is not reset when a worker restarts.
  267. The logical clock is also synchronized with other nodes
  268. in the same cluster (neighbors), so this means that the logical
  269. epoch will start at the point when the first worker in the cluster
  270. starts.
  271. You may notice that the logical clock is an integer value and increases
  272. very rapidly. It will take several millennia before the clock overflows 64 bits,
  273. so this is not a concern.
  274. - Message expires value is now forwarded at retry (Issue #980).
  275. The value is forwarded at is, so the expiry time will not change.
  276. To update the expiry time you would have to pass the expires
  277. argument to ``retry()``.
  278. - Worker now crashes if a channel error occurs.
  279. Channel errors are transport specific and is the list of exceptions
  280. returned by ``Connection.channel_errors``.
  281. For RabbitMQ this means that Celery will crash if the equivalence
  282. checks for one of the queues in :setting:`CELERY_QUEUES` mismatches, which
  283. makes sense since this is a scenario where manual intervention is
  284. required.
  285. - Calling ``AsyncResult.get()`` on a chain now propagates errors for previous
  286. tasks (Issue #1014).
  287. - The parent attribute of ``AsyncResult`` is now reconstructed when using JSON
  288. serialization (Issue #1014).
  289. - Worker disconnection logs are now logged with severity warning instead of
  290. error.
  291. Contributed by Chris Adams.
  292. - The logger named ``celery.concurrency`` has been renamed to ``celery.pool``.
  293. - New command line utility ``celery graph``
  294. This utility creates graphs in GraphViz dot format.
  295. You can create graphs from the currently installed bootsteps:
  296. .. code-block:: bash
  297. # Create graph of currently installed bootsteps in both the worker
  298. # and consumer namespaces.
  299. $ celery graph bootsteps | dot -T png -o steps.png
  300. # Graph of the consumer namespace only.
  301. $ celery graph bootsteps consumer | dot -T png -o consumer_only.png
  302. # Graph of the worker namespace only.
  303. $ celery graph bootsteps worker | dot -T png -o worker_only.png
  304. Or graphs of workers in a cluster:
  305. .. code-block:: bash
  306. # Create graph from the current cluster
  307. $ celery graph workers | dot -T png -o workers.png
  308. # Create graph from a specified list of workers
  309. $ celery graph workers nodes:w1,w2,w3 | dot -T png workers.png
  310. # also specify the number of threads in each worker
  311. $ celery graph workers nodes:w1,w2,w3 threads:2,4,6
  312. # ...also specify the broker and backend URLs shown in the graph
  313. $ celery graph workers broker:amqp:// backend:redis://
  314. # ...also specify the max number of workers/threads shown (wmax/tmax),
  315. # enumerating anything that exceeds that number.
  316. $ celery graph workers wmax:10 tmax:3
  317. - Ability to trace imports for debugging purposes.
  318. The :envvar:`C_IMPDEBUG` can be set to trace imports as they
  319. occur:
  320. .. code-block:: bash
  321. $ C_IMDEBUG=1 celery worker -l info
  322. .. code-block:: bash
  323. $ C_IMPDEBUG=1 celery shell
  324. - :class:`celery.apps.worker.Worker` has been refactored as a subclass of
  325. :class:`celery.worker.WorkController`.
  326. This removes a lot of duplicate functionality.
  327. - :class:`@events.Receiver` is now a :class:`kombu.mixins.ConsumerMixin`
  328. subclass.
  329. - ``celery.platforms.PIDFile`` renamed to :class:`celery.platforms.Pidfile`.
  330. - ``celery.results.BaseDictBackend`` has been removed, replaced by
  331. :class:``celery.results.BaseBackend``.
  332. .. _v310-experimental:
  333. Experimental
  334. ============
  335. XXX
  336. ---
  337. YYY
  338. .. _v310-removals:
  339. Scheduled Removals
  340. ==================
  341. - The ``BROKER_INSIST`` setting is no longer supported.
  342. - The ``CELERY_AMQP_TASK_RESULT_CONNECTION_MAX`` setting is no longer
  343. supported.
  344. Use :setting:`BROKER_POOL_LIMIT` instead.
  345. - The ``CELERY_TASK_ERROR_WHITELIST`` setting is no longer supported.
  346. You should set the :class:`~celery.utils.mail.ErrorMail` attribute
  347. of the task class instead. You can also do this using
  348. :setting:`CELERY_ANNOTATIONS`:
  349. .. code-block:: python
  350. from celery import Celery
  351. from celery.utils.mail import ErrorMail
  352. class MyErrorMail(ErrorMail):
  353. whitelist = (KeyError, ImportError)
  354. def should_send(self, context, exc):
  355. return isinstance(exc, self.whitelist)
  356. app = Celery()
  357. app.conf.CELERY_ANNOTATIONS = {
  358. '*': {
  359. 'ErrorMail': MyErrorMails,
  360. }
  361. }
  362. - The ``CELERY_AMQP_TASK_RESULT_EXPIRES`` setting is no longer supported.
  363. Use :setting:`CELERY_TASK_RESULT_EXPIRES` instead.
  364. - Functions that establishes broker connections no longer
  365. supports the ``connect_timeout`` argument.
  366. This can now only be set using the :setting:`BROKER_CONNECTION_TIMEOUT`
  367. setting. This is because function rarely establish connections directly,
  368. but instead acquire connections from the connection pool.
  369. .. _v310-deprecations:
  370. Deprecations
  371. ============
  372. See the :ref:`deprecation-timeline`.
  373. - XXX
  374. YYY
  375. .. _v310-fixes:
  376. Fixes
  377. =====
  378. - XXX