whatsnew-4.0.rst 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995
  1. .. _whatsnew-4.0:
  2. ===========================================
  3. What's new in Celery 4.0 (0Today8)
  4. ===========================================
  5. :Author: Ask Solem (``ask at celeryproject.org``)
  6. .. sidebar:: Change history
  7. What's new documents describe the changes in major versions,
  8. we also have a :ref:`changelog` that lists the changes in bugfix
  9. releases (0.0.x), while older series are archived under the :ref:`history`
  10. section.
  11. Celery is a simple, flexible, and reliable distributed system to
  12. process vast amounts of messages, while providing operations with
  13. the tools required to maintain such a system.
  14. It's a task queue with focus on real-time processing, while also
  15. supporting task scheduling.
  16. Celery has a large and diverse community of users and contributors,
  17. you should come join us :ref:`on IRC <irc-channel>`
  18. or :ref:`our mailing-list <mailing-list>`.
  19. To read more about Celery you should go read the :ref:`introduction <intro>`.
  20. While this version is backward compatible with previous versions
  21. it's important that you read the following section.
  22. This version is officially supported on CPython 2.7, 3.4, and 3.5.
  23. and also supported on PyPy.
  24. .. _`website`: http://celeryproject.org/
  25. .. topic:: Table of Contents
  26. Make sure you read the important notes before upgrading to this version.
  27. .. contents::
  28. :local:
  29. :depth: 3
  30. Preface
  31. =======
  32. XXX To be written
  33. Wall of Contributors
  34. --------------------
  35. XXX Needs update
  36. Aaron McMillin, Adam Renberg, Adrien Guinet, Ahmet Demir, Aitor Gómez-Goiri,
  37. Albert Wang, Alex Koshelev, Alex Rattray, Alex Williams, Alexander Koshelev,
  38. Alexander Lebedev, Alexander Oblovatniy, Alexey Kotlyarov, Ali Bozorgkhan,
  39. Alice Zoë Bevan–McGregor, Allard Hoeve, Alman One, Andrea Rabbaglietti,
  40. Andrea Rosa, Andrei Fokau, Andrew Rodionoff, Andriy Yurchuk,
  41. Aneil Mallavarapu, Areski Belaid, Artyom Koval, Ask Solem, Balthazar Rouberol,
  42. Berker Peksag, Bert Vanderbauwhede, Brian Bouterse, Chris Duryee, Chris Erway,
  43. Chris Harris, Chris Martin, Corey Farwell, Craig Jellick, Cullen Rhodes,
  44. Dallas Marlow, Daniel Wallace, Danilo Bargen, Davanum Srinivas, Dave Smith,
  45. David Baumgold, David Harrigan, David Pravec, Dennis Brakhane, Derek Anderson,
  46. Dmitry Malinovsky, Dudás Ádám, Dustin J. Mitchell, Ed Morley, Fatih Sucu,
  47. Feanil Patel, Felix Schwarz, Fernando Rocha, Flavio Grossi, Frantisek Holop,
  48. Gao Jiangmiao, Gerald Manipon, Gilles Dartiguelongue, Gino Ledesma,
  49. Hank John, Hogni Gylfason, Ilya Georgievsky, Ionel Cristian Mărieș,
  50. James Pulec, Jared Lewis, Jason Veatch, Jasper Bryant-Greene, Jeremy Tillman,
  51. Jocelyn Delalande, Joe Jevnik, John Anderson, John Kirkham, John Whitlock,
  52. Joshua Harlow, Juan Rossi, Justin Patrin, Kai Groner, Kevin Harvey,
  53. Konstantinos Koukopoulos, Kouhei Maeda, Kracekumar Ramaraju,
  54. Krzysztof Bujniewicz, Latitia M. Haskins, Len Buckens, Lorenzo Mancini,
  55. Lucas Wiman, Luke Pomfrey, Marcio Ribeiro, Marin Atanasov Nikolov,
  56. Mark Parncutt, Maxime Vdb, Mher Movsisyan, Michael (:github_user:`michael-k`),
  57. Michael Duane Mooring, Michael Permana, Mickaël Penhard, Mike Attwood,
  58. Morton Fox, Môshe van der Sterre, Nat Williams, Nathan Van Gheem, Nik Nyby,
  59. Omer Katz, Omer Korner, Ori Hoch, Paul Pearce, Paulo Bu, Philip Garnero,
  60. Piotr Maślanka, Radek Czajka, Raghuram Srinivasan, Randy Barlow,
  61. Rodolfo Carvalho, Roger Hu, Rongze Zhu, Ross Deane, Ryan Luckie,
  62. Rémy Greinhofer, Samuel Jaillet, Sergey Azovskov, Sergey Tikhonov,
  63. Seungha Kim, Steve Peak, Sukrit Khera, Tadej Janež, Tewfik Sadaoui,
  64. Thomas French, Thomas Grainger, Tobias Schottdorf, Tocho Tochev,
  65. Valentyn Klindukh, Vic Kumar, Vladimir Bolshakov, Vladimir Gorbunov,
  66. Wayne Chang, Wil Langford, Will Thompson, William King, Yury Selivanov,
  67. Zoran Pavlovic, 許邱翔, :github_user:`allenling`, :github_user:`bee-keeper`,
  68. :github_user:`ffeast`, :github_user:`flyingfoxlee`, :github_user:`gdw2`,
  69. :github_user:`gitaarik`, :github_user:`hankjin`, :github_user:`m-vdb`,
  70. :github_user:`mdk`, :github_user:`nokrik`, :github_user:`ocean1`,
  71. :github_user:`orlo666`, :github_user:`raducc`, :github_user:`wanglei`,
  72. :github_user:`worldexception`.
  73. .. _v400-upgrading:
  74. Upgrading from Celery 3.1
  75. =========================
  76. Step 1: Upgrade to Celery 3.1.25
  77. --------------------------------
  78. If you haven't already, the first step is to upgrade to Celery 3.1.25.
  79. This version adds foreward compatibility to the new message protocol,
  80. so that you can incrementally upgrade from 3.1 to 4.0.
  81. Deploy the workers first by upgrading to 3.1.25, this means these
  82. workers can process messages sent by clients using both 3.1 and 4.0.
  83. After the workers are upgraded you can upgrade the clients (e.g. web servers).
  84. Step 2: Update your configuration with the new setting names
  85. ------------------------------------------------------------
  86. This version radically changes the configuration setting names,
  87. to be more consistent.
  88. The changes are fully backwards compatible, so you have the option to wait
  89. until the old setting names are deprecated, but to ease the transition
  90. we have included a command-line utility that rewrites your settings
  91. automatically.
  92. See :ref:`v400-upgrade-settings` for more information.
  93. Step 3: Read the important notes in this document
  94. -------------------------------------------------
  95. Make sure you are not affected by any of the important upgrade notes
  96. mentioned in the following section.
  97. Step 4: Upgrade to Celery 4.0
  98. -----------------------------
  99. At this point you can upgrade your workers and clients with the new version.
  100. .. _v400-important:
  101. Important Notes
  102. ===============
  103. Dropped support for Python 2.6
  104. ------------------------------
  105. Celery now requires Python 2.7 or later,
  106. and also drops support for Python 3.3 so supported versions are:
  107. - CPython 2.7
  108. - CPython 3.4
  109. - CPython 3.5
  110. - PyPy 5.4 (``pypy2``)
  111. - PyPy 5.5-alpha (``pypy3``)
  112. Last major version to support Python 2
  113. --------------------------------------
  114. Starting from Celery 5.0 only Python 3.5+ will be supported.
  115. To make sure you're not affected by this change you should pin
  116. the Celery version in your requirements file, either to a specific
  117. version: ``celery==4.0.0``, or a range: ``celery>=4.0,<5.0``.
  118. Dropping support for Python 2 will enable us to remove massive
  119. amounts of compatibility code, and going with Python 3.5 allows
  120. us to take advantage of typing, async/await, asyncio, and similar
  121. concepts there's no alternative for in older versions.
  122. Celery 4.x will continue to work on Python 2.7, 3.4, 3.5; just as Celery 3.x
  123. still works on Python 2.6.
  124. Django support
  125. --------------
  126. Celery 4.x requires Django 1.8 or later, but we really recommend
  127. using at least Django 1.9 for the new ``transaction.on_commit`` feature.
  128. A common problem when calling tasks from Django is when the task is related
  129. to a model change, and you wish to cancel the task if the transaction is
  130. rolled back, or ensure the task is only executed after the changes have been
  131. written to the database.
  132. ``transaction.on_commit`` enables you to solve this problem by adding
  133. the task as a callback to be called only when the transaction is committed.
  134. Example usage:
  135. .. code-block:: python
  136. from functools import partial
  137. from django.db import transaction
  138. from .models import Article, Log
  139. from .tasks import send_article_created_notification
  140. def create_article(request):
  141. with transaction.atomic():
  142. article = Article.objects.create(**request.POST)
  143. # send this task only if the rest of the transaction succeeds.
  144. transaction.on_commit(partial(
  145. send_article_created_notification.delay, article_id=article.pk)
  146. Log.objects.create(type=Log.ARTICLE_CREATED, object_pk=article.pk)
  147. Removed features
  148. ----------------
  149. - Microsoft Windows is no longer supported.
  150. The test suite is passing, and Celery seems to be working with Windows,
  151. but we make no guarantees as we are unable to diagnose issues on this
  152. platform.
  153. - Jython is no longer supported.
  154. Features removed for simplicity
  155. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  156. - Webhook task machinery (``celery.task.http``) has been removed.
  157. Nowadays it's easy to use the :pypi:`requests` module to write
  158. webhook tasks manually. We would love to use requests but we
  159. are simply unable to as there's a very vocal 'anti-dependency'
  160. mob in the Python community
  161. If you need backwards compatibility
  162. you can simply copy + paste the 3.1 version of the module and make sure
  163. it's imported by the worker:
  164. https://github.com/celery/celery/blob/3.1/celery/task/http.py
  165. - Task no longer sends error emails.
  166. This also removes support for ``app.mail_admins``, and any functionality
  167. related to sending emails.
  168. - ``celery.contrib.batches`` has been removed.
  169. This was an experimental feature, so not covered by our deprecation
  170. timeline guarantee.
  171. You can copy and pase the existing batches code for use within your projects:
  172. https://github.com/celery/celery/blob/3.1/celery/contrib/batches.py
  173. Features removed for lack of funding
  174. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  175. We announced with the 3.1 release that some transports were
  176. moved to experimental status, and that there'd be no official
  177. support for the transports, citing a lack of resources.
  178. As this subtle hint for the need of funding failed
  179. we've removed them completely, breaking backwards compatibility.
  180. - Using the Django ORM as a broker is no longer supported.
  181. You can still use the Django ORM as a result backend:
  182. see :ref:`django-celery-results` section for more information.
  183. - Using SQLAlchemy as a broker is no longer supported.
  184. You can still use SQLAlchemy as a result backend.
  185. - Using CouchDB as a broker is no longer supported.
  186. You can still use CouchDB as a result backend.
  187. - Using IronMQ as a broker is no longer supported.
  188. - Using Beanstalk as a broker is no longer supported.
  189. In addition some features have been removed completely so that
  190. attempting to use them will raise an exception:
  191. - The ``--autoreload`` feature has been removed.
  192. This was an experimental feature, and not covered by our deprecation
  193. timeline guarantee. The flag is removed completely so the worker
  194. will crash at startup when present. Luckily this
  195. flag isn't used in production systems.
  196. - The experimental ``threads`` pool is no longer supported and has been removed.
  197. - The force_execv feature is no longer supported.
  198. The ``celery worker`` command now ignores the ``--no-execv``,
  199. ``--force-execv``, and the ``CELERYD_FORCE_EXECV`` setting.
  200. This flag will be removed completely in 5.0 and the worker
  201. will raise an error.
  202. - The old legacy "amqp" result backend has been deprecated, and will
  203. be removed in Celery 5.0.
  204. Please use the ``rpc`` result backend for RPC-style calls, and a
  205. persistent result backend for multi-consumer results.
  206. **Now to the good news**...
  207. New Task Message Protocol
  208. -------------------------
  209. .. :sha:`e71652d384b1b5df2a4e6145df9f0efb456bc71c`
  210. This version introduces a brand new task message protocol,
  211. the first major change to the protocol since the beginning of the project.
  212. The new protocol is enabled by default in this version and since the new
  213. version isn't backwards compatible you have to be careful when upgrading.
  214. The 3.1.25 version was released to add compatibility with the new protocol
  215. so the easiest way to upgrade is to upgrade to that version first, then
  216. upgrade to 4.0 in a second deployment.
  217. If you wish to keep using the old protocol you may also configure
  218. the protocol version number used:
  219. .. code-block:: python
  220. app = Celery()
  221. app.conf.task_protocol = 1
  222. Read more about the features available in the new protocol in the news
  223. section found later in this document.
  224. .. _v400-upgrade-settings:
  225. Lowercase setting names
  226. -----------------------
  227. In the pursuit of beauty all settings are now renamed to be in all
  228. lowercase and some setting names have been renamed for consistency.
  229. This change is fully backwards compatible so you can still use the uppercase
  230. setting names, but we would like you to upgrade as soon as possible and
  231. you can this automatically using the :program:`celery upgrade settings`
  232. command:
  233. .. code-block:: console
  234. $ celery upgrade settings proj/settings.py
  235. This command will modify your module in-place to use the new lower-case
  236. names (if you want uppercase with a "``CELERY``" prefix see block below),
  237. and save a backup in :file:`proj/settings.py.orig`.
  238. .. admonition:: For Django users and others who want to keep uppercase names
  239. If you're loading Celery configuration from the Django settings module
  240. then you'll want to keep using the uppercase names.
  241. You also want to use a ``CELERY_`` prefix so that no Celery settings
  242. collide with Django settings used by other apps.
  243. To do this, you'll first need to convert your settings file
  244. to use the new consistent naming scheme, and add the prefix to all
  245. Celery related settings:
  246. .. code-block:: console
  247. $ celery upgrade settings --django proj/settings.py
  248. After upgrading the settings file, you need to set the prefix explicitly
  249. in your ``proj/celery.py`` module:
  250. .. code-block:: python
  251. app.config_from_object('django.conf:settings', namespace='CELERY')
  252. You can find the most up to date Django Celery integration example
  253. here: :ref:`django-first-steps`.
  254. .. note::
  255. This will also add a prefix to settings that didn't previously
  256. have one, for example ``BROKER_URL`` should be written
  257. ``CELERY_BROKER_URL`` with a namespace of ``CELERY``
  258. ``CELERY_BROKER_URL``.
  259. Luckily you don't have to manually change the files, as
  260. the :program:`celery upgrade settings --django` program should do the
  261. right thing.
  262. The loader will try to detect if your configuration is using the new format,
  263. and act accordingly, but this also means you're not allowed to mix and
  264. match new and old setting names, that's unless you provide a value for both
  265. alternatives.
  266. The major difference between previous versions, apart from the lower case
  267. names, are the renaming of some prefixes, like ``celerybeat_`` to ``beat_``,
  268. ``celeryd_`` to ``worker_``.
  269. The ``celery_`` prefix has also been removed, and task related settings
  270. from this name-space is now prefixed by ``task_``, worker related settings
  271. with ``worker_``.
  272. Apart from this most of the settings will be the same in lowercase, apart from
  273. a few special ones:
  274. ===================================== ==========================================================
  275. **Setting name** **Replace with**
  276. ===================================== ==========================================================
  277. ``CELERY_MAX_CACHED_RESULTS`` :setting:`result_cache_max`
  278. ``CELERY_MESSAGE_COMPRESSION`` :setting:`result_compression`/:setting:`task_compression`.
  279. ``CELERY_TASK_RESULT_EXPIRES`` :setting:`result_expires`
  280. ``CELERY_RESULT_DBURI`` :setting:`result_backend`
  281. ``CELERY_RESULT_ENGINE_OPTIONS`` :setting:`database_engine_options`
  282. ``-*-_DB_SHORT_LIVED_SESSIONS`` :setting:`database_short_lived_sessions`
  283. ``CELERY_RESULT_DB_TABLE_NAMES`` :setting:`database_db_names`
  284. ``CELERY_ACKS_LATE`` :setting:`task_acks_late`
  285. ``CELERY_ALWAYS_EAGER`` :setting:`task_always_eager`
  286. ``CELERY_ANNOTATIONS`` :setting:`task_annotations`
  287. ``CELERY_MESSAGE_COMPRESSION`` :setting:`task_compression`
  288. ``CELERY_CREATE_MISSING_QUEUES`` :setting:`task_create_missing_queues`
  289. ``CELERY_DEFAULT_DELIVERY_MODE`` :setting:`task_default_delivery_mode`
  290. ``CELERY_DEFAULT_EXCHANGE`` :setting:`task_default_exchange`
  291. ``CELERY_DEFAULT_EXCHANGE_TYPE`` :setting:`task_default_exchange_type`
  292. ``CELERY_DEFAULT_QUEUE`` :setting:`task_default_queue`
  293. ``CELERY_DEFAULT_RATE_LIMIT`` :setting:`task_default_rate_limit`
  294. ``CELERY_DEFAULT_ROUTING_KEY`` :setting:`task_default_routing_key`
  295. ``-"-_EAGER_PROPAGATES_EXCEPTIONS`` :setting:`task_eager_propagates`
  296. ``CELERY_IGNORE_RESULT`` :setting:`task_ignore_result`
  297. ``CELERY_TASK_PUBLISH_RETRY`` :setting:`task_publish_retry`
  298. ``CELERY_TASK_PUBLISH_RETRY_POLICY`` :setting:`task_publish_retry_policy`
  299. ``CELERY_QUEUES`` :setting:`task_queues`
  300. ``CELERY_ROUTES`` :setting:`task_routes`
  301. ``CELERY_SEND_TASK_SENT_EVENT`` :setting:`task_send_sent_event`
  302. ``CELERY_TASK_SERIALIZER`` :setting:`task_serializer`
  303. ``CELERYD_TASK_SOFT_TIME_LIMIT`` :setting:`task_soft_time_limit`
  304. ``CELERYD_TASK_TIME_LIMIT`` :setting:`task_time_limit`
  305. ``CELERY_TRACK_STARTED`` :setting:`task_track_started`
  306. ``CELERY_DISABLE_RATE_LIMITS`` :setting:`worker_disable_rate_limits`
  307. ``CELERY_ENABLE_REMOTE_CONTROL`` :setting:`worker_enable_remote_control`
  308. ``CELERYD_SEND_EVENTS`` :setting:`worker_send_task_events`
  309. ===================================== ==========================================================
  310. You can see a full table of the changes in :ref:`conf-old-settings-map`.
  311. Json is now the default serializer
  312. ----------------------------------
  313. The time has finally come to end the reign of :mod:`pickle` as the default
  314. serialization mechanism, and json is the default serializer starting from this
  315. version.
  316. This change was :ref:`announced with the release of Celery 3.1
  317. <last-version-to-enable-pickle>`.
  318. If you're still depending on :mod:`pickle` being the default serializer,
  319. then you have to configure your app before upgrading to 4.0:
  320. .. code-block:: python
  321. task_serializer = 'pickle'
  322. result_serializer = 'pickle'
  323. accept_content = {'pickle'}
  324. The Json serializer now also supports some additional types:
  325. - :class:`~datetime.datetime`, :class:`~datetime.time`, :class:`~datetime.date`
  326. Converted to json text, in ISO-8601 format.
  327. - :class:`~decimal.Decimal`
  328. Converted to json text.
  329. - :class:`django.utils.functional.Promise`
  330. Django only: Lazy strings used for translation etc., are evaluated
  331. and conversion to a json type is attempted.
  332. - :class:`uuid.UUID`
  333. Converted to json text.
  334. You can also define a ``__json__`` method on your custom classes to support
  335. JSON serialization (must return a json compatible type):
  336. .. code-block:: python
  337. class Person:
  338. first_name = None
  339. last_name = None
  340. address = None
  341. def __json__(self):
  342. return {
  343. 'first_name': self.first_name,
  344. 'last_name': self.last_name,
  345. 'address': self.address,
  346. }
  347. The Task base class no longer automatically register tasks
  348. ----------------------------------------------------------
  349. The :class:`~@Task` class is no longer using a special meta-class
  350. that automatically registers the task in the task registry.
  351. Instead this is now handled by the :class:`@task` decorators.
  352. If you're still using class based tasks, then you need to register
  353. these manually:
  354. .. code-block:: python
  355. class CustomTask(Task):
  356. def run(self):
  357. print('running')
  358. app.tasks.register(CustomTask())
  359. The best practice is to use custom task classes only for overriding
  360. general behavior, and then using the task decorator to realize the task:
  361. .. code-block:: python
  362. @app.task(bind=True, base=CustomTask)
  363. def custom(self):
  364. print('running')
  365. This change also means that the ``abstract`` attribute of the task
  366. no longer has any effect.
  367. Task argument checking
  368. ----------------------
  369. The arguments of the task are now verified when calling the task,
  370. even asynchronously:
  371. .. code-block:: pycon
  372. >>> @app.task
  373. ... def add(x, y):
  374. ... return x + y
  375. >>> add.delay(8, 8)
  376. <AsyncResult: f59d71ca-1549-43e0-be41-4e8821a83c0c>
  377. >>> add.delay(8)
  378. Traceback (most recent call last):
  379. File "<stdin>", line 1, in <module>
  380. File "celery/app/task.py", line 376, in delay
  381. return self.apply_async(args, kwargs)
  382. File "celery/app/task.py", line 485, in apply_async
  383. check_arguments(*(args or ()), **(kwargs or {}))
  384. TypeError: add() takes exactly 2 arguments (1 given)
  385. You can disable the argument checking for any task by setting its
  386. :attr:`~@Task.typing` attribute to :const:`False`:
  387. .. code-block:: pycon
  388. >>> @app.task(typing=False)
  389. ... def add(x, y):
  390. ... return x + y
  391. Redis Events not backward compatible
  392. ------------------------------------
  393. The Redis ``fanout_patterns`` and ``fanout_prefix`` transport
  394. options are now enabled by default.
  395. Workers/monitors without these flags enabled won't be able to
  396. see workers with this flag disabled. They can still execute tasks,
  397. but they cannot receive each others monitoring messages.
  398. You can upgrade in a backward compatible manner by first configuring
  399. your 3.1 workers and monitors to enable the settings, before the final
  400. upgrade to 4.0:
  401. .. code-block:: python
  402. BROKER_TRANSPORT_OPTIONS = {
  403. 'fanout_patterns': True,
  404. 'fanout_prefix': True,
  405. }
  406. Django: Auto-discover now supports Django app configurations
  407. ------------------------------------------------------------
  408. The ``autodiscover_tasks()`` function can now be called without arguments,
  409. and the Django handler will automatically find your installed apps:
  410. .. code-block:: python
  411. app.autodiscover_tasks()
  412. The Django integration :ref:`example in the documentation
  413. <django-first-steps>` has been updated to use the argument-less call.
  414. This also ensures compatibility with the new, ehm, ``AppConfig`` stuff
  415. introduced in recent Django versions.
  416. Worker direct queues no longer use auto-delete
  417. ----------------------------------------------
  418. Workers/clients running 4.0 will no longer be able to send
  419. worker direct messages to workers running older versions, and vice versa.
  420. If you're relying on worker direct messages you should upgrade
  421. your 3.x workers and clients to use the new routing settings first,
  422. by replacing :func:`celery.utils.worker_direct` with this implementation:
  423. .. code-block:: python
  424. from kombu import Exchange, Queue
  425. worker_direct_exchange = Exchange('C.dq2')
  426. def worker_direct(hostname):
  427. return Queue(
  428. '{hostname}.dq2'.format(hostname),
  429. exchange=worker_direct_exchange,
  430. routing_key=hostname,
  431. )
  432. This feature closed Issue #2492.
  433. Old command-line programs removed
  434. ---------------------------------
  435. Installing Celery will no longer install the ``celeryd``,
  436. ``celerybeat`` and ``celeryd-multi`` programs.
  437. This was announced with the release of Celery 3.1, but you may still
  438. have scripts pointing to the old names, so make sure you update these
  439. to use the new umbrella command:
  440. +-------------------+--------------+-------------------------------------+
  441. | Program | New Status | Replacement |
  442. +===================+==============+=====================================+
  443. | ``celeryd`` | **REMOVED** | :program:`celery worker` |
  444. +-------------------+--------------+-------------------------------------+
  445. | ``celerybeat`` | **REMOVED** | :program:`celery beat` |
  446. +-------------------+--------------+-------------------------------------+
  447. | ``celeryd-multi`` | **REMOVED** | :program:`celery multi` |
  448. +-------------------+--------------+-------------------------------------+
  449. .. _v400-news:
  450. News
  451. ====
  452. New protocol highlights
  453. -----------------------
  454. The new protocol fixes many problems with the old one, and enables
  455. some long-requested features:
  456. - Most of the data are now sent as message headers, instead of being
  457. serialized with the message body.
  458. In version 1 of the protocol the worker always had to deserialize
  459. the message to be able to read task meta-data like the task id,
  460. name, etc. This also meant that the worker was forced to double-decode
  461. the data, first deserializing the message on receipt, serializing
  462. the message again to send to child process, then finally the child process
  463. deserializes the message again.
  464. Keeping the meta-data fields in the message headers means the worker
  465. doesn't actually have to decode the payload before delivering
  466. the task to the child process, and also that it's now possible
  467. for the worker to reroute a task written in a language different
  468. from Python to a different worker.
  469. - A new ``lang`` message header can be used to specify the programming
  470. language the task is written in.
  471. - Worker stores results for internal errors like ``ContentDisallowed``,
  472. and other deserialization errors.
  473. - Worker stores results and sends monitoring events for unregistered
  474. task errors.
  475. - Worker calls callbacks/errbacks even when the result is sent by the
  476. parent process (e.g., :exc:`WorkerLostError` when a child process
  477. terminates, deserialization errors, unregistered tasks).
  478. - A new ``origin`` header contains information about the process sending
  479. the task (worker node-name, or PID and host-name information).
  480. - A new ``shadow`` header allows you to modify the task name used in logs.
  481. This is useful for dispatch like patterns, like a task that calls
  482. any function using pickle (don't do this at home):
  483. .. code-block:: python
  484. from celery import Task
  485. from celery.utils.imports import qualname
  486. class call_as_task(Task):
  487. def shadow_name(self, args, kwargs, options):
  488. return 'call_as_task:{0}'.format(qualname(args[0]))
  489. def run(self, fun, *args, **kwargs):
  490. return fun(*args, **kwargs)
  491. call_as_task = app.tasks.register(call_as_task())
  492. - New ``argsrepr`` and ``kwargsrepr`` fields contain textual representations
  493. of the task arguments (possibly truncated) for use in logs, monitors, etc.
  494. This means the worker doesn't have to deserialize the message payload
  495. to display the task arguments for informational purposes.
  496. - Chains now use a dedicated ``chain`` field enabling support for chains
  497. of thousands and more tasks.
  498. - New ``parent_id`` and ``root_id`` headers adds information about
  499. a tasks relationship with other tasks.
  500. - ``parent_id`` is the task id of the task that called this task
  501. - ``root_id`` is the first task in the work-flow.
  502. These fields can be used to improve monitors like flower to group
  503. related messages together (like chains, groups, chords, complete
  504. work-flows, etc).
  505. - ``app.TaskProducer`` replaced by :meth:`@amqp.create_task_message` and
  506. :meth:`@amqp.send_task_message`.
  507. Dividing the responsibilities into creating and sending means that
  508. people who want to send messages using a Python AMQP client directly,
  509. doesn't have to implement the protocol.
  510. The :meth:`@amqp.create_task_message` method calls either
  511. :meth:`@amqp.as_task_v2`, or :meth:`@amqp.as_task_v1` depending
  512. on the configured task protocol, and returns a special
  513. :class:`~celery.app.amqp.task_message` tuple containing the
  514. headers, properties and body of the task message.
  515. .. seealso::
  516. The new task protocol is documented in full here:
  517. :ref:`message-protocol-task-v2`.
  518. Prefork Pool Improvements
  519. -------------------------
  520. Tasks now log from the child process
  521. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  522. Logging of task success/failure now happens from the child process
  523. executing the task. As a result logging utilities,
  524. like Sentry can get full information about tasks, including
  525. variables in the traceback stack.
  526. ``-Ofair`` is now the default scheduling strategy
  527. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  528. To re-enable the default behavior in 3.1 use the ``-Ofast`` command-line
  529. option.
  530. There's been lots of confusion about what the ``-Ofair`` command-line option
  531. does, and using the term "prefetch" in explanations have probably not helped
  532. given how confusing this terminology is in AMQP.
  533. When a Celery worker using the prefork pool receives a task, it needs to
  534. delegate that task to a child process for execution.
  535. The prefork pool has a configurable number of child processes
  536. (``--concurrency``) that can be used to execute tasks, and each child process
  537. uses pipes/sockets to communicate with the parent process:
  538. - inqueue (pipe/socket): parent sends task to the child process
  539. - outqueue (pipe/socket): child sends result/return value to the parent.
  540. In Celery 3.1 the default scheduling mechanism was simply to send
  541. the task to the first ``inqueue`` that was writable, with some heuristics
  542. to make sure we round-robin between them to ensure each child process
  543. would receive the same amount of tasks.
  544. This means that in the default scheduling strategy, a worker may send
  545. tasks to the same child process that is already executing a task. If that
  546. task is long running, it may block the waiting task for a long time. Even
  547. worse, hundreds of short-running tasks may be stuck behind a long running task
  548. even when there are child processes free to do work.
  549. The ``-Ofair`` scheduling strategy was added to avoid this situation,
  550. and when enabled it adds the rule that no task should be sent to the a child
  551. process that is already executing a task.
  552. The fair scheduling strategy may perform slightly worse if you have only
  553. short running tasks.
  554. Limit child process resident memory size
  555. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  556. .. :sha:`5cae0e754128750a893524dcba4ae030c414de33`
  557. You can now limit the maximum amount of memory allocated per prefork
  558. pool child process by setting the worker
  559. :option:`--max-memory-per-child <celery worker --max-memory-per-child>` option,
  560. or the :setting:`worker_max_memory_per_child` setting.
  561. The limit is for RSS/resident memory size and is specified in kilobytes.
  562. A child process having exceeded the limit will be terminated and replaced
  563. with a new process after the currently executing task returns.
  564. See :ref:`worker-max-memory-per-child` for more information.
  565. Contributed by **Dave Smith**.
  566. One log-file per child process
  567. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  568. Init-scrips and :program:`celery multi` now uses the `%I` log file format
  569. option (e.g., :file:`/var/log/celery/%n%I.log`).
  570. This change was necessary to ensure each child
  571. process has a separate log file after moving task logging
  572. to the child process, as multiple processes writing to the same
  573. log file can cause corruption.
  574. You're encouraged to upgrade your init-scripts and
  575. :program:`celery multi` arguments to use this new option.
  576. Transports
  577. ----------
  578. RabbitMQ priority queue support
  579. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  580. See :ref:`routing-options-rabbitmq-priorities` for more information.
  581. Contributed by **Gerald Manipon**.
  582. Configure broker URL for read/write separately
  583. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  584. New :setting:`broker_read_url` and :setting:`broker_write_url` settings
  585. have been added so that separate broker URLs can be provided
  586. for connections used for consuming/publishing.
  587. In addition to the configuration options, two new methods have been
  588. added the app API:
  589. - ``app.connection_for_read()``
  590. - ``app.connection_for_write()``
  591. These should now be used in place of ``app.connection()`` to specify
  592. the intent of the required connection.
  593. .. note::
  594. Two connection pools are available: ``app.pool`` (read), and
  595. ``app.producer_pool`` (write). The latter doesn't actually give connections
  596. but full :class:`kombu.Producer` instances.
  597. .. code-block:: python
  598. def publish_some_message(app, producer=None):
  599. with app.producer_or_acquire(producer) as producer:
  600. ...
  601. def consume_messages(app, connection=None):
  602. with app.connection_or_acquire(connection) as connection:
  603. ...
  604. Amazon SQS transport now officially supported
  605. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  606. The SQS broker transport has been rewritten to use async I/O and as such
  607. joins RabbitMQ and Redis as officially supported transports.
  608. The new implementation also takes advantage of long polling,
  609. and closes several issues related to using SQS as a broker.
  610. This work was sponsored by Nextdoor.
  611. Apache QPid transport now officially supported
  612. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  613. Contributed by **Brian Bouterse**.
  614. Tasks
  615. -----
  616. Task Auto-retry Decorator
  617. ~~~~~~~~~~~~~~~~~~~~~~~~~
  618. Writing custom retry handling for exception events is so common
  619. that we now have built-in support for it.
  620. For this a new ``autoretry_for`` argument is now supported by
  621. the task decorators, where you can specify a tuple of exceptions
  622. to automatically retry for.
  623. See :ref:`task-autoretry` for more information.
  624. Contributed by **Dmitry Malinovsky**.
  625. .. :sha:`75246714dd11e6c463b9dc67f4311690643bff24`
  626. ``Task.replace``
  627. ~~~~~~~~~~~~~~~~
  628. Task.replace changed, removes Task.replace_in_chord.
  629. The two methods had almost the same functionality, but the old
  630. ``Task.replace`` would force the new task to inherit the
  631. callbacks/errbacks of the existing task.
  632. If you replace a node in a tree, then you wouldn't expect the new node to
  633. inherit the children of the old node, so this seems like unexpected
  634. behavior.
  635. So ``self.replace(sig)`` now works for any task, in addition ``sig`` can now
  636. be a group.
  637. Groups are automatically converted to a chord, where the callback
  638. will "accumulate" the results of the group tasks.
  639. A new built-in task (`celery.accumulate` was added for this purpose)
  640. Contributed by **Steeve Morin**, and **Ask Solem**.
  641. Closes #817
  642. Remote Task Tracebacks
  643. ~~~~~~~~~~~~~~~~~~~~~~
  644. The new :setting:`task_remote_tracebacks` will make task tracebacks more
  645. useful by injecting the stack of the remote worker.
  646. This feature requires the additional :pypi:`tblib` library.
  647. Contributed by **Ionel Cristian Mărieș**.
  648. Handling task connection errors
  649. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  650. Connection related errors occuring while sending a task is now re-raised
  651. as a :exc:`kombu.exceptions.OperationalError` error:
  652. .. code-block:: pycon
  653. >>> try:
  654. ... add.delay(2, 2)
  655. ... except add.OperationalError as exc:
  656. ... print('Could not send task %r: %r' % (add, exc))
  657. See :ref:`calling-connection-errors` for more information.
  658. Gevent/Eventlet: Dedicated thread for consuming results
  659. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  660. When using :pypi:`gevent`, or :pypi:`eventlet` there is now a single
  661. thread responsible for consuming events.
  662. This means that if you have many calls retrieving results, there will be
  663. a dedicated thread for consuming them:
  664. .. code-block:: python
  665. result = add.delay(2, 2)
  666. # this call will delegate to the result consumer thread:
  667. # once the consumer thread has received the result this greenlet can
  668. # continue.
  669. value = result.get(timeout=3)
  670. This makes performing RPC calls when using gevent/eventlet perform much
  671. better.
  672. ``AsyncResult.then(on_success, on_error)``
  673. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  674. The AsyncResult API has been extended to support the :class:`~vine.promise` protocol.
  675. This currently only works with the RPC (amqp) and Redis result backends, but
  676. lets you attach callbacks to when tasks finish:
  677. .. code-block:: python
  678. import gevent.monkey
  679. monkey.patch_all()
  680. import time
  681. from celery import Celery
  682. app = Celery(broker='amqp://', backend='rpc')
  683. @app.task
  684. def add(x, y):
  685. return x + y
  686. def on_result_ready(result):
  687. print('Received result for id %r: %r' % (result.id, result.result,))
  688. add.delay(2, 2).then(on_result_ready)
  689. time.sleep(3) # run gevent event loop for a while.
  690. Demonstrated using gevent here, but really this is an API that's more useful
  691. in callback-based event loops like :pypi:`twisted`, or :pypi:`tornado`.
  692. New Task Router API
  693. ~~~~~~~~~~~~~~~~~~~
  694. The :setting:`task_routes` setting can now hold functions, and map routes
  695. now support glob patterns and regexes.
  696. Instead of using router classes you can now simply define a function:
  697. .. code-block:: python
  698. def route_for_task(name, args, kwargs, options, task=None, **kwargs):
  699. from proj import tasks
  700. if name == tasks.add.name:
  701. return {'queue': 'hipri'}
  702. If you don't need the arguments you can use start arguments, just make
  703. sure you always also accept star arguments so that we have the ability
  704. to add more features in the future:
  705. .. code-block:: python
  706. def route_for_task(name, *args, **kwargs):
  707. from proj import tasks
  708. if name == tasks.add.name:
  709. return {'queue': 'hipri', 'priority': 9}
  710. Both the ``options`` argument and the new ``task`` keyword argument
  711. are new to the function-style routers, and will make it easier to write
  712. routers based on execution options, or properties of the task.
  713. The optional ``task`` keyword argument won't be set if a task is called
  714. by name using :meth:`@send_task`.
  715. For more examples, including using glob/regexes in routers please see
  716. :setting:`task_routes` and :ref:`routing-automatic`.
  717. Canvas Refactor
  718. ~~~~~~~~~~~~~~~
  719. The canvas/work-flow implementation have been heavily refactored
  720. to fix some long outstanding issues.
  721. .. :sha:`d79dcd8e82c5e41f39abd07ffed81ca58052bcd2`
  722. .. :sha:`1e9dd26592eb2b93f1cb16deb771cfc65ab79612`
  723. .. :sha:`e442df61b2ff1fe855881c1e2ff9acc970090f54`
  724. .. :sha:`0673da5c09ac22bdd49ba811c470b73a036ee776`
  725. - Error callbacks can now take real exception and traceback instances
  726. (Issue #2538).
  727. .. code-block:: pycon
  728. >>> add.s(2, 2).on_error(log_error.s()).delay()
  729. Where ``log_error`` could be defined as:
  730. .. code-block:: python
  731. @app.task
  732. def log_error(request, exc, traceback):
  733. with open(os.path.join('/var/errors', request.id), 'a') as fh:
  734. print('--\n\n{0} {1} {2}'.format(
  735. task_id, exc, traceback), file=fh)
  736. See :ref:`guide-canvas` for more examples.
  737. - Now unrolls groups within groups into a single group (Issue #1509).
  738. - chunks/map/starmap tasks now routes based on the target task
  739. - chords and chains can now be immutable.
  740. - Fixed bug where serialized signatures weren't converted back into
  741. signatures (Issue #2078)
  742. Fix contributed by **Ross Deane**.
  743. - Fixed problem where chains and groups didn't work when using JSON
  744. serialization (Issue #2076).
  745. Fix contributed by **Ross Deane**.
  746. - Creating a chord no longer results in multiple values for keyword
  747. argument 'task_id' (Issue #2225).
  748. Fix contributed by **Aneil Mallavarapu**.
  749. - Fixed issue where the wrong result is returned when a chain
  750. contains a chord as the penultimate task.
  751. Fix contributed by **Aneil Mallavarapu**.
  752. - Special case of ``group(A.s() | group(B.s() | C.s()))`` now works.
  753. - Chain: Fixed bug with incorrect id set when a subtask is also a chain.
  754. - ``group | group`` is now flattened into a single group (Issue #2573).
  755. - Fixed issue where ``group | task`` wasn't upgrading correctly
  756. to chord (Issue #2922).
  757. - Chords now properly sets ``result.parent`` links.
  758. Periodic Tasks
  759. --------------
  760. New API for configuring periodic tasks
  761. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  762. This new API enables you to use signatures when defining periodic tasks,
  763. removing the chance of mistyping task names.
  764. An example of the new API is :ref:`here <beat-entries>`.
  765. .. :sha:`bc18d0859c1570f5eb59f5a969d1d32c63af764b`
  766. .. :sha:`132d8d94d38f4050db876f56a841d5a5e487b25b`
  767. Optimized Beat implementation
  768. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  769. The :program:`celery beat` implementation has been optimized
  770. for millions of periodic tasks by using a heap to schedule entries.
  771. Contributed by **Ask Solem** and **Alexander Koshelev**.
  772. Schedule tasks based on sunrise, sunset, dawn and dusk
  773. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  774. See :ref:`beat-solar` for more information.
  775. Contributed by **Mark Parncutt**.
  776. Result Backends
  777. ---------------
  778. RPC Result Backend matured
  779. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  780. Lots of bugs in the previously experimental RPC result backend have been fixed
  781. and we now consider it production ready.
  782. Contributed by **Ask Solem**, **Morris Tweed**.
  783. Redis: Result backend optimizations
  784. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  785. ``result.get()`` is now using pub/sub for streaming task results
  786. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  787. Calling ``result.get()`` when using the Redis result backend
  788. used to be extremely expensive as it was using polling to wait
  789. for the result to become available. A default polling
  790. interval of 0.5 seconds didn't help performance, but was
  791. necessary to avoid a spin loop.
  792. The new implementation is using Redis Pub/Sub mechanisms to
  793. publish and retrieve results immediately, greatly improving
  794. task round-trip times.
  795. Contributed by **Yaroslav Zhavoronkov** and **Ask Solem**.
  796. New optimized chord join implementation
  797. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  798. This was an experimental feature introduced in Celery 3.1,
  799. that could only be enabled by adding ``?new_join=1`` to the
  800. result backend URL configuration.
  801. We feel that the implementation has been tested thoroughly enough
  802. to be considered stable and enabled by default.
  803. The new implementation greatly reduces the overhead of chords,
  804. and especially with larger chords the performance benefit can be massive.
  805. New Riak result backend introduced
  806. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  807. See :ref:`conf-riak-result-backend` for more information.
  808. Contributed by **Gilles Dartiguelongue**, **Alman One** and **NoKriK**.
  809. New CouchDB result backend introduced
  810. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  811. See :ref:`conf-couchdb-result-backend` for more information.
  812. Contributed by **Nathan Van Gheem**.
  813. New Consul result backend introduced
  814. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  815. Add support for Consul as a backend using the Key/Value store of Consul.
  816. Consul has an HTTP API where through you can store keys with their values.
  817. The backend extends KeyValueStoreBackend and implements most of the methods.
  818. Mainly to set, get and remove objects.
  819. This allows Celery to store Task results in the K/V store of Consul.
  820. Consul also allows to set a TTL on keys using the Sessions from Consul. This way
  821. the backend supports auto expiry of Task results.
  822. For more information on Consul visit http://consul.io/
  823. The backend uses :pypi:`python-consul` for talking to the HTTP API.
  824. This package is fully Python 3 compliant just as this backend is:
  825. .. code-block:: console
  826. $ pip install python-consul
  827. That installs the required package to talk to Consul's HTTP API from Python.
  828. Contributed by **Wido den Hollander**.
  829. Brand new Cassandra result backend
  830. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  831. A brand new Cassandra backend utilizing the new :pypi:`cassandra-driver`
  832. library is replacing the old result backend using the older
  833. :pypi:`pycassa` library.
  834. See :ref:`conf-cassandra-result-backend` for more information.
  835. .. # XXX What changed?
  836. New Elasticsearch result backend introduced
  837. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  838. See :ref:`conf-elasticsearch-result-backend` for more information.
  839. Contributed by **Ahmet Demir**.
  840. New File-system result backend introduced
  841. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  842. See :ref:`conf-filesystem-result-backend` for more information.
  843. Contributed by **Môshe van der Sterre**.
  844. Event Batching
  845. --------------
  846. Events are now buffered in the worker and sent as a list, reducing
  847. the overhead required to send monitoring events.
  848. For authors of custom event monitors there will be no action
  849. required as long as you're using the Python Celery
  850. helpers (:class:`~@events.Receiver`) to implement your monitor.
  851. However, if you're parsing raw event messages you must now account
  852. for batched event messages, as they differ from normal event messages
  853. in the following way:
  854. - The routing key for a batch of event messages will be set to
  855. ``<event-group>.multi`` where the only batched event group
  856. is currently ``task`` (giving a routing key of ``task.multi``).
  857. - The message body will be a serialized list-of-dictionaries instead
  858. of a dictionary. Each item in the list can be regarded
  859. as a normal event message body.
  860. .. :sha:`03399b4d7c26fb593e61acf34f111b66b340ba4e`
  861. In Other News...
  862. ----------------
  863. Requirements
  864. ~~~~~~~~~~~~
  865. - Now depends on :ref:`Kombu 4.0 <kombu:version-4.0>`.
  866. - Now depends on :pypi:`billiard` version 3.5.
  867. - No longer depends on :pypi:`anyjson`. Good-bye old friend :(
  868. Tasks
  869. ~~~~~
  870. - The "anon-exchange" is now used for simple name-name direct routing.
  871. This increases performance as it completely bypasses the routing table,
  872. in addition it also improves reliability for the Redis broker transport.
  873. - An empty ResultSet now evaluates to True.
  874. Fix contributed by **Colin McIntosh**.
  875. - New :setting:`task_reject_on_worker_lost` setting, and
  876. :attr:`~@Task.reject_on_worker_lost` task attribute decides what happens
  877. when the child worker process executing a late ack task is terminated.
  878. Contributed by **Michael Permana**.
  879. - ``Task.subtask`` renamed to ``Task.signature`` with alias.
  880. - ``Task.subtask_from_request`` renamed to
  881. ``Task.signature_from_request`` with alias.
  882. - The ``delivery_mode`` attribute for :class:`kombu.Queue` is now
  883. respected (Issue #1953).
  884. - Routes in :setting:`task-routes` can now specify a
  885. :class:`~kombu.Queue` instance directly.
  886. Example:
  887. .. code-block:: python
  888. task_routes = {'proj.tasks.add': {'queue': Queue('add')}}
  889. - ``AsyncResult`` now raises :exc:`ValueError` if task_id is None.
  890. (Issue #1996).
  891. - Retried tasks didn't forward expires setting (Issue #3297).
  892. - ``result.get()`` now supports an ``on_message`` argument to set a
  893. callback to be called for every message received.
  894. - New abstract classes added:
  895. - :class:`~celery.utils.abstract.CallableTask`
  896. Looks like a task.
  897. - :class:`~celery.utils.abstract.CallableSignature`
  898. Looks like a task signature.
  899. - ``Task.replace`` now properly forwards callbacks (Issue #2722).
  900. Fix contributed by **Nicolas Unravel**.
  901. - ``Task.replace``: Append to chain/chord (Closes #3232)
  902. Fixed issue #3232, adding the signature to the chain (if there's any).
  903. Fixed the chord suppress if the given signature contains one.
  904. Fix contributed by :github_user:`honux`.
  905. - Task retry now also throws in eager mode.
  906. Fix contributed by **Feanil Patel**.
  907. Beat
  908. ~~~~
  909. - Fixed crontab infinite loop with invalid date.
  910. When occurrence can never be reached (example, April, 31th), trying
  911. to reach the next occurrence would trigger an infinite loop.
  912. Try fixing that by raising a RuntimeError after 2,000 iterations
  913. (Also added a test for crontab leap years in the process)
  914. Fix contributed by **Romuald Brunet**.
  915. - Now ensures the program exits with a non-zero exit code when an
  916. exception terminates the service.
  917. Fix contributed by **Simon Peeters**.
  918. App
  919. ~~~
  920. - Dates are now always timezone aware even if
  921. :setting:`enable_utc` is disabled (Issue #943).
  922. Fix contributed by **Omer Katz**.
  923. - **Config**: App preconfiguration is now also pickled with the configuration.
  924. Fix contributed by **Jeremy Zafran**.
  925. - The application can now change how task names are generated using
  926. the :meth:`~@gen_task_name` method.
  927. Contributed by **Dmitry Malinovsky**.
  928. - App has new ``app.current_worker_task`` property that
  929. returns the task that's currently being worked on (or :const:`None`).
  930. (Issue #2100).
  931. Execution Pools
  932. ~~~~~~~~~~~~~~~
  933. - **Eventlet/Gevent**: Fixed race condition leading to "simultaneous read"
  934. errors (Issue #2812).
  935. - **Prefork**: Prefork pool now uses ``poll`` instead of ``select`` where
  936. available (Issue #2373).
  937. - **Prefork**: Fixed bug where the pool would refuse to shut down the
  938. worker (Issue #2606).
  939. - **Eventlet**: Now returns pool size in :program:`celery inspect stats`
  940. command.
  941. Contributed by **Alexander Oblovatniy**.
  942. Transports
  943. ~~~~~~~~~~
  944. - **Redis Transport**: The Redis transport now supports the
  945. :setting:`broker_use_ssl` option.
  946. Programs
  947. ~~~~~~~~
  948. - :program:`celery multi`: ``%n`` format for is now synonym with
  949. ``%N`` to be consistent with :program:`celery worker`.
  950. - :program:`celery inspect`/:program:`celery control`: now supports a new
  951. :option:`--json <celery inspect --json>` option to give output in json format.
  952. - :program:`celery inspect registered`: now ignores built-in tasks.
  953. - :program:`celery purge` now takes ``-Q`` and ``-X`` options
  954. used to specify what queues to include and exclude from the purge.
  955. - New :program:`celery logtool`: Utility for filtering and parsing
  956. celery worker log-files
  957. - :program:`celery multi`: now passes through `%i` and `%I` log
  958. file formats.
  959. - General: ``%p`` can now be used to expand to the full worker node-name
  960. in log-file/pid-file arguments.
  961. - A new command line option
  962. :option:`--executable <celery worker --executable>` is now
  963. available for daemonizing programs (:program:`celery worker` and
  964. :program:`celery beat`).
  965. Contributed by **Bert Vanderbauwhede**.
  966. - :program:`celery worker`: supports new
  967. :option:`--prefetch-multiplier <celery worker --prefetch-multiplier>` option.
  968. Contributed by **Mickaël Penhard**.
  969. Worker
  970. ~~~~~~
  971. - Improvements and fixes for :class:`~celery.utils.collections.LimitedSet`.
  972. Getting rid of leaking memory + adding ``minlen`` size of the set:
  973. the minimal residual size of the set after operating for some time.
  974. ``minlen`` items are kept, even if they should've been expired.
  975. Problems with older and even more old code:
  976. #. Heap would tend to grow in some scenarios
  977. (like adding an item multiple times).
  978. #. Adding many items fast wouldn't clean them soon enough (if ever).
  979. #. When talking to other workers, revoked._data was sent, but
  980. it was processed on the other side as iterable.
  981. That means giving those keys new (current)
  982. time-stamp. By doing this workers could recycle
  983. items forever. Combined with 1) and 2), this means that in
  984. large set of workers, you're getting out of memory soon.
  985. All those problems should be fixed now.
  986. This should fix issues #3095, #3086.
  987. Contributed by **David Pravec**.
  988. - New settings to control remote control command queues.
  989. - :setting:`control_queue_expires`
  990. Set queue expiry time for both remote control command queues,
  991. and remote control reply queues.
  992. - :setting:`control_queue_ttl`
  993. Set message time-to-live for both remote control command queues,
  994. and remote control reply queues.
  995. Contributed by **Alan Justino**.
  996. - Worker now only starts the remote control command consumer if the
  997. broker transport used actually supports them.
  998. - Gossip now sets ``x-message-ttl`` for event queue to heartbeat_interval s.
  999. (Issue #2005).
  1000. - Now preserves exit code (Issue #2024).
  1001. - Fixed crash when the ``-purge`` argument was used.
  1002. - Log--level for unrecoverable errors changed from ``error`` to
  1003. ``critical``.
  1004. - Improved rate limiting accuracy.
  1005. - Account for missing timezone information in task expires field.
  1006. Fix contributed by **Albert Wang**.
  1007. - The worker no longer has a ``Queues`` bootsteps, as it is now
  1008. superfluous.
  1009. - Now emits the "Received task" line even for revoked tasks.
  1010. (Issue #3155).
  1011. - Now respects :setting:`broker_connection_retry` setting.
  1012. Fix contributed by **Nat Williams**.
  1013. - New :data:`celery.worker.state.requests` enables O(1) loookup
  1014. of active/reserved tasks by id.
  1015. - Auto-scale didn't always update keep-alive when scaling down.
  1016. Fix contributed by **Philip Garnero**.
  1017. - Fixed typo ``options_list`` -> ``option_list``.
  1018. Fix contributed by **Greg Wilbur**.
  1019. Debugging Utilities
  1020. ~~~~~~~~~~~~~~~~~~~
  1021. - :mod:`celery.contrib.rdb`: Changed remote debugger banner so that you can copy and paste
  1022. the address easily (no longer has a period in the address).
  1023. Contributed by **Jonathan Vanasco**.
  1024. - Fixed compatibility with recent :pypi:`psutil` versions (Issue #3262).
  1025. Signals
  1026. ~~~~~~~
  1027. - **App**: New signals for app configuration/finalization:
  1028. - :data:`app.on_configure <@on_configure>`
  1029. - :data:`app.on_after_configure <@on_after_configure>`
  1030. - :data:`app.on_after_finalize <@on_after_finalize>`
  1031. - **Task**: New task signals for rejected task messages:
  1032. - :data:`celery.signals.task_rejected`.
  1033. - :data:`celery.signals.task_unknown`.
  1034. - **Worker**: New signal for when a heartbeat event is sent.
  1035. - :data:`celery.signals.heartbeat_sent`
  1036. Contributed by **Kevin Richardson**.
  1037. Events
  1038. ~~~~~~
  1039. - Event messages now uses the RabbitMQ ``x-message-ttl`` option
  1040. to ensure older event messages are discarded.
  1041. The default is 5 seconds, but can be changed using the
  1042. :setting:`event_queue_ttl` setting.
  1043. - Event monitors now sets the :setting:`event_queue_expires`
  1044. setting by default.
  1045. The queues will now expire after 60 seconds after the monitor stops
  1046. consuming from it.
  1047. - Fixed a bug where a None value wasn't handled properly.
  1048. Fix contributed by **Dongweiming**.
  1049. - New :setting:`event_queue_prefix` setting can now be used
  1050. to change the default ``celeryev`` queue prefix for event receiver queues.
  1051. Contributed by **Takeshi Kanemoto**.
  1052. - ``State.tasks_by_type`` and ``State.tasks_by_worker`` can now be
  1053. used as a mapping for fast access to this information.
  1054. Canvas
  1055. ~~~~~~
  1056. - ``chunks``/``map``/``starmap`` are now routed based on the target task.
  1057. - ``Signature.link`` now works when argument is scalar (not a list)
  1058. (Issue #2019).
  1059. - ``group()`` now properly forwards keyword arguments (Issue #3426).
  1060. Fix contributed by **Samuel Giffard**.
  1061. Deployment
  1062. ~~~~~~~~~~
  1063. - Generic init-scripts now support
  1064. :envvar:`CELERY_SU` and :envvar:`CELERYD_SU_ARGS` environment variables
  1065. to set the path and arguments for :command:`su` (:manpage:`su(1)`).
  1066. - Generic init-scripts now better support FreBSD and other BSD
  1067. systems by searching :file:`/usr/local/etc/` for the configuration file.
  1068. Contributed by **Taha Jahangir**.
  1069. - Generic init-script: Fixed strange bug for ``celerybeat`` where
  1070. restart didn't always work (Issue #3018).
  1071. - The systemd init script now uses a shell when executing
  1072. services.
  1073. Contributed by **Tomas Machalek**.
  1074. Result Backends
  1075. ~~~~~~~~~~~~~~~
  1076. - Redis: Now has a default socket timeout of 5 seconds.
  1077. The default can be changed using the new :setting:`redis_socket_timeout`
  1078. setting.
  1079. Contributed by **Raghuram Srinivasan**.
  1080. - RPC Backend result queues are now auto delete by default (Issue #2001).
  1081. - RPC Backend: Fixed problem where exception
  1082. wasn't deserialized properly with the json serializer (Issue #2518).
  1083. Fix contributed by **Allard Hoeve**.
  1084. - CouchDB: Fixed typo causing the backend to not be found
  1085. (Issue #3287).
  1086. Fix contributed by **Andrew Stewart**.
  1087. - MongoDB: Now supports setting the :setting:`result_serialzier` setting
  1088. to ``bson`` to use the MongoDB libraries own serializer.
  1089. Contributed by **Davide Quarta**.
  1090. - MongoDB: URI handling has been improved to use
  1091. database name, user and password from the URI if provided.
  1092. Contributed by **Samuel Jaillet**.
  1093. - SQLAlchemy result backend: Now ignores all result
  1094. engine options when using NullPool (Issue #1930).
  1095. - SQLAlchemy result backend: Now sets max char size to 155 to deal
  1096. with brain damaged MySQL unicode implementation (Issue #1748).
  1097. - **General**: All Celery exceptions/warnings now inherit from common
  1098. :class:`~celery.exceptions.CeleryError`/:class:`~celery.exceptions.CeleryWarning`.
  1099. (Issue #2643).
  1100. Documentation Improvements
  1101. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1102. Contributed by:
  1103. - Adam Chainz
  1104. - Arthur Vuillard
  1105. - Batiste Bieler
  1106. - Daniel Devine
  1107. - Edward Betts
  1108. - Jason Veatch
  1109. - Jeff Widman
  1110. - Manuel Kaufmann
  1111. - Maxime Beauchemin
  1112. - Mitchel Humpherys
  1113. - Rik
  1114. - Tayfun Sen
  1115. Reorganization, Deprecations, and Removals
  1116. ==========================================
  1117. Incompatible changes
  1118. --------------------
  1119. - Prefork: Calling ``result.get()`` or joining any result from within a task
  1120. now raises :exc:`RuntimeError`.
  1121. In previous versions this would emit a warning.
  1122. - :mod:`celery.worker.consumer` is now a package, not a module.
  1123. - Module ``celery.worker.job`` renamed to :mod:`celery.worker.request`.
  1124. - Beat: ``Scheduler.Publisher``/``.publisher`` renamed to
  1125. ``.Producer``/``.producer``.
  1126. - Result: The task_name argument/attribute of :class:`@AsyncResult` was
  1127. removed.
  1128. This was historically a field used for :mod:`pickle` compatibility,
  1129. but is no longer needed.
  1130. - Backends: Arguments named ``status`` renamed to ``state``.
  1131. - Backends: ``backend.get_status()`` renamed to ``backend.get_state()``.
  1132. - Backends: ``backend.maybe_reraise()`` renamed to ``.maybe_throw()``
  1133. The promise API uses .throw(), so this change was made to make it more
  1134. consistent.
  1135. There's an alias available, so you can still use maybe_reraise until
  1136. Celery 5.0.
  1137. .. _v400-unscheduled-removals:
  1138. Unscheduled Removals
  1139. --------------------
  1140. - The experimental :mod:`celery.contrib.methods` feature has been removed,
  1141. as there were far many bugs in the implementation to be useful.
  1142. - The CentOS init-scripts have been removed.
  1143. These didn't really add any features over the generic init-scripts,
  1144. so you're encouraged to use them instead, or something like
  1145. :pypi:`supervisor`.
  1146. .. _v400-deprecations-reorg:
  1147. Reorganization Deprecations
  1148. ---------------------------
  1149. These symbols have been renamed, and while there's an alias available in this
  1150. version for backward compatibility, they will be removed in Celery 5.0, so
  1151. make sure you rename these ASAP to make sure it won't break for that release.
  1152. Chances are that you'll only use the first in this list, but you never
  1153. know:
  1154. - ``celery.utils.worker_direct`` ->
  1155. :meth:`celery.utils.nodenames.worker_direct`.
  1156. - ``celery.utils.nodename`` -> :meth:`celery.utils.nodenames.nodename`.
  1157. - ``celery.utils.anon_nodename`` ->
  1158. :meth:`celery.utils.nodenames.anon_nodename`.
  1159. - ``celery.utils.nodesplit`` -> :meth:`celery.utils.nodenames.nodesplit`.
  1160. - ``celery.utils.default_nodename`` ->
  1161. :meth:`celery.utils.nodenames.default_nodename`.
  1162. - ``celery.utils.node_format`` -> :meth:`celery.utils.nodenames.node_format`.
  1163. - ``celery.utils.host_format`` -> :meth:`celery.utils.nodenames.host_format`.
  1164. .. _v400-removals:
  1165. Scheduled Removals
  1166. ------------------
  1167. Modules
  1168. ~~~~~~~
  1169. - Module ``celery.worker.job`` has been renamed to :mod:`celery.worker.request`.
  1170. This was an internal module so shouldn't have any effect.
  1171. It's now part of the public API so must not change again.
  1172. - Module ``celery.task.trace`` has been renamed to ``celery.app.trace``
  1173. as the ``celery.task`` package is being phased out. The module
  1174. will be removed in version 5.0 so please change any import from::
  1175. from celery.task.trace import X
  1176. to::
  1177. from celery.app.trace import X
  1178. - Old compatibility aliases in the :mod:`celery.loaders` module
  1179. has been removed.
  1180. - Removed ``celery.loaders.current_loader()``, use: ``current_app.loader``
  1181. - Removed ``celery.loaders.load_settings()``, use: ``current_app.conf``
  1182. Result
  1183. ~~~~~~
  1184. - ``AsyncResult.serializable()`` and ``celery.result.from_serializable``
  1185. has been removed:
  1186. Use instead:
  1187. .. code-block:: pycon
  1188. >>> tup = result.as_tuple()
  1189. >>> from celery.result import result_from_tuple
  1190. >>> result = result_from_tuple(tup)
  1191. - Removed ``BaseAsyncResult``, use ``AsyncResult`` for instance checks
  1192. instead.
  1193. - Removed ``TaskSetResult``, use ``GroupResult`` instead.
  1194. - ``TaskSetResult.total`` -> ``len(GroupResult)``
  1195. - ``TaskSetResult.taskset_id`` -> ``GroupResult.id``
  1196. - Removed ``ResultSet.subtasks``, use ``ResultSet.results`` instead.
  1197. TaskSet
  1198. ~~~~~~~
  1199. TaskSet has been renamed to group and TaskSet will be removed in version 4.0.
  1200. Old::
  1201. >>> from celery.task import TaskSet
  1202. >>> TaskSet(add.subtask((i, i)) for i in xrange(10)).apply_async()
  1203. New::
  1204. >>> from celery import group
  1205. >>> group(add.s(i, i) for i in xrange(10))()
  1206. Events
  1207. ~~~~~~
  1208. - Removals for class :class:`celery.events.state.Worker`:
  1209. - ``Worker._defaults`` attribute.
  1210. Use ``{k: getattr(worker, k) for k in worker._fields}``.
  1211. - ``Worker.update_heartbeat``
  1212. Use ``Worker.event(None, timestamp, received)``
  1213. - ``Worker.on_online``
  1214. Use ``Worker.event('online', timestamp, received, fields)``
  1215. - ``Worker.on_offline``
  1216. Use ``Worker.event('offline', timestamp, received, fields)``
  1217. - ``Worker.on_heartbeat``
  1218. Use ``Worker.event('heartbeat', timestamp, received, fields)``
  1219. - Removals for class :class:`celery.events.state.Task`:
  1220. - ``Task._defaults`` attribute.
  1221. Use ``{k: getattr(task, k) for k in task._fields}``.
  1222. - ``Task.on_sent``
  1223. Use ``Worker.event('sent', timestamp, received, fields)``
  1224. - ``Task.on_received``
  1225. Use ``Task.event('received', timestamp, received, fields)``
  1226. - ``Task.on_started``
  1227. Use ``Task.event('started', timestamp, received, fields)``
  1228. - ``Task.on_failed``
  1229. Use ``Task.event('failed', timestamp, received, fields)``
  1230. - ``Task.on_retried``
  1231. Use ``Task.event('retried', timestamp, received, fields)``
  1232. - ``Task.on_succeeded``
  1233. Use ``Task.event('succeeded', timestamp, received, fields)``
  1234. - ``Task.on_revoked``
  1235. Use ``Task.event('revoked', timestamp, received, fields)``
  1236. - ``Task.on_unknown_event``
  1237. Use ``Task.event(short_type, timestamp, received, fields)``
  1238. - ``Task.update``
  1239. Use ``Task.event(short_type, timestamp, received, fields)``
  1240. - ``Task.merge``
  1241. Contact us if you need this.
  1242. Magic keyword arguments
  1243. ~~~~~~~~~~~~~~~~~~~~~~~
  1244. Support for the very old magic keyword arguments accepted by tasks is
  1245. finally removed in this version.
  1246. If you're still using these you have to rewrite any task still
  1247. using the old ``celery.decorators`` module and depending
  1248. on keyword arguments being passed to the task,
  1249. for example::
  1250. from celery.decorators import task
  1251. @task()
  1252. def add(x, y, task_id=None):
  1253. print('My task id is %r' % (task_id,))
  1254. should be rewritten into::
  1255. from celery import task
  1256. @task(bind=True)
  1257. def add(self, x, y):
  1258. print('My task id is {0.request.id}'.format(self))
  1259. Removed Settings
  1260. ----------------
  1261. The following settings have been removed, and is no longer supported:
  1262. Logging Settings
  1263. ~~~~~~~~~~~~~~~~
  1264. ===================================== =====================================
  1265. **Setting name** **Replace with**
  1266. ===================================== =====================================
  1267. ``CELERYD_LOG_LEVEL`` :option:`celery worker --loglevel`
  1268. ``CELERYD_LOG_FILE`` :option:`celery worker --logfile`
  1269. ``CELERYBEAT_LOG_LEVEL`` :option:`celery beat --loglevel`
  1270. ``CELERYBEAT_LOG_FILE`` :option:`celery beat --loglevel`
  1271. ``CELERYMON_LOG_LEVEL`` celerymon is deprecated, use flower
  1272. ``CELERYMON_LOG_FILE`` celerymon is deprecated, use flower
  1273. ``CELERYMON_LOG_FORMAT`` celerymon is deprecated, use flower
  1274. ===================================== =====================================
  1275. Task Settings
  1276. ~~~~~~~~~~~~~~
  1277. ===================================== =====================================
  1278. **Setting name** **Replace with**
  1279. ===================================== =====================================
  1280. ``CELERY_CHORD_PROPAGATES`` N/A
  1281. ===================================== =====================================
  1282. Changes to internal API
  1283. -----------------------
  1284. - Module ``celery.datastructures`` renamed to :mod:`celery.utils.collections`.
  1285. - Module ``celery.utils.timeutils`` renamed to :mod:`celery.utils.time`.
  1286. - ``celery.utils.datastructures.DependencyGraph`` moved to
  1287. :mod:`celery.utils.graph`.
  1288. - ``celery.utils.jsonify`` is now :func:`celery.utils.serialization.jsonify`.
  1289. - ``celery.utils.strtobool`` is now
  1290. :func:`celery.utils.serialization.strtobool`.
  1291. - ``celery.utils.is_iterable`` has been removed.
  1292. Instead use::
  1293. isinstance(x, collections.Iterable)
  1294. - ``celery.utils.lpmerge`` is now :func:`celery.utils.collections.lpmerge`.
  1295. - ``celery.utils.cry`` is now :func:`celery.utils.debug.cry`.
  1296. - ``celery.utils.isatty`` is now :func:`celery.platforms.isatty`.
  1297. - ``celery.utils.gen_task_name`` is now
  1298. :func:`celery.utils.imports.gen_task_name`.
  1299. - ``celery.utils.deprecated`` is now :func:`celery.utils.deprecated.Callable`
  1300. - ``celery.utils.deprecated_property`` is now
  1301. :func:`celery.utils.deprecated.Property`.
  1302. - ``celery.utils.warn_deprecated`` is now :func:`celery.utils.deprecated.warn`
  1303. .. _v400-deprecations:
  1304. Deprecation Time-line Changes
  1305. =============================
  1306. See the :ref:`deprecation-timeline`.