whatsnew-4.0.rst 53 KB

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