whatsnew-3.0.rst 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. .. _whatsnew-3.0:
  2. ===========================================
  3. What's new in Celery 3.0 (Chiastic Slide)
  4. ===========================================
  5. Celery is a simple, flexible, and reliable distributed system to
  6. process vast amounts of messages, while providing operations with
  7. the tools required to maintain such a system.
  8. It's a task queue with focus on real-time processing, while also
  9. supporting task scheduling.
  10. Celery has a large and diverse community of users and contributors,
  11. you should come join us :ref:`on IRC <irc-channel>`
  12. or :ref:`our mailing-list <mailing-list>`.
  13. To read more about Celery you should go read the :ref:`introduction <intro>`.
  14. While this version is backward compatible with previous versions
  15. it's important that you read the following section.
  16. If you use Celery in combination with Django you must also
  17. read the `django-celery changelog`_ and upgrade
  18. to :pypi:`django-celery 3.0 <django-celery>`.
  19. This version is officially supported on CPython 2.5, 2.6, 2.7, 3.2 and 3.3,
  20. as well as PyPy and Jython.
  21. Highlights
  22. ==========
  23. .. topic:: Overview
  24. - A new and improved API, that's both simpler and more powerful.
  25. Everyone must read the new :ref:`first-steps` tutorial,
  26. and the new :ref:`next-steps` tutorial. Oh, and
  27. why not reread the user guide while you're at it :)
  28. There are no current plans to deprecate the old API,
  29. so you don't have to be in a hurry to port your applications.
  30. - The worker is now thread-less, giving great performance improvements.
  31. - The new "Canvas" makes it easy to define complex work-flows.
  32. Ever wanted to chain tasks together? This is possible, but
  33. not just that, now you can even chain together groups and chords,
  34. or even combine multiple chains.
  35. Read more in the :ref:`Canvas <guide-canvas>` user guide.
  36. - All of Celery's command-line programs are now available from a single
  37. :program:`celery` umbrella command.
  38. - This is the last version to support Python 2.5.
  39. Starting with Celery 3.1, Python 2.6 or later is required.
  40. - Support for the new :pypi:`librabbitmq` C client.
  41. Celery will automatically use the :pypi:`librabbitmq` module
  42. if installed, which is a very fast and memory-optimized
  43. replacement for the :pypi:`amqp` module.
  44. - Redis support is more reliable with improved ack emulation.
  45. - Celery now always uses UTC
  46. - Over 600 commits, 30k additions/36k deletions.
  47. In comparison 1.0➝ 2.0 had 18k additions/8k deletions.
  48. .. _`website`: http://celeryproject.org/
  49. .. _`django-celery changelog`:
  50. https://github.com/celery/django-celery/tree/master/Changelog
  51. .. contents::
  52. :local:
  53. :depth: 2
  54. .. _v300-important:
  55. Important Notes
  56. ===============
  57. Broadcast exchanges renamed
  58. ---------------------------
  59. The workers remote control command exchanges has been renamed
  60. (a new :term:`pidbox` name), this is because the ``auto_delete`` flag on
  61. the exchanges has been removed, and that makes it incompatible with
  62. earlier versions.
  63. You can manually delete the old exchanges if you want,
  64. using the :program:`celery amqp` command (previously called ``camqadm``):
  65. .. code-block:: console
  66. $ celery amqp exchange.delete celeryd.pidbox
  67. $ celery amqp exchange.delete reply.celeryd.pidbox
  68. Event-loop
  69. ----------
  70. The worker is now running *without threads* when used with RabbitMQ (AMQP),
  71. or Redis as a broker, resulting in:
  72. - Much better overall performance.
  73. - Fixes several edge case race conditions.
  74. - Sub-millisecond timer precision.
  75. - Faster shutdown times.
  76. The transports supported are: ``py-amqp`` ``librabbitmq``, ``redis``,
  77. and ``amqplib``.
  78. Hopefully this can be extended to include additional broker transports
  79. in the future.
  80. For increased reliability the :setting:`CELERY_FORCE_EXECV` setting is enabled
  81. by default if the event-loop isn't used.
  82. New ``celery`` umbrella command
  83. -------------------------------
  84. All Celery's command-line programs are now available from a single
  85. :program:`celery` umbrella command.
  86. You can see a list of sub-commands and options by running:
  87. .. code-block:: console
  88. $ celery help
  89. Commands include:
  90. - ``celery worker`` (previously ``celeryd``).
  91. - ``celery beat`` (previously ``celerybeat``).
  92. - ``celery amqp`` (previously ``camqadm``).
  93. The old programs are still available (``celeryd``, ``celerybeat``, etc),
  94. but you're discouraged from using them.
  95. Now depends on :pypi:`billiard`
  96. -------------------------------
  97. Billiard is a fork of the multiprocessing containing
  98. the no-execv patch by ``sbt`` (http://bugs.python.org/issue8713),
  99. and also contains the pool improvements previously located in Celery.
  100. This fork was necessary as changes to the C extension code was required
  101. for the no-execv patch to work.
  102. - Issue #625
  103. - Issue #627
  104. - Issue #640
  105. - `django-celery #122 <https://github.com/celery/django-celery/issues/122`
  106. - `django-celery #124 <https://github.com/celery/django-celery/issues/122`
  107. :mod:`celery.app.task` no longer a package
  108. ------------------------------------------
  109. The :mod:`celery.app.task` module is now a module instead of a package.
  110. The :file:`setup.py` install script will try to remove the old package,
  111. but if that doesn't work for some reason you have to remove
  112. it manually. This command helps:
  113. .. code-block:: console
  114. $ rm -r $(dirname $(python -c 'import celery;print(celery.__file__)'))/app/task/
  115. If you experience an error like ``ImportError: cannot import name _unpickle_task``,
  116. you just have to remove the old package and everything is fine.
  117. Last version to support Python 2.5
  118. ----------------------------------
  119. The 3.0 series will be last version to support Python 2.5,
  120. and starting from 3.1 Python 2.6 and later will be required.
  121. With several other distributions taking the step to discontinue
  122. Python 2.5 support, we feel that it is time too.
  123. Python 2.6 should be widely available at this point, and we urge
  124. you to upgrade, but if that's not possible you still have the option
  125. to continue using the Celery 3.0, and important bug fixes
  126. introduced in Celery 3.1 will be back-ported to Celery 3.0 upon request.
  127. UTC timezone is now used
  128. ------------------------
  129. This means that ETA/countdown in messages aren't compatible with Celery
  130. versions prior to 2.5.
  131. You can disable UTC and revert back to old local time by setting
  132. the :setting:`CELERY_ENABLE_UTC` setting.
  133. Redis: Ack emulation improvements
  134. ---------------------------------
  135. Reducing the possibility of data loss.
  136. Acks are now implemented by storing a copy of the message when the message
  137. is consumed. The copy isn't removed until the consumer acknowledges
  138. or rejects it.
  139. This means that unacknowledged messages will be redelivered either
  140. when the connection is closed, or when the visibility timeout is exceeded.
  141. - Visibility timeout
  142. This is a timeout for acks, so that if the consumer
  143. doesn't ack the message within this time limit, the message
  144. is redelivered to another consumer.
  145. The timeout is set to one hour by default, but
  146. can be changed by configuring a transport option::
  147. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 18000} # 5 hours
  148. .. note::
  149. Messages that haven't been acked will be redelivered
  150. if the visibility timeout is exceeded, for Celery users
  151. this means that ETA/countdown tasks that are scheduled to execute
  152. with a time that exceeds the visibility timeout will be executed
  153. twice (or more). If you plan on using long ETA/countdowns you
  154. should tweak the visibility timeout accordingly.
  155. Setting a long timeout means that it'll take a long time
  156. for messages to be redelivered in the event of a power failure,
  157. but if so happens you could temporarily set the visibility timeout lower
  158. to flush out messages when you start up the systems again.
  159. .. _v300-news:
  160. News
  161. ====
  162. Chaining Tasks
  163. --------------
  164. Tasks can now have callbacks and errbacks, and dependencies are recorded
  165. - The task message format have been updated with two new extension keys
  166. Both keys can be empty/undefined or a list of subtasks.
  167. - ``callbacks``
  168. Applied if the task exits successfully, with the result
  169. of the task as an argument.
  170. - ``errbacks``
  171. Applied if an error occurred while executing the task,
  172. with the uuid of the task as an argument. Since it may not be possible
  173. to serialize the exception instance, it passes the uuid of the task
  174. instead. The uuid can then be used to retrieve the exception and
  175. traceback of the task from the result backend.
  176. - ``link`` and ``link_error`` keyword arguments has been added
  177. to ``apply_async``.
  178. These add callbacks and errbacks to the task, and
  179. you can read more about them at :ref:`calling-links`.
  180. - We now track what subtasks a task sends, and some result backends
  181. supports retrieving this information.
  182. - task.request.children
  183. Contains the result instances of the subtasks
  184. the currently executing task has applied.
  185. - AsyncResult.children
  186. Returns the tasks dependencies, as a list of
  187. ``AsyncResult``/``ResultSet`` instances.
  188. - AsyncResult.iterdeps
  189. Recursively iterates over the tasks dependencies,
  190. yielding `(parent, node)` tuples.
  191. Raises IncompleteStream if any of the dependencies
  192. hasn't returned yet.
  193. - AsyncResult.graph
  194. A :class:`~celery.utils.graph.DependencyGraph` of the tasks
  195. dependencies. With this you can also convert to dot format:
  196. .. code-block:: python
  197. with open('graph.dot') as fh:
  198. result.graph.to_dot(fh)
  199. then produce an image of the graph:
  200. .. code-block:: console
  201. $ dot -Tpng graph.dot -o graph.png
  202. - A new special subtask called ``chain`` is also included:
  203. .. code-block:: pycon
  204. >>> from celery import chain
  205. # (2 + 2) * 8 / 2
  206. >>> res = chain(add.subtask((2, 2)),
  207. mul.subtask((8,)),
  208. div.subtask((2,))).apply_async()
  209. >>> res.get() == 16
  210. >>> res.parent.get() == 32
  211. >>> res.parent.parent.get() == 4
  212. - Adds :meth:`AsyncResult.get_leaf`
  213. Waits and returns the result of the leaf subtask.
  214. That's the last node found when traversing the graph,
  215. but this means that the graph can be 1-dimensional only (in effect
  216. a list).
  217. - Adds ``subtask.link(subtask)`` + ``subtask.link_error(subtask)``
  218. Shortcut to ``s.options.setdefault('link', []).append(subtask)``
  219. - Adds ``subtask.flatten_links()``
  220. Returns a flattened list of all dependencies (recursively)
  221. Redis: Priority support
  222. -----------------------
  223. The message's ``priority`` field is now respected by the Redis
  224. transport by having multiple lists for each named queue.
  225. The queues are then consumed by in order of priority.
  226. The priority field is a number in the range of 0 - 9, where
  227. 0 is the default and highest priority.
  228. The priority range is collapsed into four steps by default, since it is
  229. unlikely that nine steps will yield more benefit than using four steps.
  230. The number of steps can be configured by setting the ``priority_steps``
  231. transport option, which must be a list of numbers in **sorted order**:
  232. .. code-block:: pycon
  233. >>> BROKER_TRANSPORT_OPTIONS = {
  234. ... 'priority_steps': [0, 2, 4, 6, 8, 9],
  235. ... }
  236. Priorities implemented in this way isn't as reliable as
  237. priorities on the server side, which is why
  238. the feature is nicknamed "quasi-priorities";
  239. **Using routing is still the suggested way of ensuring
  240. quality of service**, as client implemented priorities
  241. fall short in a number of ways, for example if the worker
  242. is busy with long running tasks, has prefetched many messages,
  243. or the queues are congested.
  244. Still, it is possible that using priorities in combination
  245. with routing can be more beneficial than using routing
  246. or priorities alone. Experimentation and monitoring
  247. should be used to prove this.
  248. Contributed by Germán M. Bravo.
  249. Redis: Now cycles queues so that consuming is fair
  250. --------------------------------------------------
  251. This ensures that a very busy queue won't block messages
  252. from other queues, and ensures that all queues have
  253. an equal chance of being consumed from.
  254. This used to be the case before, but the behavior was
  255. accidentally changed while switching to using blocking pop.
  256. `group`/`chord`/`chain` are now subtasks
  257. ----------------------------------------
  258. - group is no longer an alias to ``TaskSet``, but new all together,
  259. since it was very difficult to migrate the ``TaskSet`` class to become
  260. a subtask.
  261. - A new shortcut has been added to tasks:
  262. .. code-block:: pycon
  263. >>> task.s(arg1, arg2, kw=1)
  264. as a shortcut to:
  265. .. code-block:: pycon
  266. >>> task.subtask((arg1, arg2), {'kw': 1})
  267. - Tasks can be chained by using the ``|`` operator:
  268. .. code-block:: pycon
  269. >>> (add.s(2, 2), pow.s(2)).apply_async()
  270. - Subtasks can be "evaluated" using the ``~`` operator:
  271. .. code-block:: pycon
  272. >>> ~add.s(2, 2)
  273. 4
  274. >>> ~(add.s(2, 2) | pow.s(2))
  275. is the same as:
  276. .. code-block:: pycon
  277. >>> chain(add.s(2, 2), pow.s(2)).apply_async().get()
  278. - A new subtask_type key has been added to the subtask dictionary.
  279. This can be the string ``"chord"``, ``"group"``, ``"chain"``,
  280. ``"chunks"``, ``"xmap"``, or ``"xstarmap"``.
  281. - maybe_subtask now uses subtask_type to reconstruct
  282. the object, to be used when using non-pickle serializers.
  283. - The logic for these operations have been moved to dedicated
  284. tasks celery.chord, celery.chain and celery.group.
  285. - subtask no longer inherits from AttributeDict.
  286. It's now a pure dict subclass with properties for attribute
  287. access to the relevant keys.
  288. - The repr's now outputs how the sequence would like imperatively:
  289. .. code-block:: pycon
  290. >>> from celery import chord
  291. >>> (chord([add.s(i, i) for i in xrange(10)], xsum.s())
  292. | pow.s(2))
  293. tasks.xsum([tasks.add(0, 0),
  294. tasks.add(1, 1),
  295. tasks.add(2, 2),
  296. tasks.add(3, 3),
  297. tasks.add(4, 4),
  298. tasks.add(5, 5),
  299. tasks.add(6, 6),
  300. tasks.add(7, 7),
  301. tasks.add(8, 8),
  302. tasks.add(9, 9)]) | tasks.pow(2)
  303. New remote control commands
  304. ---------------------------
  305. These commands were previously experimental, but they've proven
  306. stable and is now documented as part of the official API.
  307. - :control:`add_consumer`/:control:`cancel_consumer`
  308. Tells workers to consume from a new queue, or cancel consuming from a
  309. queue. This command has also been changed so that the worker remembers
  310. the queues added, so that the change will persist even if
  311. the connection is re-connected.
  312. These commands are available programmatically as
  313. :meth:`@control.add_consumer` / :meth:`@control.cancel_consumer`:
  314. .. code-block:: pycon
  315. >>> celery.control.add_consumer(queue_name,
  316. ... destination=['w1.example.com'])
  317. >>> celery.control.cancel_consumer(queue_name,
  318. ... destination=['w1.example.com'])
  319. or using the :program:`celery control` command:
  320. .. code-block:: console
  321. $ celery control -d w1.example.com add_consumer queue
  322. $ celery control -d w1.example.com cancel_consumer queue
  323. .. note::
  324. Remember that a control command without *destination* will be
  325. sent to **all workers**.
  326. - :control:`autoscale`
  327. Tells workers with ``--autoscale`` enabled to change autoscale
  328. max/min concurrency settings.
  329. This command is available programmatically as :meth:`@control.autoscale`:
  330. .. code-block:: pycon
  331. >>> celery.control.autoscale(max=10, min=5,
  332. ... destination=['w1.example.com'])
  333. or using the :program:`celery control` command:
  334. .. code-block:: console
  335. $ celery control -d w1.example.com autoscale 10 5
  336. - :control:`pool_grow`/:control:`pool_shrink`
  337. Tells workers to add or remove pool processes.
  338. These commands are available programmatically as
  339. :meth:`@control.pool_grow` / :meth:`@control.pool_shrink`:
  340. .. code-block:: pycon
  341. >>> celery.control.pool_grow(2, destination=['w1.example.com'])
  342. >>> celery.contorl.pool_shrink(2, destination=['w1.example.com'])
  343. or using the :program:`celery control` command:
  344. .. code-block:: console
  345. $ celery control -d w1.example.com pool_grow 2
  346. $ celery control -d w1.example.com pool_shrink 2
  347. - :program:`celery control` now supports :control:`rate_limit` and
  348. :control:`time_limit` commands.
  349. See ``celery control --help`` for details.
  350. Crontab now supports Day of Month, and Month of Year arguments
  351. --------------------------------------------------------------
  352. See the updated list of examples at :ref:`beat-crontab`.
  353. Immutable subtasks
  354. ------------------
  355. ``subtask``'s can now be immutable, which means that the arguments
  356. won't be modified when calling callbacks:
  357. .. code-block:: pycon
  358. >>> chain(add.s(2, 2), clear_static_electricity.si())
  359. means it'll not receive the argument of the parent task,
  360. and ``.si()`` is a shortcut to:
  361. .. code-block:: pycon
  362. >>> clear_static_electricity.subtask(immutable=True)
  363. Logging Improvements
  364. --------------------
  365. Logging support now conforms better with best practices.
  366. - Classes used by the worker no longer uses app.get_default_logger, but uses
  367. `celery.utils.log.get_logger` which simply gets the logger not setting the
  368. level, and adds a NullHandler.
  369. - Loggers are no longer passed around, instead every module using logging
  370. defines a module global logger that's used throughout.
  371. - All loggers inherit from a common logger called "celery".
  372. - Before ``task.get_logger`` would setup a new logger for every task,
  373. and even set the log level. This is no longer the case.
  374. - Instead all task loggers now inherit from a common "celery.task" logger
  375. that's set up when programs call `setup_logging_subsystem`.
  376. - Instead of using LoggerAdapter to augment the formatter with
  377. the task_id and task_name field, the task base logger now use
  378. a special formatter adding these values at run-time from the
  379. currently executing task.
  380. - In fact, ``task.get_logger`` is no longer recommended, it is better
  381. to add a module-level logger to your tasks module.
  382. For example, like this:
  383. .. code-block:: python
  384. from celery.utils.log import get_task_logger
  385. logger = get_task_logger(__name__)
  386. @celery.task
  387. def add(x, y):
  388. logger.debug('Adding %r + %r' % (x, y))
  389. return x + y
  390. The resulting logger will then inherit from the ``"celery.task"`` logger
  391. so that the current task name and id is included in logging output.
  392. - Redirected output from stdout/stderr is now logged to a "celery.redirected"
  393. logger.
  394. - In addition a few warnings.warn have been replaced with logger.warn.
  395. - Now avoids the 'no handlers for logger multiprocessing' warning
  396. Task registry no longer global
  397. ------------------------------
  398. Every Celery instance now has its own task registry.
  399. You can make apps share registries by specifying it:
  400. .. code-block:: pycon
  401. >>> app1 = Celery()
  402. >>> app2 = Celery(tasks=app1.tasks)
  403. Note that tasks are shared between registries by default, so that
  404. tasks will be added to every subsequently created task registry.
  405. As an alternative tasks can be private to specific task registries
  406. by setting the ``shared`` argument to the ``@task`` decorator:
  407. .. code-block:: python
  408. @celery.task(shared=False)
  409. def add(x, y):
  410. return x + y
  411. Abstract tasks are now lazily bound
  412. -----------------------------------
  413. The :class:`~celery.task.Task` class is no longer bound to an app
  414. by default, it will first be bound (and configured) when
  415. a concrete subclass is created.
  416. This means that you can safely import and make task base classes,
  417. without also initializing the app environment:
  418. .. code-block:: python
  419. from celery.task import Task
  420. class DebugTask(Task):
  421. abstract = True
  422. def __call__(self, *args, **kwargs):
  423. print('CALLING %r' % (self,))
  424. return self.run(*args, **kwargs)
  425. .. code-block:: pycon
  426. >>> DebugTask
  427. <unbound DebugTask>
  428. >>> @celery1.task(base=DebugTask)
  429. ... def add(x, y):
  430. ... return x + y
  431. >>> add.__class__
  432. <class add of <Celery default:0x101510d10>>
  433. Lazy task decorators
  434. --------------------
  435. The ``@task`` decorator is now lazy when used with custom apps.
  436. That is, if ``accept_magic_kwargs`` is enabled (her by called "compat mode"), the task
  437. decorator executes inline like before, however for custom apps the @task
  438. decorator now returns a special PromiseProxy object that's only evaluated
  439. on access.
  440. All promises will be evaluated when :meth:`@finalize` is called, or implicitly
  441. when the task registry is first used.
  442. Smart `--app` option
  443. --------------------
  444. The :option:`--app <celery --app>` option now 'auto-detects'
  445. - If the provided path is a module it tries to get an
  446. attribute named 'celery'.
  447. - If the provided path is a package it tries
  448. to import a sub module named celery',
  449. and get the celery attribute from that module.
  450. For example, if you have a project named ``proj`` where the
  451. celery app is located in ``from proj.celery import app``,
  452. then the following will be equivalent:
  453. .. code-block:: console
  454. $ celery worker --app=proj
  455. $ celery worker --app=proj.celery:
  456. $ celery worker --app=proj.celery:app
  457. In Other News
  458. -------------
  459. - New :setting:`CELERYD_WORKER_LOST_WAIT` to control the timeout in
  460. seconds before :exc:`billiard.WorkerLostError` is raised
  461. when a worker can't be signaled (Issue #595).
  462. Contributed by Brendon Crawford.
  463. - Redis event monitor queues are now automatically deleted (Issue #436).
  464. - App instance factory methods have been converted to be cached
  465. descriptors that creates a new subclass on access.
  466. For example, this means that ``app.Worker`` is an actual class
  467. and will work as expected when:
  468. .. code-block:: python
  469. class Worker(app.Worker):
  470. ...
  471. - New signal: :signal:`task_success`.
  472. - Multiprocessing logs are now only emitted if the :envvar:`MP_LOG`
  473. environment variable is set.
  474. - The Celery instance can now be created with a broker URL
  475. .. code-block:: python
  476. app = Celery(broker='redis://')
  477. - Result backends can now be set using a URL
  478. Currently only supported by redis. Example use:
  479. .. code-block:: python
  480. CELERY_RESULT_BACKEND = 'redis://localhost/1'
  481. - Heartbeat frequency now every 5s, and frequency sent with event
  482. The heartbeat frequency is now available in the worker event messages,
  483. so that clients can decide when to consider workers offline based on
  484. this value.
  485. - Module celery.actors has been removed, and will be part of cl instead.
  486. - Introduces new ``celery`` command, which is an entry-point for all other
  487. commands.
  488. The main for this command can be run by calling ``celery.start()``.
  489. - Annotations now supports decorators if the key starts with '@'.
  490. For example:
  491. .. code-block:: python
  492. def debug_args(fun):
  493. @wraps(fun)
  494. def _inner(*args, **kwargs):
  495. print('ARGS: %r' % (args,))
  496. return _inner
  497. CELERY_ANNOTATIONS = {
  498. 'tasks.add': {'@__call__': debug_args},
  499. }
  500. Also tasks are now always bound by class so that
  501. annotated methods end up being bound.
  502. - Bug-report now available as a command and broadcast command
  503. - Get it from a Python REPL:
  504. .. code-block:: pycon
  505. >>> import celery
  506. >>> print(celery.bugreport())
  507. - Using the ``celery`` command line program:
  508. .. code-block:: console
  509. $ celery report
  510. - Get it from remote workers:
  511. .. code-block:: console
  512. $ celery inspect report
  513. - Module ``celery.log`` moved to :mod:`celery.app.log`.
  514. - Module ``celery.task.control`` moved to :mod:`celery.app.control`.
  515. - New signal: :signal:`task_revoked`
  516. Sent in the main process when the task is revoked or terminated.
  517. - ``AsyncResult.task_id`` renamed to ``AsyncResult.id``
  518. - ``TasksetResult.taskset_id`` renamed to ``.id``
  519. - ``xmap(task, sequence)`` and ``xstarmap(task, sequence)``
  520. Returns a list of the results applying the task function to every item
  521. in the sequence.
  522. Example:
  523. .. code-block:: pycon
  524. >>> from celery import xstarmap
  525. >>> xstarmap(add, zip(range(10), range(10)).apply_async()
  526. [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
  527. - ``chunks(task, sequence, chunksize)``
  528. - ``group.skew(start=, stop=, step=)``
  529. Skew will skew the countdown for the individual tasks in a group -- for
  530. example with this group:
  531. .. code-block:: pycon
  532. >>> g = group(add.s(i, i) for i in xrange(10))
  533. Skewing the tasks from 0 seconds to 10 seconds:
  534. .. code-block:: pycon
  535. >>> g.skew(stop=10)
  536. Will have the first task execute in 0 seconds, the second in 1 second,
  537. the third in 2 seconds and so on.
  538. - 99% test Coverage
  539. - :setting:`CELERY_QUEUES` can now be a list/tuple of :class:`~kombu.Queue`
  540. instances.
  541. Internally :attr:`@amqp.queues` is now a mapping of name/Queue instances,
  542. instead of converting on the fly.
  543. - Can now specify connection for :class:`@control.inspect`.
  544. .. code-block:: python
  545. from kombu import Connection
  546. i = celery.control.inspect(connection=Connection('redis://'))
  547. i.active_queues()
  548. - :setting:`CELERY_FORCE_EXECV` is now enabled by default.
  549. If the old behavior is wanted the setting can be set to False,
  550. or the new `--no-execv` option to :program:`celery worker`.
  551. - Deprecated module ``celery.conf`` has been removed.
  552. - The :setting:`CELERY_TIMEZONE` now always require the :pypi:`pytz`
  553. library to be installed (except if the timezone is set to `UTC`).
  554. - The Tokyo Tyrant backend has been removed and is no longer supported.
  555. - Now uses :func:`~kombu.common.maybe_declare` to cache queue declarations.
  556. - There's no longer a global default for the
  557. :setting:`CELERYBEAT_MAX_LOOP_INTERVAL` setting, it is instead
  558. set by individual schedulers.
  559. - Worker: now truncates very long message bodies in error reports.
  560. - No longer deep-copies exceptions when trying to serialize errors.
  561. - :envvar:`CELERY_BENCH` environment variable, will now also list
  562. memory usage statistics at worker shutdown.
  563. - Worker: now only ever use a single timer for all timing needs,
  564. and instead set different priorities.
  565. - An exceptions arguments are now safely pickled
  566. Contributed by Matt Long.
  567. - Worker/Beat no longer logs the start-up banner.
  568. Previously it would be logged with severity warning,
  569. now it's only written to stdout.
  570. - The ``contrib/`` directory in the distribution has been renamed to
  571. ``extra/``.
  572. - New signal: :signal:`task_revoked`
  573. - :mod:`celery.contrib.migrate`: Many improvements, including;
  574. filtering, queue migration, and support for acking messages on the broker
  575. migrating from.
  576. Contributed by John Watson.
  577. - Worker: Prefetch count increments are now optimized and grouped together.
  578. - Worker: No longer calls ``consume`` on the remote control command queue
  579. twice.
  580. Probably didn't cause any problems, but was unnecessary.
  581. Internals
  582. ---------
  583. - ``app.broker_connection`` is now ``app.connection``
  584. Both names still work.
  585. - Compatibility modules are now generated dynamically upon use.
  586. These modules are ``celery.messaging``, ``celery.log``,
  587. ``celery.decorators`` and ``celery.registry``.
  588. - :mod:`celery.utils` refactored into multiple modules:
  589. :mod:`celery.utils.text`
  590. :mod:`celery.utils.imports`
  591. :mod:`celery.utils.functional`
  592. - Now using :mod:`kombu.utils.encoding` instead of
  593. :mod:`celery.utils.encoding`.
  594. - Renamed module ``celery.routes`` -> :mod:`celery.app.routes`.
  595. - Renamed package ``celery.db`` -> :mod:`celery.backends.database`.
  596. - Renamed module ``celery.abstract`` -> :mod:`celery.worker.bootsteps`.
  597. - Command line docs are now parsed from the module docstrings.
  598. - Test suite directory has been reorganized.
  599. - :program:`setup.py` now reads docs from the :file:`requirements/` directory.
  600. - Celery commands no longer wraps output (Issue #700).
  601. Contributed by Thomas Johansson.
  602. .. _v300-experimental:
  603. Experimental
  604. ============
  605. :mod:`celery.contrib.methods`: Task decorator for methods
  606. ----------------------------------------------------------
  607. This is an experimental module containing a task
  608. decorator, and a task decorator filter, that can be used
  609. to create tasks out of methods::
  610. from celery.contrib.methods import task_method
  611. class Counter(object):
  612. def __init__(self):
  613. self.value = 1
  614. @celery.task(name='Counter.increment', filter=task_method)
  615. def increment(self, n=1):
  616. self.value += 1
  617. return self.value
  618. See :mod:`celery.contrib.methods` for more information.
  619. .. _v300-unscheduled-removals:
  620. Unscheduled Removals
  621. ====================
  622. Usually we don't make backward incompatible removals,
  623. but these removals should have no major effect.
  624. - The following settings have been renamed:
  625. - ``CELERYD_ETA_SCHEDULER`` -> ``CELERYD_TIMER``
  626. - ``CELERYD_ETA_SCHEDULER_PRECISION`` -> ``CELERYD_TIMER_PRECISION``
  627. .. _v300-deprecations:
  628. Deprecation Time-line Changes
  629. =============================
  630. See the :ref:`deprecation-timeline`.
  631. - The ``celery.backends.pyredis`` compat module has been removed.
  632. Use :mod:`celery.backends.redis` instead!
  633. - The following undocumented API's has been moved:
  634. - ``control.inspect.add_consumer`` -> :meth:`@control.add_consumer`.
  635. - ``control.inspect.cancel_consumer`` -> :meth:`@control.cancel_consumer`.
  636. - ``control.inspect.enable_events`` -> :meth:`@control.enable_events`.
  637. - ``control.inspect.disable_events`` -> :meth:`@control.disable_events`.
  638. This way ``inspect()`` is only used for commands that don't
  639. modify anything, while idempotent control commands that make changes
  640. are on the control objects.
  641. Fixes
  642. =====
  643. - Retry SQLAlchemy backend operations on DatabaseError/OperationalError
  644. (Issue #634)
  645. - Tasks that called ``retry`` wasn't acknowledged if acks late was enabled
  646. Fix contributed by David Markey.
  647. - The message priority argument wasn't properly propagated to Kombu
  648. (Issue #708).
  649. Fix contributed by Eran Rundstein