This document describes the current stable version of Celery (5.5). For development docs, go here.
Celery Deprecation Time-line¶
Removals for version 5.0¶
Old Task API¶
Compat Task Modules¶
Module
celery.decoratorswill be removed:This means you need to change:
from celery.decorators import task
Into:
from celery import task
Module
celery.taskwill be removedThis means you should change:
from celery.task import task
into:
from celery import shared_task
—and:
from celery import task
into:
from celery import shared_task
—and:
from celery.task import Task
into:
from celery import Task
Note that the new Task class no longer
uses classmethod() for these methods:
delay
apply_async
retry
apply
AsyncResult
subtask
This also means that you can’t call these methods directly on the class, but have to instantiate the task first:
>>> MyTask.delay() # NO LONGER WORKS
>>> MyTask().delay() # WORKS!
Task attributes¶
The task attributes:
queueexchangeexchange_typerouting_keydelivery_modepriority
is deprecated and must be set by task_routes instead.
Modules to Remove¶
celery.executeThis module only contains
send_task: this must be replaced withapp.send_taskinstead.celery.decoratorscelery.logUse
app.loginstead.celery.messagingUse
app.amqpinstead.celery.registryUse
celery.app.registryinstead.celery.task.controlUse
app.controlinstead.celery.task.schedulesUse
celery.schedulesinstead.celery.task.chordsUse
celery.chord()instead.
Settings¶
BROKER Settings¶
Setting name |
Replace with |
|---|---|
|
|
|
|
|
|
|
|
|
REDIS Result Backend Settings¶
Setting name |
Replace with |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task_sent signal¶
The task_sent signal will be removed in version 4.0.
Please use the before_task_publish and after_task_publish
signals instead.
Result¶
Apply to: AsyncResult,
EagerResult:
Result.wait()->Result.get()Result.task_id()->Result.idResult.status->Result.state.
Settings¶
Setting name |
Replace with |
|---|---|
|
Removals for version 2.0¶
The following settings will be removed:
Setting name |
Replace with |
|---|---|
CELERY_AMQP_CONSUMER_QUEUES |
task_queues |
CELERY_AMQP_CONSUMER_QUEUES |
task_queues |
CELERY_AMQP_EXCHANGE |
task_default_exchange |
CELERY_AMQP_EXCHANGE_TYPE |
task_default_exchange_type |
CELERY_AMQP_CONSUMER_ROUTING_KEY |
task_queues |
CELERY_AMQP_PUBLISHER_ROUTING_KEY |
task_default_routing_key |
CELERY_LOADERdefinitions without class name.For example,, celery.loaders.default, needs to include the class name: celery.loaders.default.Loader.
TaskSet.run(). Usecelery.task.base.TaskSet.apply_async()instead.