whatsnew-3.1.rst 36 KB

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