whatsnew-3.1.rst 37 KB

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