deprecation.rst 7.9 KB

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