deprecation.rst 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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. Apply to: :class:`~celery.result.AsyncResult`,
  54. :class:`~celery.result.EagerResult`::
  55. - ``Result.wait()`` -> ``Result.get()``
  56. - ``Result.task_id()`` -> ``Result.id``
  57. - ``Result.status`` -> ``Result.state``.
  58. :mod:`celery.loader`
  59. --------------------
  60. - ``current_loader()`` -> ``current_app.loader``
  61. - ``load_settings()`` -> ``current_app.conf``
  62. Task_sent signal
  63. ----------------
  64. The :signal:`task_sent` signal will be removed in version 4.0.
  65. Please use the :signal:`before_task_publish` and :signal:`after_task_publush`
  66. signals instead.
  67. Settings
  68. --------
  69. ``BROKER`` Settings
  70. ~~~~~~~~~~~~~~~~~~~
  71. ===================================== =====================================
  72. **Setting name** **Replace with**
  73. ===================================== =====================================
  74. ``BROKER_HOST`` :setting:`broker_url`
  75. ``BROKER_PORT`` :setting:`broker_url`
  76. ``BROKER_USER`` :setting:`broker_url`
  77. ``BROKER_PASSWORD`` :setting:`broker_url`
  78. ``BROKER_VHOST`` :setting:`broker_url`
  79. ===================================== =====================================
  80. ``REDIS`` Result Backend Settings
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. ===================================== =====================================
  83. **Setting name** **Replace with**
  84. ===================================== =====================================
  85. ``CELERY_REDIS_HOST`` :setting:`result_backend`
  86. ``CELERY_REDIS_PORT`` :setting:`result_backend`
  87. ``CELERY_REDIS_DB`` :setting:`result_backend`
  88. ``CELERY_REDIS_PASSWORD`` :setting:`result_backend`
  89. ``REDIS_HOST`` :setting:`result_backend`
  90. ``REDIS_PORT`` :setting:`result_backend`
  91. ``REDIS_DB`` :setting:`result_backend`
  92. ``REDIS_PASSWORD`` :setting:`result_backend`
  93. ===================================== =====================================
  94. Logging Settings
  95. ~~~~~~~~~~~~~~~~
  96. ===================================== =====================================
  97. **Setting name** **Replace with**
  98. ===================================== =====================================
  99. ``CELERYD_LOG_LEVEL`` :option:`--loglevel`
  100. ``CELERYD_LOG_FILE`` :option:`--logfile``
  101. ``CELERYBEAT_LOG_LEVEL`` :option:`--loglevel`
  102. ``CELERYBEAT_LOG_FILE`` :option:`--loglevel``
  103. ``CELERYMON_LOG_LEVEL`` :option:`--loglevel`
  104. ``CELERYMON_LOG_FILE`` :option:`--loglevel``
  105. ===================================== =====================================
  106. Other Settings
  107. ~~~~~~~~~~~~~~
  108. ===================================== =====================================
  109. **Setting name** **Replace with**
  110. ===================================== =====================================
  111. ``CELERY_TASK_ERROR_WITELIST`` Annotate ``Task.ErrorMail``
  112. ``CELERY_AMQP_TASK_RESULT_EXPIRES`` :setting:`result_expires`
  113. ===================================== =====================================
  114. .. _deprecations-v5.0:
  115. Removals for version 5.0
  116. ========================
  117. Old Task API
  118. ------------
  119. .. _deprecate-compat-task-modules:
  120. Compat Task Modules
  121. ~~~~~~~~~~~~~~~~~~~
  122. - Module ``celery.decorators`` will be removed:
  123. Which means you need to change::
  124. from celery.decorators import task
  125. Into::
  126. from celery import task
  127. - Module ``celery.task`` *may* be removed (not decided)
  128. This means you should change::
  129. from celery.task import task
  130. into::
  131. from celery import task
  132. -- and::
  133. from celery.task import Task
  134. into::
  135. from celery import Task
  136. Note that the new :class:`~celery.Task` class no longer
  137. uses classmethods for these methods:
  138. - delay
  139. - apply_async
  140. - retry
  141. - apply
  142. - AsyncResult
  143. - subtask
  144. This also means that you can't call these methods directly
  145. on the class, but have to instantiate the task first::
  146. >>> MyTask.delay() # NO LONGER WORKS
  147. >>> MyTask().delay() # WORKS!
  148. Task attributes
  149. ---------------
  150. The task attributes:
  151. - ``queue``
  152. - ``exchange``
  153. - ``exchange_type``
  154. - ``routing_key``
  155. - ``delivery_mode``
  156. - ``priority``
  157. is deprecated and must be set by :setting:`task_routes` instead.
  158. Modules to Remove
  159. -----------------
  160. - ``celery.execute``
  161. This module only contains ``send_task``, which must be replaced with
  162. :attr:`@send_task` instead.
  163. - ``celery.decorators``
  164. See :ref:`deprecate-compat-task-modules`
  165. - ``celery.log``
  166. Use :attr:`@log` instead.
  167. - ``celery.messaging``
  168. Use :attr:`@amqp` instead.
  169. - ``celery.registry``
  170. Use :mod:`celery.app.registry` instead.
  171. - ``celery.task.control``
  172. Use :attr:`@control` instead.
  173. - ``celery.task.schedules``
  174. Use :mod:`celery.schedules` instead.
  175. - ``celery.task.chords``
  176. Use :func:`celery.chord` instead.
  177. .. _deprecations-v2.0:
  178. Removals for version 2.0
  179. ========================
  180. * The following settings will be removed:
  181. ===================================== =====================================
  182. **Setting name** **Replace with**
  183. ===================================== =====================================
  184. `CELERY_AMQP_CONSUMER_QUEUES` `task_queues`
  185. `CELERY_AMQP_CONSUMER_QUEUES` `task_queues`
  186. `CELERY_AMQP_EXCHANGE` `task_default_exchange`
  187. `CELERY_AMQP_EXCHANGE_TYPE` `task_default_exchange_type`
  188. `CELERY_AMQP_CONSUMER_ROUTING_KEY` `task_queues`
  189. `CELERY_AMQP_PUBLISHER_ROUTING_KEY` `task_default_routing_key`
  190. ===================================== =====================================
  191. * :envvar:`CELERY_LOADER` definitions without class name.
  192. E.g. `celery.loaders.default`, needs to include the class name:
  193. `celery.loaders.default.Loader`.
  194. * :meth:`TaskSet.run`. Use :meth:`celery.task.base.TaskSet.apply_async`
  195. instead.
  196. * The module :mod:`celery.task.rest`; use :mod:`celery.task.httpY` instead.