whatsnew-3.1.rst 19 KB

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