whatsnew-3.1.rst 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955
  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. - Now supports Django out of the box.
  27. See the new tutorial at :ref:`django-first-steps`.
  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. No longer supports Python 2.5
  42. -----------------------------
  43. Celery now requires Python 2.6 or later.
  44. We now have a dual codebase that runs on both Python 2 and 3 without
  45. using the ``2to3`` porting tool.
  46. Last version to use Pickle.
  47. ---------------------------
  48. Starting from Celery 3.2 the default serializer will be json.
  49. If you depend on pickle being accepted you should be prepared
  50. for this change by explicitly allowing your worker
  51. to consume pickled messages using the :setting:`CELERY_ACCEPT_CONTENT``
  52. setting::
  53. CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
  54. Make sure you select only the serialization formats that you will actually be using,
  55. and make sure you have properly secured your broker from unwanted access
  56. (see the :ref:`guide-security` guide).
  57. The worker will show a deprecation warning if you don't define this setting.
  58. .. _v310-news:
  59. News
  60. ====
  61. Now supports Django out of the box.
  62. -----------------------------------
  63. The fixes and improvements applied by the django-celery library is now
  64. automatically applied by core Celery when it detects that
  65. the :envvar:`DJANGO_SETTINGS_MODULE` environment variable is set.
  66. The distribution ships with a new example project using Django
  67. in :file:`examples/django`:
  68. http://github.com/celery/celery/tree/master/examples/django
  69. Some features still require the :mod:`django-celery` library:
  70. - Celery does not implement the Django database or cache result backends.
  71. - Celery does not ship with the database-based periodic task
  72. scheduler.
  73. .. note::
  74. If you are using django-celery then it is crucial that you have
  75. ``djcelery.setup_loader()`` in your settings module, as this
  76. no longer happens as a side-effect of importing the :mod:`djcelery`
  77. module.
  78. Multiprocessing Pool improvements
  79. :mod:`pytz` replaces ``python-dateutil`` dependency.
  80. ----------------------------------------------------
  81. Celery no longer depends on the ``python-dateutil`` library,
  82. but instead a new dependency on the :mod:`pytz` library was added.
  83. The :mod:`pytz` library was already recommended for accurate timezone support.
  84. This also means that dependencies are the same for both Python 2 and
  85. Python 3, and that the :file:`requirements/default-py3k.txt` file has
  86. been removed.
  87. Old command-line programs removed and deprecated
  88. ------------------------------------------------
  89. The goal is that everyone should move the new :program:`celery` umbrella
  90. command, so with this version we deprecate the old command names,
  91. and remove commands that are not used in init scripts.
  92. +-------------------+--------------+-------------------------------------+
  93. | Program | New Status | Replacement |
  94. +===================+==============+=====================================+
  95. | ``celeryd`` | *DEPRECATED* | :program:`celery worker` |
  96. +-------------------+--------------+-------------------------------------+
  97. | ``celerybeat`` | *DEPRECATED* | :program:`celery beat` |
  98. +-------------------+--------------+-------------------------------------+
  99. | ``celeryd-multi`` | *DEPRECATED* | :program:`celery multi` |
  100. +-------------------+--------------+-------------------------------------+
  101. | ``celeryctl`` | **REMOVED** | :program:`celery` |
  102. +-------------------+--------------+-------------------------------------+
  103. | ``celeryev`` | **REMOVED** | :program:`celery events` |
  104. +-------------------+--------------+-------------------------------------+
  105. | ``camqadm`` | **REMOVED** | :program:`celery amqp` |
  106. +-------------------+--------------+-------------------------------------+
  107. Please see :program:`celery --help` for help using the umbrella command.
  108. Bootsteps: Extending the worker
  109. -------------------------------
  110. By writing bootsteps you can now easily extend the consumer part
  111. of the worker to add additional features, or even message consumers.
  112. The worker has been using bootsteps for some time, but these were never
  113. documented. In this version the consumer part of the worker
  114. has also been rewritten to use bootsteps and the new :ref:`guide-extending`
  115. guide documents examples extending the worker, including adding
  116. custom message consumers.
  117. See the :ref:`guide-extending` guide for more information.
  118. .. note::
  119. Bootsteps written for older versions will not be compatible
  120. with this version, as the API has changed significantly.
  121. The old API was experimental and internal so hopefully no one
  122. is depending. Should you happen to be using it then please
  123. contact the mailing-list and we will help you port to the new version.
  124. New result backend with RPC semantics
  125. -------------------------------------
  126. This version of the ``amqp`` result backend is a very good alternative
  127. to use in classical RPC scenarios, where the process that initiates
  128. the task is always the process to retrieve the result.
  129. It uses Kombu to send and retrieve results, and each client
  130. will create a unique queue for replies to be sent to. Avoiding
  131. the significant overhead of the original amqp backend which creates
  132. one queue per task.
  133. Results sent using this backend is not persistent, and so will
  134. not survive a broker restart, but you can set
  135. the :setting:`CELERY_RESULT_PERSISTENT` setting to change that.
  136. .. code-block:: python
  137. CELERY_RESULT_BACKEND = 'rpc'
  138. Note that chords are currently not supported by the RPC backend.
  139. Time limits can now be set by the client.
  140. -----------------------------------------
  141. You can set both hard and soft time limits using the ``time_limit`` and
  142. ``soft_time_limit`` calling options:
  143. .. code-block:: python
  144. >>> res = add.apply_async((2, 2), time_limit=10, soft_time_limit=8)
  145. >>> res = add.subtask((2, 2), time_limit=10, soft_time_limit=8).delay()
  146. >>> res = add.s(2, 2).set(time_limit=10, soft_time_limit=8).delay()
  147. Contributed by Mher Movsisyan.
  148. Redis: Separate broadcast messages by virtual host
  149. ---------------------------------------------------------------------------
  150. Broadcast messages are seen by all virtual hosts when using the Redis
  151. transport. You can fix this by enabling a prefix to all channels
  152. so that the messages are separated by virtual host::
  153. BROKER_TRANSPORT_OPTIONS = {'fanout_prefix': True}
  154. Note that you will not be able to communicate with workers running older
  155. versions or workers that does not have this setting enabled.
  156. This setting will be the default in the future, so better to migrate
  157. sooner rather than later.
  158. Related to Issue #1490.
  159. Events are now ordered using logical time.
  160. ------------------------------------------
  161. Timestamps are not a reliable way to order events in a distributed system,
  162. for one the floating point value does not have enough precision, but
  163. also it's impossible to keep physical clocks in sync.
  164. Celery event messages have included a logical clock value for some time,
  165. but starting with this version that field is also used to order them
  166. (that is if the monitor is using :mod:`celery.events.state`).
  167. The logical clock is currently implemented using Lamport timestamps,
  168. which does not have a high degree of accuracy, but should be good
  169. enough to casually order the events.
  170. Also, events now records timezone information for better timestamp
  171. accuracy, where a new ``utcoffset`` field is included in the event.
  172. This is a signed integer telling the difference from UTC time in hours,
  173. so e.g. an even sent from the Europe/London timezone in daylight savings
  174. time will have an offset of 1.
  175. :class:`@events.Receiver` will automatically convert the timestamps
  176. to the destination timezone.
  177. .. note::
  178. The logical clock is synchronized with other nodes
  179. in the same cluster (neighbors), so this means that the logical
  180. epoch will start at the point when the first worker in the cluster
  181. starts.
  182. If all of the workers are shutdown the clock value will be lost
  183. and reset to 0, to protect against this you should specify
  184. a :option:`--statedb` so that the worker can persist the clock
  185. value at shutdown.
  186. You may notice that the logical clock is an integer value and
  187. increases very rapidly. Do not worry about the value overflowing
  188. though, as even in the most busy clusters it may take several
  189. millennia before the clock exceeds a 64 bits value.
  190. New worker node name format (``name@host``).
  191. -------------------------------------------------------------------------
  192. Node names are now constructed by a node name and a hostname separated by '@'.
  193. This change was made to more easily identify multiple instances running
  194. on the same machine.
  195. If a custom name is not specified then the
  196. worker will use the name 'celery' by default, resulting in a
  197. fully qualified node name of 'celery@hostname':
  198. .. code-block:: bash
  199. $ celery worker -n example.com
  200. celery@example.com
  201. To also set the name you must include the @:
  202. .. code-block:: bash
  203. $ celery worker -n worker1@example.com
  204. worker1@example.com
  205. The worker will identify itself using the fully qualified
  206. node name in events and broadcast messages, so where before
  207. a worker would identify as 'worker1.example.com', it will now
  208. use 'celery@worker1.example.com'.
  209. Remember that the ``-n`` argument also supports simple variable
  210. substitutions, so if the current hostname is *jerry.example.com*
  211. then ``%h`` will expand into that:
  212. .. code-block:: bash
  213. $ celery worker -n worker1@%h
  214. worker1@jerry.example.com
  215. The available substitutions are as follows:
  216. +---------------+---------------------------------------+
  217. | Variable | Substitution |
  218. +===============+=======================================+
  219. | ``%h`` | Full hostname (including domain name) |
  220. +---------------+---------------------------------------+
  221. | ``%d`` | Domain name only |
  222. +---------------+---------------------------------------+
  223. | ``%n`` | Hostname only (without domain name) |
  224. +---------------+---------------------------------------+
  225. | ``%%`` | The character ``%`` |
  226. +---------------+---------------------------------------+
  227. Bound tasks
  228. -----------
  229. The task decorator can now created "bound tasks", which means that the
  230. task will receive the ``self`` argument.
  231. .. code-block:: python
  232. @app.task(bind=True)
  233. def send_twitter_status(self, oauth, tweet):
  234. try:
  235. twitter = Twitter(oauth)
  236. twitter.update_status(tweet)
  237. except (Twitter.FailWhaleError, Twitter.LoginError) as exc:
  238. raise self.retry(exc=exc)
  239. Using *bound tasks* is now the recommended approach whenever
  240. you need access to the current task or request context.
  241. Previously one would have to refer to the name of the task
  242. instead (``send_twitter_status.retry``), but this could lead to problems
  243. in some instances where the registered task was no longer the same
  244. object.
  245. Gossip: Worker <-> Worker communication.
  246. ----------------------------------------
  247. Workers now synchronizes revoked tasks with its neighbors.
  248. This happens at startup and causes a one second startup delay
  249. to collect broadcast responses from other workers.
  250. Now supports Setuptools extra requirements.
  251. -------------------------------------------
  252. Pip now supports installing setuptools extra requirements
  253. so we have deprecated the old bundles, replacing them with these
  254. little creatures, which are more convenient since you can easily
  255. specify multiple extras (e.g. ``pip install celery[redis,mongodb]``).
  256. +-------------+-------------------------+---------------------------+
  257. | Extension | Requirement entry | Type |
  258. +=============+=========================+===========================+
  259. | Redis | ``celery[redis]`` | transport, result backend |
  260. +-------------+-------------------------+---------------------------+
  261. | MongoDB`` | ``celery[mongodb]`` | transport, result backend |
  262. +-------------+-------------------------+---------------------------+
  263. | CouchDB | ``celery[couchdb]`` | transport |
  264. +-------------+-------------------------+---------------------------+
  265. | Beanstalk | ``celery[beanstalk]`` | transport |
  266. +-------------+-------------------------+---------------------------+
  267. | ZeroMQ | ``celery[zeromq]`` | transport |
  268. +-------------+-------------------------+---------------------------+
  269. | Zookeeper | ``celery[zookeeper]`` | transport |
  270. +-------------+-------------------------+---------------------------+
  271. | SQLAlchemy | ``celery[sqlalchemy]`` | transport, result backend |
  272. +-------------+-------------------------+---------------------------+
  273. | librabbitmq | ``celery[librabbitmq]`` | transport (C amqp client) |
  274. +-------------+-------------------------+---------------------------+
  275. There are more examples in the :ref:`bundles` section.
  276. Calling a subtask will now execute the task directly
  277. ----------------------------------------------------
  278. A misunderstanding led to ``Signature.__call__`` being an alias of
  279. ``.delay`` but this does not conform to the calling API of ``Task`` which
  280. should call the underlying task method.
  281. This means that:
  282. .. code-block:: python
  283. @app.task
  284. def add(x, y):
  285. return x + y
  286. add.s(2, 2)()
  287. now does the same as calling the task directly:
  288. .. code-block:: python
  289. add(2, 2)
  290. In Other News
  291. -------------
  292. - Now depends on :ref:`Kombu 3.0 <kombu:version-3.0.0>`.
  293. - Now depends on :mod:`billiard` version 3.3.
  294. - Worker will now crash if running as the root user with pickle enabled.
  295. - Canvas: ``group.apply_async`` and ``chain.apply_async`` no longer starts
  296. separate task.
  297. That the group and chord primitives supported the "calling API" like other
  298. subtasks was a nice idea, but it was useless in practice, often confusing
  299. users. If you still want this behavior you can create a task to do it
  300. for you.
  301. - New method ``Signature.freeze()`` can be used to "finalize"
  302. signatures/subtask.
  303. Regular signature:
  304. .. code-block:: python
  305. >>> s = add.s(2, 2)
  306. >>> result = s.freeze()
  307. >>> result
  308. <AsyncResult: ffacf44b-f8a1-44e9-80a3-703150151ef2>
  309. >>> s.delay()
  310. <AsyncResult: ffacf44b-f8a1-44e9-80a3-703150151ef2>
  311. Group:
  312. .. code-block:: python
  313. >>> g = group(add.s(2, 2), add.s(4, 4))
  314. >>> result = g.freeze()
  315. <GroupResult: e1094b1d-08fc-4e14-838e-6d601b99da6d [
  316. 70c0fb3d-b60e-4b22-8df7-aa25b9abc86d,
  317. 58fcd260-2e32-4308-a2ea-f5be4a24f7f4]>
  318. >>> g()
  319. <GroupResult: e1094b1d-08fc-4e14-838e-6d601b99da6d [70c0fb3d-b60e-4b22-8df7-aa25b9abc86d, 58fcd260-2e32-4308-a2ea-f5be4a24f7f4]>
  320. - New ability to specify additional command line options
  321. to the worker and beat programs.
  322. The :attr:`@Celery.user_options` attribute can be used
  323. to add additional command-line arguments, and expects
  324. optparse-style options:
  325. .. code-block:: python
  326. from celery import Celery
  327. from optparse import make_option as Option
  328. app = Celery()
  329. app.user_options['worker'].add(
  330. Option('--my-argument'),
  331. )
  332. See the :ref:`guide-extending` guide for more information.
  333. - All events now include a ``pid`` field, which is the process id of the
  334. process that sent the event.
  335. - Event heartbeats are now calculated based on the time when the event
  336. was received by the monitor, and not the time reported by the worker.
  337. This means that a worker with an out-of-sync clock will no longer
  338. show as 'Offline' in monitors.
  339. A warning is now emitted if the difference between the senders
  340. time and the internal time is greater than 15 seconds, suggesting
  341. that the clocks are out of sync.
  342. - Many parts of the Celery codebase now uses a montonic clock.
  343. The montonic clock function is built-in starting from Python 3.4,
  344. but we also have fallback implementaions for Linux and OS X.
  345. - :program:`celery worker` now supports a ``--detach`` argument to start
  346. the worker as a daemon in the background.
  347. - :class:`@events.Receiver` now sets a ``local_received`` field for incoming
  348. events, which is set to the time of when the event was received.
  349. - :class:`@events.Dispatcher` now accepts a ``groups`` argument
  350. which decides a whitelist of event groups that will be sent.
  351. The type of an event is a string separated by '-', where the part
  352. before the first '-' is the group. Currently there are only
  353. two groups: ``worker`` and ``task``.
  354. A dispatcher instantiated as follows:
  355. .. code-block:: python
  356. app.events.Dispatcher(connection, groups=['worker'])
  357. will only send worker related events and silently drop any attempts
  358. to send events related to any other group.
  359. - ``Result.revoke`` will no longer wait for replies.
  360. You can add the ``reply=True`` argument if you really want to wait for
  361. responses from the workers.
  362. - Better support for link and link_error tasks for chords.
  363. Contributed by Steeve Morin.
  364. - There's a now an 'inspect clock' command which will collect the current
  365. logical clock value from workers.
  366. - `celery inspect stats` now contains the process id of the worker's main
  367. process.
  368. Contributed by Mher Movsisyan.
  369. - New remote control command to dump a workers configuration.
  370. Example:
  371. .. code-block:: bash
  372. $ celery inspect conf
  373. Configuration values will be converted to values supported by JSON
  374. where possible.
  375. Contributed by Mher Movisyan.
  376. - New settings :setting:`CELERY_EVENT_QUEUE_TTL` and
  377. :setting:`CELERY_EVENT_QUEUE_EXPIRES`.
  378. These control when a monitors event queue is deleted, and for how long
  379. events published to that queue will be visible. Only supported on
  380. RabbitMQ.
  381. - New Couchbase result backend
  382. This result backend enables you to store and retrieve task results
  383. using `Couchbase`_.
  384. See :ref:`conf-couchbase-result-backend` for more information
  385. about configuring this result backend.
  386. Contributed by Alain Masiero.
  387. .. _`Couchbase`: http://www.couchbase.com
  388. - CentOS init script now supports starting multiple worker instances.
  389. See the script header for details.
  390. Contributed by Jonathan Jordan.
  391. - ``AsyncResult.iter_native`` now sets default interval parameter to 0.5
  392. Fix contributed by Idan Kamara
  393. - New setting :setting:`BROKER_LOGIN_METHOD`
  394. This setting can be used to specify an alternate login method
  395. for the AMQP transports.
  396. Contributed by Adrien Guinet
  397. - The ``dump_conf`` remote control command will now give the string
  398. representation for types that are not JSON compatible.
  399. - Function `celery.security.setup_security` is now :func:`celery.setup_security`.
  400. - Message expires value is now forwarded at retry (Issue #980).
  401. The value is forwarded at is, so the expiry time will not change.
  402. To update the expiry time you would have to pass the expires
  403. argument to ``retry()``.
  404. - Worker now crashes if a channel error occurs.
  405. Channel errors are transport specific and is the list of exceptions
  406. returned by ``Connection.channel_errors``.
  407. For RabbitMQ this means that Celery will crash if the equivalence
  408. checks for one of the queues in :setting:`CELERY_QUEUES` mismatches, which
  409. makes sense since this is a scenario where manual intervention is
  410. required.
  411. - Calling ``AsyncResult.get()`` on a chain now propagates errors for previous
  412. tasks (Issue #1014).
  413. - The parent attribute of ``AsyncResult`` is now reconstructed when using JSON
  414. serialization (Issue #1014).
  415. - Worker disconnection logs are now logged with severity warning instead of
  416. error.
  417. Contributed by Chris Adams.
  418. - ``events.State`` no longer crashes when it receives unknown event types.
  419. - SQLAlchemy Result Backend: New :setting:`CELERY_RESULT_DB_TABLENAMES`
  420. setting can be used to change the name of the database tables used.
  421. Contributed by Ryan Petrello.
  422. - A stress test suite for the Celery worker has been written.
  423. This is located in the ``funtests/stress`` directory in the git
  424. repository. There's a README file there to get you started.
  425. - The logger named ``celery.concurrency`` has been renamed to ``celery.pool``.
  426. - New command line utility ``celery graph``
  427. This utility creates graphs in GraphViz dot format.
  428. You can create graphs from the currently installed bootsteps:
  429. .. code-block:: bash
  430. # Create graph of currently installed bootsteps in both the worker
  431. # and consumer namespaces.
  432. $ celery graph bootsteps | dot -T png -o steps.png
  433. # Graph of the consumer namespace only.
  434. $ celery graph bootsteps consumer | dot -T png -o consumer_only.png
  435. # Graph of the worker namespace only.
  436. $ celery graph bootsteps worker | dot -T png -o worker_only.png
  437. Or graphs of workers in a cluster:
  438. .. code-block:: bash
  439. # Create graph from the current cluster
  440. $ celery graph workers | dot -T png -o workers.png
  441. # Create graph from a specified list of workers
  442. $ celery graph workers nodes:w1,w2,w3 | dot -T png workers.png
  443. # also specify the number of threads in each worker
  444. $ celery graph workers nodes:w1,w2,w3 threads:2,4,6
  445. # ...also specify the broker and backend URLs shown in the graph
  446. $ celery graph workers broker:amqp:// backend:redis://
  447. # ...also specify the max number of workers/threads shown (wmax/tmax),
  448. # enumerating anything that exceeds that number.
  449. $ celery graph workers wmax:10 tmax:3
  450. - Changed the way that app instances are pickled
  451. Apps can now define a ``__reduce_keys__`` method that is used instead
  452. of the old ``AppPickler`` attribute. E.g. if your app defines a custom
  453. 'foo' attribute that needs to be preserved when pickling you can define
  454. a ``__reduce_keys__`` as such:
  455. .. code-block:: python
  456. import celery
  457. class Celery(celery.Celery):
  458. def __init__(self, *args, **kwargs):
  459. super(Celery, self).__init__(*args, **kwargs)
  460. self.foo = kwargs.get('foo')
  461. def __reduce_keys__(self):
  462. return super(Celery, self).__reduce_keys__().update(
  463. foo=self.foo,
  464. )
  465. This is a much more convenient way to add support for pickling custom
  466. attributes. The old ``AppPickler`` is still supported but its use is
  467. discouraged and we would like to remove it in a future version.
  468. - Ability to trace imports for debugging purposes.
  469. The :envvar:`C_IMPDEBUG` can be set to trace imports as they
  470. occur:
  471. .. code-block:: bash
  472. $ C_IMDEBUG=1 celery worker -l info
  473. .. code-block:: bash
  474. $ C_IMPDEBUG=1 celery shell
  475. - Message headers now available as part of the task request.
  476. Example setting and retreiving a header value::
  477. @app.task(bind=True)
  478. def t(self):
  479. return self.request.headers.get('sender')
  480. >>> t.apply_async(headers={'sender': 'George Costanza'})
  481. - :class:`@events.Receiver` is now a :class:`kombu.mixins.ConsumerMixin`
  482. subclass.
  483. - New :signal:`task_send`` signal dispatched before a task message
  484. is sent and can be used to modify the final message fields (Issue #1281).
  485. - ``celery.platforms.PIDFile`` renamed to :class:`celery.platforms.Pidfile`.
  486. - ``celery.results.BaseDictBackend`` has been removed, replaced by
  487. :class:``celery.results.BaseBackend``.
  488. - MongoDB Backend: Can now be configured using an URL
  489. See :ref:`example-mongodb-result-config`.
  490. - MongoDB Backend: No longer using deprecated ``pymongo.Connection``.
  491. - MongoDB Backend: Now disables ``auto_start_request``.
  492. - MongoDB Backend: Now enables ``use_greenlets`` when eventlet/gevent is used.
  493. - ``subtask()`` / ``maybe_subtask()`` renamed to
  494. ``signature()``/``maybe_signature()``.
  495. Aliases still available for backwards compatibility.
  496. - The ``correlation_id`` message property is now automatically set to the
  497. id of the task.
  498. - The task message ``eta`` and ``expires`` fields now includes timezone
  499. information.
  500. - All result backends ``store_result``/``mark_as_*`` methods must now accept
  501. a ``request`` keyword argument.
  502. - Events now emit warning if the broken ``yajl`` library is used.
  503. - The :signal:`celeryd_init` signal now takes an extra keyword argument:
  504. ``option``.
  505. This is the mapping of parsed command line arguments, and can be used to
  506. prepare new preload arguments (``app.user_options['preload']``).
  507. - New callback: ``Celery.on_configure``.
  508. This callback is called when an app is about to be configured (a
  509. configuration key is required).
  510. - Eventlet/gevent/solo/threads pools now properly handles BaseException errors
  511. raised by tasks.
  512. - Multi: Now properly handles both ``-f`` and ``--logfile`` options
  513. (Issue #1541).
  514. .. _v310-experimental:
  515. Experimental
  516. ============
  517. XXX
  518. ---
  519. YYY
  520. .. _v310-removals:
  521. Scheduled Removals
  522. ==================
  523. - The ``BROKER_INSIST`` setting is no longer supported.
  524. - The ``CELERY_AMQP_TASK_RESULT_CONNECTION_MAX`` setting is no longer
  525. supported.
  526. Use :setting:`BROKER_POOL_LIMIT` instead.
  527. - The ``CELERY_TASK_ERROR_WHITELIST`` setting is no longer supported.
  528. You should set the :class:`~celery.utils.mail.ErrorMail` attribute
  529. of the task class instead. You can also do this using
  530. :setting:`CELERY_ANNOTATIONS`:
  531. .. code-block:: python
  532. from celery import Celery
  533. from celery.utils.mail import ErrorMail
  534. class MyErrorMail(ErrorMail):
  535. whitelist = (KeyError, ImportError)
  536. def should_send(self, context, exc):
  537. return isinstance(exc, self.whitelist)
  538. app = Celery()
  539. app.conf.CELERY_ANNOTATIONS = {
  540. '*': {
  541. 'ErrorMail': MyErrorMails,
  542. }
  543. }
  544. - Worker: No longer forks on :sig:`HUP`
  545. This means that the worker will reuse the same pid, which makes it
  546. easier for process supervisors.
  547. Contributed by Jameel Al-Aziz.
  548. - The ``CELERY_AMQP_TASK_RESULT_EXPIRES`` setting is no longer supported.
  549. Use :setting:`CELERY_TASK_RESULT_EXPIRES` instead.
  550. - Functions that establishes broker connections no longer
  551. supports the ``connect_timeout`` argument.
  552. This can now only be set using the :setting:`BROKER_CONNECTION_TIMEOUT`
  553. setting. This is because the functions no longer create connections
  554. directly, and instead get them from the connection pool.
  555. - The ``Celery.with_default_connection`` method has been removed in favor
  556. of ``with app.connection_or_acquire``.
  557. - The :signal:`task_revoked` signal now accepts new ``request`` argument
  558. (Issue #1555).
  559. The revoked signal is dispatched after the task request is removed from
  560. the stack, so it must instead use the :class:`~celery.worker.job.Request`
  561. object to get information about the task.
  562. - Worker: New :option:`-X` command line argument to exclude queues
  563. (Issue #1399).
  564. The :option:`-X` argument is the inverse of the :option:`-Q` argument
  565. and accepts a list of queues to exclude (not consume from):
  566. .. code-block:: bash
  567. # Consume from all queues in CELERY_QUEUES, but not the 'foo' queue.
  568. $ celery worker -A proj -l info -X foo
  569. - New public API to push and pop from the current task stack:
  570. :func:`celery.app.push_current_task` and
  571. :func:`celery.app.pop_current_task``.
  572. - ``RetryTaskError`` has been renamed to :exc:`~celery.exceptions.Retry`.
  573. The old name is still available for backwards compatibility.
  574. - New semipredicate exception :exc:`~celery.exceptions.Reject`
  575. This exception can be raised to reject/requeue the task message,
  576. see :ref:`task-semipred-reject` for examples.
  577. - Semipredicates documented: :ref:`task-semipredicates` (Retry/Ignore/Reject).
  578. .. _v310-deprecations:
  579. Deprecations
  580. ============
  581. See the :ref:`deprecation-timeline`.
  582. - XXX
  583. YYY
  584. .. _v310-fixes:
  585. Fixes
  586. =====
  587. - AMQP Backend: join did not convert exceptions when using the json
  588. serializer.
  589. - Worker: Workaround for unicode errors in logs (Issue #427)
  590. - Task methods: ``.apply_async`` now works properly if args list is None
  591. (Issue #1459).
  592. - Autoscale and ``pool_grow``/``pool_shrink`` remote control commands
  593. will now also automatically increase and decrease the consumer prefetch count.
  594. Fix contributed by Daniel M. Taub.
  595. - Optimization: Improved performance of ``ResultSet.join_native()``.
  596. Contributed by Stas Rudakou.
  597. - ``celery control pool_`` commands did not coerce string arguments to int.
  598. - Redis/Cache chords: Callback result is now set to failure if the group
  599. disappeared from the database (Issue #1094).
  600. - Worker: Now makes sure that the shutdown process is not initiated multiple
  601. times.
  602. - Adds :envvar:`C_FAKEFORK` envvar for simple init script/multi debugging
  603. This means that you can now do:
  604. .. code-block:: bash
  605. $ C_FAKEFORK=1 celery multi start 10
  606. or:
  607. .. code-block:: bash
  608. $ C_FAKEFORK=1 /etc/init.d/celeryd start
  609. to avoid the daemonization step to see errors that are not visible
  610. due to missing stdout/stderr.
  611. A ``dryrun`` command has been added to the generic init script that
  612. enables this option.
  613. .. _v310-internal:
  614. Internal changes
  615. ================
  616. - Module ``celery.task.trace`` has been renamed to :mod:`celery.app.trace`.
  617. - Classes that no longer fall back to using the default app:
  618. - Result backends (:class:`celery.backends.base.BaseBackend`)
  619. - :class:`celery.worker.WorkController`
  620. - :class:`celery.worker.Consumer`
  621. - :class:`celery.worker.job.Request`
  622. This means that you have to pass a specific app when instantiating
  623. these classes.
  624. - ``EventDispatcher.copy_buffer`` renamed to ``EventDispatcher.extend_buffer``
  625. - Removed unused and never documented global instance
  626. ``celery.events.state.state``.
  627. - :class:`celery.apps.worker.Worker` has been refactored as a subclass of
  628. :class:`celery.worker.WorkController`.
  629. This removes a lot of duplicate functionality.