whatsnew-2.6.rst 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. .. _whatsnew-2.6:
  2. ==========================
  3. What's new in Celery 2.6
  4. ==========================
  5. Celery aims to be a flexible and reliable, best-of-breed solution
  6. to process vast amounts of messages in a distributed fashion, while
  7. providing operations with the tools to maintain such a system.
  8. Celery has a large and diverse community of users and contributors,
  9. you should come join us :ref:`on IRC <irc-channel>`
  10. or :ref:`our mailing-list <mailing-list>`.
  11. To read more about Celery you should visit our `website`_.
  12. While this version is backward compatible with previous versions
  13. it is important that you read the following section.
  14. If you use Celery in combination with Django you must also
  15. read the `django-celery changelog`_ and upgrade to `django-celery 2.6`_.
  16. This version is officially supported on CPython 2.5, 2.6, 2.7, 3.2 and 3.3,
  17. as well as PyPy and Jython.
  18. .. _`website`: http://celeryproject.org/
  19. .. _`django-celery changelog`: http://bit.ly/djcelery-26-changelog
  20. .. _`django-celery 2.6`: http://pypi.python.org/pypi/django-celery/
  21. .. contents::
  22. :local:
  23. .. _v260-important:
  24. Important Notes
  25. ===============
  26. Now depends on :mod:`billiard`.
  27. -------------------------------
  28. Billiard is a fork of the multiprocessing containing
  29. the no-execv patch by sbt (http://bugs.python.org/issue8713),
  30. and also contains the pool improvements previously located in Celery.
  31. This fork was necessary as changes to the C extension code was required
  32. for the no-execv patch to work.
  33. - Issue #625
  34. - Issue #627
  35. - Issue #640
  36. - `django-celery #122 <http://github.com/ask/django-celery/issues/122`
  37. - `django-celery #124 <http://github.com/ask/django-celery/issues/122`
  38. Unorganized
  39. -----------
  40. * Task registry is no longer a global.
  41. * celery.task.Task is no longer bound to an app by default,
  42. so configuration of the task is lazy.
  43. * The @task decorator is now lazy when used with custom apps
  44. If ``accept_magic_kwargs`` is enabled (herby called "compat mode"), the task
  45. decorator executes inline like before, however for custom apps the @task
  46. decorator now returns a special PromiseProxy object that is only evaluated
  47. on access.
  48. All promises will be evaluated when `app.finalize` is called, or implicitly
  49. when the task registry is first used.
  50. * chain: Chain tasks together using callbacks under the hood.
  51. .. code-block:: python
  52. from celery import chain
  53. # (2 + 2) * 8 / 2
  54. res = chain(add.subtask((4, 4)),
  55. mul.subtask((8, )),
  56. div.subtask((2,))).apply_async()
  57. res.get() == 16
  58. res.parent.get() == 32
  59. res.parent.parent.get() == 4
  60. * The Celery instance can now be created with a broker URL
  61. .. code-block:: python
  62. celery = Celery(broker="redis://")
  63. * Result backends can now be set using an URL
  64. Currently only supported by redis. Example use::
  65. CELERY_RESULT_BACKEND = "redis://localhost/1"
  66. * Heartbeat frequency now every 5s, and frequency sent with event
  67. The heartbeat frequency is now available in the worker event messages,
  68. so that clients can decide when to consider workers offline based on
  69. this value.
  70. * Module celery.actors has been removed, and will be part of cl instead.
  71. * Introduces new ``celery`` command, which is an entrypoint for all other
  72. commands.
  73. The main for this command can be run by calling ``celery.start()``.
  74. * Tasks can now have callbacks and errbacks, and dependencies are recorded
  75. - The task message format have been updated with two new extension keys
  76. Both keys can be empty/undefined or a list of subtasks.
  77. - ``callbacks``
  78. Applied if the task exits successfully, with the result
  79. of the task as an argument.
  80. - ``errbacks``
  81. Applied if an error occurred while executing the task,
  82. with the uuid of the task as an argument. Since it may not be possible
  83. to serialize the exception instance, it passes the uuid of the task
  84. instead. The uuid can then be used to retrieve the exception and
  85. traceback of the task from the result backend.
  86. - ``link`` and ``link_error`` keyword arguments has been added
  87. to ``apply_async``.
  88. The value passed can be either a subtask or a list of
  89. subtasks:
  90. .. code-block:: python
  91. add.apply_async((2, 2), link=mul.subtask())
  92. add.apply_async((2, 2), link=[mul.subtask(), echo.subtask()])
  93. Example error callback:
  94. .. code-block:: python
  95. @task
  96. def error_handler(uuid):
  97. result = AsyncResult(uuid)
  98. exc = result.get(propagate=False)
  99. print("Task %r raised exception: %r\n%r" % (
  100. exc, result.traceback))
  101. >>> add.apply_async((2, 2), link_error=error_handler)
  102. - We now track what subtasks a task sends, and some result backends
  103. supports retrieving this information.
  104. - task.request.children
  105. Contains the result instances of the subtasks
  106. the currently executing task has applied.
  107. - AsyncResult.children
  108. Returns the tasks dependencies, as a list of
  109. ``AsyncResult``/``ResultSet`` instances.
  110. - AsyncResult.iterdeps
  111. Recursively iterates over the tasks dependencies,
  112. yielding `(parent, node)` tuples.
  113. Raises IncompleteStream if any of the dependencies
  114. has not returned yet.
  115. - AsyncResult.graph
  116. A ``DependencyGraph`` of the tasks dependencies.
  117. This can also be used to convert to dot format:
  118. .. code-block:: python
  119. with open("graph.dot") as fh:
  120. result.graph.to_dot(fh)
  121. which can than be used to produce an image::
  122. $ dot -Tpng graph.dot -o graph.png
  123. * Bugreport now available as a command and broadcast command
  124. - Get it from a Python repl::
  125. >>> import celery
  126. >>> print(celery.bugreport())
  127. - Use celeryctl::
  128. $ celeryctl report
  129. - Get it from remote workers::
  130. $ celeryctl inspect report
  131. * Module ``celery.log`` moved to :mod:`celery.app.log`.
  132. * Module ``celery.task.control`` moved to :mod:`celery.app.control`.
  133. * Adds :meth:`AsyncResult.get_leaf`
  134. Waits and returns the result of the leaf subtask.
  135. That is the last node found when traversing the graph,
  136. but this means that the graph can be 1-dimensional only (in effect
  137. a list).
  138. * Adds ``subtask.link(subtask)`` + ``subtask.link_error(subtask)``
  139. Shortcut to ``s.options.setdefault("link", []).append(subtask)``
  140. * Adds ``subtask.flatten_links()``
  141. Returns a flattened list of all dependencies (recursively)
  142. * ``AsyncResult.task_id`` renamed to ``AsyncResult.id``
  143. * ``TasksetResult.taskset_id`` renamed to ``.id``
  144. Internals
  145. ---------
  146. * Compat modules are now generated dynamically upon use.
  147. These modules are ``celery.messaging``, ``celery.log``,
  148. ``celery.decorators`` and ``celery.registry``.
  149. * :mod:`celery.utils` refactored into multiple modules:
  150. :mod:`celery.utils.text`
  151. :mod:`celery.utils.imports`
  152. :mod:`celery.utils.functional`
  153. * Now using :mod:`kombu.utils.encoding` instead of
  154. `:mod:`celery.utils.encoding`.
  155. * Renamed module ``celery.routes`` -> :mod:`celery.app.routes`.
  156. * Renamed package ``celery.db`` -> :mod:`celery.backends.database`.
  157. * Renamed module ``celery.abstract`` -> :mod:`celery.worker.abstract`.
  158. .. _v260-deprecations:
  159. Deprecations
  160. ============
  161. .. _v260-news:
  162. News
  163. ====
  164. In Other News
  165. -------------
  166. - Now depends on Kombu 2.1.4
  167. Fixes
  168. =====