This document describes Celery 3.0. For development docs, go here.
Module celery.decorators will be removed:
Which means you need to change:
from celery.decorators import task
Into:
from celery import task
Module celery.task may be removed (not decided)
This means you should change:
from celery.task import taskinto:
from celery import task—and::
from celery.task import Task
into:
from celery import Task
Note that the new Task class no longer uses classmethods 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!
TaskSet has been renamed to group and TaskSet will be removed in version 4.0.
Old:
>>> from celery.task import TaskSet
>>> TaskSet(add.subtask((i, i)) for i in xrange(10)).apply_async()
New:
>>> from celery import group
>>> group(add.s(i, i) for i in xrange(10))()
The magic keyword arguments accepted by tasks will be removed in 4.0, so you should start rewriting any tasks using the celery.decorators module and depending on keyword arguments being passed to the task, for example:
from celery.decorators import task
@task()
def add(x, y, task_id=None):
print("My task id is %r" % (task_id, ))
must be rewritten into:
from celery import task
@task()
def add(x, y):
print("My task id is %r" % (add.request.id, ))
The task attributes:
is deprecated and must be set by CELERY_ROUTES instead.
Apply to: AsyncResult, EagerResult:
- ``Result.wait()`` -> ``Result.get()``
celery.execute
This module only contains send_task, which must be replaced with celery.send_task instead.
celery.decorators
celery.log
Use celery.log instead.
celery.messaging
Use celery.amqp instead.
celery.registry
Use celery.app.registry instead.
celery.task.control
Use celery.control instead.
celery.task.schedules
Use celery.schedules instead.
celery.task.chords
Use celery.chord() instead.
| Setting name | Replace with |
|---|---|
| BROKER_HOST | BROKER_URL |
| BROKER_PORT | BROKER_URL |
| BROKER_USER | BROKER_URL |
| BROKER_PASSWORD | BROKER_URL |
| BROKER_VHOST | BROKER_URL |
| BROKER_INSIST | no alternative |
| Setting name | Replace with |
|---|---|
| CELERY_REDIS_HOST | CELERY_RESULT_BACKEND |
| CELERY_REDIS_PORT | CELERY_RESULT_BACKEND |
| CELERY_REDIS_DB | CELERY_RESULT_BACKEND |
| CELERY_REDIS_PASSWORD | CELERY_RESULT_BACKEND |
| REDIS_HOST | CELERY_RESULT_BACKEND |
| REDIS_PORT | CELERY_RESULT_BACKEND |
| REDIS_DB | CELERY_RESULT_BACKEND |
| REDIS_PASSWORD | CELERY_RESULT_BACKEND |
| Setting name | Replace with |
|---|---|
| CELERYD_LOG_LEVEL | --loglevel |
| CELERYD_LOG_FILE | --logfile` |
| CELERYBEAT_LOG_LEVEL | --loglevel |
| CELERYBEAT_LOG_FILE | --loglevel` |
| CELERYMON_LOG_LEVEL | --loglevel |
| CELERYMON_LOG_FILE | --loglevel` |
| Setting name | Replace with |
|---|---|
| CELERY_TASK_ERROR_WITELIST | Annotate Task.ErrorMail |
| CELERY_AMQP_TASK_RESULT_EXPIRES | CELERY_TASK_RESULT_EXPIRES |
| Setting name | Replace with |
|---|---|
| CELERY_AMQP_CONSUMER_QUEUES | CELERY_QUEUES |
| CELERY_AMQP_CONSUMER_QUEUES | CELERY_QUEUES |
| CELERY_AMQP_EXCHANGE | CELERY_DEFAULT_EXCHANGE |
| CELERY_AMQP_EXCHANGE_TYPE | CELERY_DEFAULT_AMQP_EXCHANGE_TYPE |
| CELERY_AMQP_CONSUMER_ROUTING_KEY | CELERY_QUEUES |
| CELERY_AMQP_PUBLISHER_ROUTING_KEY | CELERY_DEFAULT_ROUTING_KEY |
CELERY_LOADER definitions without class name.
E.g. celery.loaders.default, needs to include the class name: celery.loaders.default.Loader.
instead.
The module celery.task.rest; use celery.task.http instead.