deprecation.rst 7.5 KB

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