deprecation.rst 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. .. _deprecation-timeline:
  2. =============================
  3. Celery Deprecation Timeline
  4. =============================
  5. .. contents::
  6. :local:
  7. .. _deprecations-v4.0:
  8. Removals for version 4.0
  9. ========================
  10. - Module ``celery.task.trace`` has been renamed to ``celery.app.trace``
  11. as the ``celery.task`` package is being phased out. The compat module
  12. will be removed in version 4.0 so please change any import from::
  13. from celery.task.trace import …
  14. to::
  15. from celery.app.trace import …
  16. - ``AsyncResult.serializable()`` and ``celery.result.from_serializable``
  17. will be removed.
  18. Use instead::
  19. >>> tup = result.as_tuple()
  20. >>> from celery.result import result_from_tuple
  21. >>> result = result_from_tuple(tup)
  22. TaskSet
  23. ~~~~~~~
  24. TaskSet has been renamed to group and TaskSet will be removed in version 4.0.
  25. Old::
  26. >>> from celery.task import TaskSet
  27. >>> TaskSet(add.subtask((i, i)) for i in xrange(10)).apply_async()
  28. New::
  29. >>> from celery import group
  30. >>> group(add.s(i, i) for i in xrange(10))()
  31. Magic keyword arguments
  32. ~~~~~~~~~~~~~~~~~~~~~~~
  33. The magic keyword arguments accepted by tasks will be removed
  34. in 4.0, so you should start rewriting any tasks
  35. using the ``celery.decorators`` module and depending
  36. on keyword arguments being passed to the task,
  37. for example::
  38. from celery.decorators import task
  39. @task()
  40. def add(x, y, task_id=None):
  41. print("My task id is %r" % (task_id,))
  42. should be rewritten into::
  43. from celery import task
  44. @task(bind=True)
  45. def add(self, x, y):
  46. print("My task id is {0.request.id}".format(self))
  47. :mod:`celery.result`
  48. --------------------
  49. - ``BaseAsyncResult`` -> ``AsyncResult``.
  50. - ``TaskSetResult`` -> ``GroupResult``.
  51. - ``TaskSetResult.total`` -> ``len(GroupResult)``
  52. - ``TaskSetResult.taskset_id`` -> ``GroupResult.id``
  53. :mod:`celery.loader`
  54. --------------------
  55. - ``current_loader()`` -> ``current_app.loader``
  56. - ``load_settings()`` -> ``current_app.conf``
  57. Settings
  58. --------
  59. Logging Settings
  60. ~~~~~~~~~~~~~~~~
  61. ===================================== =====================================
  62. **Setting name** **Replace with**
  63. ===================================== =====================================
  64. ``CELERYD_LOG_LEVEL`` :option:`--loglevel`
  65. ``CELERYD_LOG_FILE`` :option:`--logfile``
  66. ``CELERYBEAT_LOG_LEVEL`` :option:`--loglevel`
  67. ``CELERYBEAT_LOG_FILE`` :option:`--loglevel``
  68. ``CELERYMON_LOG_LEVEL`` :option:`--loglevel`
  69. ``CELERYMON_LOG_FILE`` :option:`--loglevel``
  70. ===================================== =====================================
  71. .. _deprecations-v5.0:
  72. Removals for version 5.0
  73. ========================
  74. Old Task API
  75. ------------
  76. .. _deprecate-compat-task-modules:
  77. Compat Task Modules
  78. ~~~~~~~~~~~~~~~~~~~
  79. - Module ``celery.decorators`` will be removed:
  80. Which means you need to change::
  81. from celery.decorators import task
  82. Into::
  83. from celery import task
  84. - Module ``celery.task`` *may* be removed (not decided)
  85. This means you should change::
  86. from celery.task import task
  87. into::
  88. from celery import task
  89. -- and::
  90. from celery.task import Task
  91. into::
  92. from celery import Task
  93. Note that the new :class:`~celery.Task` class no longer
  94. uses classmethods for these methods:
  95. - delay
  96. - apply_async
  97. - retry
  98. - apply
  99. - AsyncResult
  100. - subtask
  101. This also means that you can't call these methods directly
  102. on the class, but have to instantiate the task first::
  103. >>> MyTask.delay() # NO LONGER WORKS
  104. >>> MyTask().delay() # WORKS!
  105. Task attributes
  106. ---------------
  107. The task attributes:
  108. - ``queue``
  109. - ``exchange``
  110. - ``exchange_type``
  111. - ``routing_key``
  112. - ``delivery_mode``
  113. - ``priority``
  114. is deprecated and must be set by :setting:`task_routes` instead.
  115. Modules to Remove
  116. -----------------
  117. - ``celery.execute``
  118. This module only contains ``send_task``, which must be replaced with
  119. :attr:`@send_task` instead.
  120. - ``celery.decorators``
  121. See :ref:`deprecate-compat-task-modules`
  122. - ``celery.log``
  123. Use :attr:`@log` instead.
  124. - ``celery.messaging``
  125. Use :attr:`@amqp` instead.
  126. - ``celery.registry``
  127. Use :mod:`celery.app.registry` instead.
  128. - ``celery.task.control``
  129. Use :attr:`@control` instead.
  130. - ``celery.task.schedules``
  131. Use :mod:`celery.schedules` instead.
  132. - ``celery.task.chords``
  133. Use :func:`celery.chord` instead.
  134. Settings
  135. --------
  136. ``BROKER`` Settings
  137. ~~~~~~~~~~~~~~~~~~~
  138. ===================================== =====================================
  139. **Setting name** **Replace with**
  140. ===================================== =====================================
  141. ``BROKER_HOST`` :setting:`broker_url`
  142. ``BROKER_PORT`` :setting:`broker_url`
  143. ``BROKER_USER`` :setting:`broker_url`
  144. ``BROKER_PASSWORD`` :setting:`broker_url`
  145. ``BROKER_VHOST`` :setting:`broker_url`
  146. ===================================== =====================================
  147. ``REDIS`` Result Backend Settings
  148. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  149. ===================================== =====================================
  150. **Setting name** **Replace with**
  151. ===================================== =====================================
  152. ``CELERY_REDIS_HOST`` :setting:`result_backend`
  153. ``CELERY_REDIS_PORT`` :setting:`result_backend`
  154. ``CELERY_REDIS_DB`` :setting:`result_backend`
  155. ``CELERY_REDIS_PASSWORD`` :setting:`result_backend`
  156. ``REDIS_HOST`` :setting:`result_backend`
  157. ``REDIS_PORT`` :setting:`result_backend`
  158. ``REDIS_DB`` :setting:`result_backend`
  159. ``REDIS_PASSWORD`` :setting:`result_backend`
  160. ===================================== =====================================
  161. Task_sent signal
  162. ----------------
  163. The :signal:`task_sent` signal will be removed in version 4.0.
  164. Please use the :signal:`before_task_publish` and :signal:`after_task_publush`
  165. signals instead.
  166. Result
  167. ------
  168. Apply to: :class:`~celery.result.AsyncResult`,
  169. :class:`~celery.result.EagerResult`::
  170. - ``Result.wait()`` -> ``Result.get()``
  171. - ``Result.task_id()`` -> ``Result.id``
  172. - ``Result.status`` -> ``Result.state``.
  173. .. _deprecations-v3.1:
  174. Settings
  175. ~~~~~~~~
  176. ===================================== =====================================
  177. **Setting name** **Replace with**
  178. ===================================== =====================================
  179. ``CELERY_TASK_ERROR_WITELIST`` Annotate ``Task.ErrorMail``
  180. ``CELERY_AMQP_TASK_RESULT_EXPIRES`` :setting:`result_expires`
  181. ===================================== =====================================
  182. .. _deprecations-v2.0:
  183. Removals for version 2.0
  184. ========================
  185. * The following settings will be removed:
  186. ===================================== =====================================
  187. **Setting name** **Replace with**
  188. ===================================== =====================================
  189. `CELERY_AMQP_CONSUMER_QUEUES` `task_queues`
  190. `CELERY_AMQP_CONSUMER_QUEUES` `task_queues`
  191. `CELERY_AMQP_EXCHANGE` `task_default_exchange`
  192. `CELERY_AMQP_EXCHANGE_TYPE` `task_default_exchange_type`
  193. `CELERY_AMQP_CONSUMER_ROUTING_KEY` `task_queues`
  194. `CELERY_AMQP_PUBLISHER_ROUTING_KEY` `task_default_routing_key`
  195. ===================================== =====================================
  196. * :envvar:`CELERY_LOADER` definitions without class name.
  197. E.g. `celery.loaders.default`, needs to include the class name:
  198. `celery.loaders.default.Loader`.
  199. * :meth:`TaskSet.run`. Use :meth:`celery.task.base.TaskSet.apply_async`
  200. instead.
  201. * The module :mod:`celery.task.rest`; use :mod:`celery.task.httpY` instead.