deprecation.rst 7.1 KB

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