whatsnew-2.5.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. .. _whatsnew-2.5:
  2. ==========================
  3. What's new in Celery 2.5
  4. ==========================
  5. :release-date: 2011-02-24 04:00 P.M GMT
  6. .. contents::
  7. :local:
  8. .. _v250-important:
  9. Important Notes
  10. ===============
  11. Broker connection pool now enabled by default
  12. ---------------------------------------------
  13. The default limit is 10 connections, if you have many threads/green-threads
  14. using connections at the same time you may want to tweak this limit
  15. to avoid contention.
  16. See the :setting:`BROKER_POOL_LIMIT` setting for more information.
  17. Also note that publishing tasks will be retried by default, to change
  18. this default or the default retry policy see
  19. :setting:`CELERY_TASK_PUBLISH_RETRY` and
  20. :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY`.
  21. AMQP Result Backend: Exchange is no longer *auto delete*
  22. --------------------------------------------------------
  23. The exchange used for results used to have the *auto_delete* flag set,
  24. that could result in a race condition leading to an annoying warning.
  25. .. admonition:: For RabbitMQ users
  26. Old exchanges created with the *auto_delete* flag enabled has
  27. to be removed.
  28. The :program:`camqadm` command can be used to delete the
  29. previous exchange::
  30. $ camqadm exchange.delete celeryresults
  31. As an alternative to deleting the old exchange you can
  32. configure a new name for the exchange::
  33. CELERY_RESULT_EXCHANGE = "celeryresults2"
  34. But you have to make sure that both clients and workers
  35. use this new setting, so they are updated to use the same
  36. exchange name.
  37. Solution for hanging workers (but must be manually enabled)
  38. -----------------------------------------------------------
  39. The :setting:`CELERYD_FORCE_EXECV` setting has been added to solve
  40. a problem with deadlocks that originate when threads and fork is mixed
  41. together:
  42. .. code-block:: python
  43. CELERYD_FORCE_EXECV = True
  44. This setting is recommended for all users using the processes pool,
  45. but especially users also using time limits and max tasks per child,
  46. or users experiencing workers that hang.
  47. - See `Python issue 6721` to read more about the details, and why
  48. resorting to execv is the only safe solution.
  49. Enabling this option will result in a slight performance penalty
  50. when new child worker processes are started, and it will also increase
  51. memory usage (but many platforms are optimized, so the impact may be
  52. minimal). However, this should be worth it considering that it ensures
  53. reliability when replacing lost worker processes.
  54. - It is already the default behavior on Windows.
  55. - It will be the default behavior for all platforms in a future version.
  56. .. _`Python Issue 6721`: http://bugs.python.org/issue6721#msg140215
  57. .. _v250-optimizations:
  58. Optimizations
  59. =============
  60. - The code path used when the worker executes a task has been heavily
  61. optimized, meaning the worker is able to process a great deal
  62. more tasks/s compared to previous versions. As an example the solo
  63. pool can now process up to 15000 tasks/s on a 4 core MacBook Pro
  64. when using the `pylibrabbitmq`_ transport, where it previously
  65. could only do 5000 tasks/s.
  66. - The task error tracebacks are now much shorter.
  67. - Fixed a noticeable delay in task processing when rate limits are enabled.
  68. .. _`pylibrabbitmq`: http://pypi.python.org/pylibrabbitmq/
  69. .. _v250-news:
  70. News
  71. ====
  72. Timezone support
  73. ----------------
  74. Celery can now be configured to treat all incoming and outgoing dates
  75. as UTC, and the local timezone can be configured.
  76. This is not yet enabled by default, since enabling
  77. time zone support means workers running versions pre 2.5
  78. will be out of sync with upgraded workers.
  79. To enable UTC you have to set :setting:`CELERY_ENABLE_UTC`::
  80. CELERY_ENABLE_UTC = True
  81. When UTC is enabled, dates and times in task messages will be
  82. converted to UTC, and then converted back to the local timezone
  83. when received by a worker.
  84. You can change the local timezone using the :setting:`CELERY_TIMEZONE`
  85. setting. Installing the :mod:`pytz` library is recommended when
  86. using a custom timezone, to keep timezone definition up-to-date,
  87. but it will fallback to a system definition of the timezone if available.
  88. UTC will enabled by default in version 3.0.
  89. .. note::
  90. django-celery will use the local timezone as specified by the
  91. ``TIME_ZONE`` setting, it will also honor the new `USE_TZ`_ setting
  92. introuced in Django 1.4.
  93. .. _`USE_TZ`: https://docs.djangoproject.com/en/dev/topics/i18n/timezones/
  94. New security serializer using cryptographic signing
  95. ---------------------------------------------------
  96. A new serializer has been added that signs and verifies the signature
  97. of messages.
  98. The name of the new serializer is ``auth``, and needs additional
  99. configuration to work (see :ref:`conf-security`).
  100. .. seealso::
  101. :ref:`guide-security`
  102. New :setting:`CELERY_ANNOTATIONS` setting
  103. -----------------------------------------
  104. This new setting enables the configuration to modify task classes
  105. and their attributes.
  106. The setting can be a dict, or a list of annotation objects that filter
  107. for tasks and return a map of attributes to change.
  108. As an example, this is an annotation to change the ``rate_limit`` attribute
  109. for the ``tasks.add`` task:
  110. .. code-block:: python
  111. CELERY_ANNOTATIONS = {"tasks.add": {"rate_limit": "10/s"}}
  112. or change the same for all tasks:
  113. .. code-block:: python
  114. CELERY_ANNOTATIONS = {"*": {"rate_limit": "10/s"}}
  115. You can change methods too, for example the ``on_failure`` handler:
  116. .. code-block:: python
  117. def my_on_failure(self, exc, task_id, args, kwargs, einfo):
  118. print("Oh no! Task failed: %r" % (exc, ))
  119. CELERY_ANNOTATIONS = {"*": {"on_failure": my_on_failure}}
  120. If you need more flexibility then you can also create objects
  121. that filter for tasks to annotate:
  122. .. code-block:: python
  123. class MyAnnotate(object):
  124. def annotate(self, task):
  125. if task.name.startswith("tasks."):
  126. return {"rate_limit": "10/s"}
  127. CELERY_ANNOTATIONS = (MyAnnotate(), {...})
  128. In Other News
  129. -------------
  130. - Now depends on Kombu 2.1.0.
  131. - Efficient Chord support for the memcached backend (Issue #533)
  132. This means memcached joins Redis in the ability to do non-polling
  133. chord support.
  134. Contributed by Dan McGee.
  135. - Adds Chord support for the AMQP backend
  136. The AMQP backend can now use the fallback chord solution.
  137. - New "detailed" mode for the Cassandra backend.
  138. Allows to have a "detailed" mode for the Cassandra backend.
  139. Basically the idea is to keep all states using Cassandra wide columns.
  140. New states are then appended to the row as new columns, the last state
  141. being the last column.
  142. See the :setting:`CASSANDRA_DETAILED_MODE` setting.
  143. Contributed by Steeve Morin.
  144. - More information is now preserved in the pickleable traceback.
  145. This has been added so that Sentry can show more details.
  146. Contributed by Sean O'Connor.
  147. - CentOS init script has been updated and should be more flexible.
  148. Contributed by Andrew McFague.
  149. - MongoDB result backend now supports ``forget()``.
  150. Contributed by Andrew McFague
  151. - ``task.retry()`` now re-raises the original exception keeping
  152. the original stack trace.
  153. Suggested by ojii.
  154. - The `--uid` argument to daemons now uses ``initgroups()`` to set
  155. groups to all the groups the user is a member of.
  156. Contributed by Łukasz Oleś.
  157. - celeryctl: Added ``shell`` command.
  158. The shell will have the current_app (``celery``) and all tasks
  159. automatically added to locals.
  160. - celeryctl: Added ``migrate`` command.
  161. The migrate command moves all tasks from one broker to another.
  162. Note that this is experimental and you should have a backup
  163. of the data before proceeding.
  164. **Examples**::
  165. $ celeryctl migrate redis://localhost amqp://localhost
  166. $ celeryctl migrate amqp://localhost//v1 amqp://localhost//v2
  167. $ python manage.py celeryctl migrate django:// redis://
  168. * Routers can now override the ``exchange`` and ``routing_key`` used
  169. to create missing queues (Issue #577).
  170. Previously this would always be named the same as the queue,
  171. but you can now have a router return exchange and routing_key keys
  172. to set the explicitly.
  173. This is useful when using routing classes which decides a destination
  174. at runtime.
  175. Contributed by Akira Matsuzaki.
  176. - Redis result backend: Adds support for a ``max_connections`` parameter.
  177. It is now possible to configure the maximum number of
  178. simultaneous connections in the Redis connection pool used for
  179. results.
  180. The default max connections setting can be configured using the
  181. :setting:`CELERY_REDIS_MAX_CONNECTIONS` setting,
  182. or it can be changed individually by ``RedisBackend(max_connections=int)``.
  183. Contributed by Steeve Morin.
  184. - Redis result backend: Adds the ability to wait for results without polling.
  185. Contributed by Steeve Morin.
  186. - MongoDB result backend: Now supports save and restore taskset.
  187. Contributed by Julien Poissonnier.
  188. - There's a new :ref:`guide-security` guide in the documentation.
  189. - The init scripts has been updated, and many bugs fixed.
  190. Contributed by Chris Streeter.
  191. - User (tilde) is now expanded in command line arguments.
  192. - Can now configure CELERYCTL envvar in :file:`/etc/default/celeryd`.
  193. While not necessary for operation, :program:`celeryctl` is used for the
  194. ``celeryd status`` command, and the path to :program:`celeryctl` must be
  195. configured for that to work.
  196. The daemonization cookbook contains examples.
  197. Contributed by Jude Nagurney.
  198. - The MongoDB result backend can now use Replica Sets.
  199. Contributed by Ivan Metzlar.
  200. - gevent: Now supports autoscaling (Issue #599).
  201. Contributed by Mark Lavin.
  202. - multiprocessing: Mediator thread is now always enabled,
  203. even though rate limits are disabled, as the pool semaphore
  204. is known to block the main thread, causing broadcast commands and
  205. shutdown to depend on the semaphore being released.
  206. Fixes
  207. =====
  208. - Exceptions that are re-raised with a new exception object now keeps
  209. the original stack trace.
  210. - Windows: Fixed the ``no handlers found for multiprocessing`` warning.
  211. - Windows: The ``celeryd`` program can now be used.
  212. Previously Windows users had to launch celeryd using
  213. ``python -m celery.bin.celeryd``.
  214. - Redis result backend: Now uses ``SETEX`` command to set result key,
  215. and expiry atomically.
  216. Suggested by yaniv-aknin.
  217. - celeryd: Fixed a problem where shutdown hanged when Ctrl+C was used to
  218. terminate.
  219. - celeryd: No longer crashes when channel errors occur.
  220. Fix contributed by Roger Hu.
  221. - Fixed memory leak in the eventlet pool, caused by the
  222. use of ``greenlet.getcurrent``.
  223. Fix contributed by Ignas Mikalajūnas.
  224. - Cassandra backend: No longer uses :func:`pycassa.connect` which is
  225. deprecated since :mod:`pycassa` 1.4.
  226. Fix contributed by Jeff Terrace.
  227. - Fixed unicode decode errors that could occur while sending error emails.
  228. Fix contributed by Seong Wun Mun.
  229. - ``celery.bin`` programs now always defines ``__package__`` as recommended
  230. by PEP-366.
  231. - ``send_task`` now emits a warning when used in combination with
  232. :setting:`CELERY_ALWAYS_EAGER` (Issue #581).
  233. Contributed by Mher Movsisyan.
  234. - ``apply_async`` now forwards the original keyword arguments to ``apply``
  235. when :setting:`CELERY_ALWAYS_EAGER` is enabled.
  236. - celeryev now tries to re-establish the connection if the connection
  237. to the broker is lost (Issue #574).
  238. - celeryev: Fixed a crash occurring if a task has no associated worker
  239. information.
  240. Fix contributed by Matt Williamson.
  241. - The current date and time is now consistently taken from the current loaders
  242. ``now`` method.
  243. - Now shows helpful error message when given a config module ending in
  244. ``.py`` that can't be imported.
  245. - celeryctl: The ``--expires`` and ``-eta`` arguments to the apply command
  246. can now be an ISO-8601 formatted string.
  247. - celeryctl now exits with exit status ``EX_UNAVAILABLE`` (69) if no replies
  248. have been received.