deprecation.rst 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. .. _deprecation-timeline:
  2. =============================
  3. Celery Deprecation Timeline
  4. =============================
  5. .. contents::
  6. :local:
  7. .. _deprecations-v3.0:
  8. Removals for version 3.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. Magic keyword arguments
  42. ~~~~~~~~~~~~~~~~~~~~~~~
  43. The magic keyword arguments accepted by tasks will be removed
  44. in 3.0, so you should start rewriting any tasks
  45. using the ``celery.decorators`` module and depending
  46. on keyword arguments being passed to the task,
  47. for example::
  48. from celery.decorators import task
  49. @task()
  50. def add(x, y, task_id=None):
  51. print("My task id is %r" % (task_id, ))
  52. must be rewritten into::
  53. from celery import task
  54. @task()
  55. def add(x, y):
  56. print("My task id is %r" % (add.request.id, ))
  57. Task attributes
  58. ---------------
  59. The task attributes:
  60. - ``queue``
  61. - ``exchange``
  62. - ``exchange_type``
  63. - ``routing_key``
  64. - ``delivery_mode``
  65. - ``priority``
  66. is deprecated and must be set by :setting:`CELERY_ROUTES` instead.
  67. :mod:`celery.result`
  68. --------------------
  69. - ``BaseAsyncResult`` -> ``AsyncResult``.
  70. - ``TaskSetResult.total`` -> ``len(TaskSetResult)``
  71. Apply to: :class:`~celery.result.AsyncResult`,
  72. :class:`~celery.result.ResultSet`, :class:`~celery.result.EagerResult`,
  73. :class:`~celery.result.TaskSetResult`.
  74. - ``Result.wait()`` -> ``Result.get()``
  75. - ``Result.task_id()`` -> ``Result.id``
  76. - ``TaskSetResult.taskset_id`` -> ``TaskSetResult.id``
  77. - ``Result.status`` -> ``Result.state``.
  78. :mod:`celery.loader`
  79. --------------------
  80. - ``current_loader()`` -> ``current_app.loader``
  81. - ``load_settings()`` -> ``current_app.conf``
  82. Modules to Remove
  83. -----------------
  84. - ``celery.execute``
  85. This module only contains ``send_task``, which must be replaced with
  86. :attr:`@send_task` instead.
  87. - ``celery.decorators``
  88. See :ref:`deprecate-compat-task-modules`
  89. - ``celery.log``
  90. Use :attr:`@log` instead.
  91. - ``celery.messaging``
  92. Use :attr:`@amqp` instead.
  93. - ``celery.registry``
  94. Use :mod:`celery.app.registry` instead.
  95. - ``celery.task.control``
  96. Use :attr:`@control` instead.
  97. - ``celery.task.schedules``
  98. Use :mod:`celery.schedules` instead.
  99. - ``celery.task.chords``
  100. Use :func:`celery.chord` instead.
  101. Settings
  102. --------
  103. ``BROKER`` Settings
  104. ~~~~~~~~~~~~~~~~~~~
  105. ===================================== =====================================
  106. **Setting name** **Replace with**
  107. ===================================== =====================================
  108. ``BROKER_HOST`` :setting:`BROKER_URL`
  109. ``BROKER_PORT`` :setting:`BROKER_URL`
  110. ``BROKER_USER`` :setting:`BROKER_URL`
  111. ``BROKER_PASSWORD`` :setting:`BROKER_URL`
  112. ``BROKER_VHOST`` :setting:`BROKER_URL`
  113. ``BROKER_INSIST`` *no alternative*
  114. ``REDIS`` Result Backend Settings
  115. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116. ===================================== =====================================
  117. **Setting name** **Replace with**
  118. ===================================== =====================================
  119. ``CELERY_REDIS_HOST`` :setting:`CELERY_RESULT_BACKEND`
  120. ``CELERY_REDIS_PORT`` :setting:`CELERY_RESULT_BACKEND`
  121. ``CELERY_REDIS_DB`` :setting:`CELERY_RESULT_BACKEND`
  122. ``CELERY_REDIS_PASSWORD`` :setting:`CELERY_RESULT_BACKEND`
  123. ``REDIS_HOST`` :setting:`CELERY_RESULT_BACKEND`
  124. ``REDIS_PORT`` :setting:`CELERY_RESULT_BACKEND`
  125. ``REDIS_DB`` :setting:`CELERY_RESULT_BACKEND`
  126. ``REDIS_PASSWORD`` :setting:`CELERY_RESULT_BACKEND`
  127. Logging Settings
  128. ~~~~~~~~~~~~~~~~
  129. ===================================== =====================================
  130. **Setting name** **Replace with**
  131. ===================================== =====================================
  132. ``CELERYD_LOG_LEVEL`` :option:`--loglevel`
  133. ``CELERYD_LOG_FILE`` :option:`--logfile``
  134. ``CELERYBEAT_LOG_LEVEL`` :option:`--loglevel`
  135. ``CELERYBEAT_LOG_FILE`` :option:`--loglevel``
  136. ``CELERYMON_LOG_LEVEL`` :option:`--loglevel`
  137. ``CELERYMON_LOG_FILE`` :option:`--loglevel``
  138. Other Settings
  139. ~~~~~~~~~~~~~~
  140. ===================================== =====================================
  141. **Setting name** **Replace with**
  142. ===================================== =====================================
  143. ``CELERY_TASK_ERROR_WITELIST`` Annotate ``Task.ErrorMail``
  144. ``CELERY_AMQP_TASK_RESULT_EXPIRES`` :setting:`CELERY_TASK_RESULT_EXPIRES`
  145. .. _deprecations-v2.0:
  146. Removals for version 2.0
  147. ========================
  148. * The following settings will be removed:
  149. ===================================== =====================================
  150. **Setting name** **Replace with**
  151. ===================================== =====================================
  152. `CELERY_AMQP_CONSUMER_QUEUES` `CELERY_QUEUES`
  153. `CELERY_AMQP_CONSUMER_QUEUES` `CELERY_QUEUES`
  154. `CELERY_AMQP_EXCHANGE` `CELERY_DEFAULT_EXCHANGE`
  155. `CELERY_AMQP_EXCHANGE_TYPE` `CELERY_DEFAULT_AMQP_EXCHANGE_TYPE`
  156. `CELERY_AMQP_CONSUMER_ROUTING_KEY` `CELERY_QUEUES`
  157. `CELERY_AMQP_PUBLISHER_ROUTING_KEY` `CELERY_DEFAULT_ROUTING_KEY`
  158. ===================================== =====================================
  159. * :envvar:`CELERY_LOADER` definitions without class name.
  160. E.g. `celery.loaders.default`, needs to include the class name:
  161. `celery.loaders.default.Loader`.
  162. * :meth:`TaskSet.run`. Use :meth:`celery.task.base.TaskSet.apply_async`
  163. instead.
  164. * The module :mod:`celery.task.rest`; use :mod:`celery.task.http` instead.