task.base

Deprecated task base class.

The task implementation has been moved to celery.app.task.

This contains the backward compatible Task class used in the old API, and shouldn’t be used in new applications.

Module Contents

Classes

_CompatShared(self,name,cons)
TaskType() Meta class for tasks.
Task() Deprecated Task base class.
PeriodicTask(self) A task that adds itself to the :setting:`beat_schedule` setting.

Functions

task(*args,**kwargs) Deprecated decorator, please use celery.task().
periodic_task(*args,**options) Deprecated decorator, please use :setting:`beat_schedule`.
class _CompatShared(name, cons)
__init__(name, cons)
__hash__()
__repr__()
__call__(app)
class TaskType

Meta class for tasks.

Automatically registers the task in the task registry (except if the Task.abstract` attribute is set).

If no Task.name attribute is provided, then the name is generated from the module and class name.

__new__(name, bases, attrs)
__repr__()
class Task

Deprecated Task base class.

Modern applications should use celery.Task instead.

request()
backend()
backend(value)
get_logger(**kwargs)
establish_connection()

Deprecated method used to get a broker connection.

Should be replaced with @Celery.connection() instead, or by acquiring connections from the connection pool:

Examples:
>>> # using the connection pool
>>> with celery.pool.acquire(block=True) as conn:
...     pass
>>> # establish fresh connection
>>> with celery.connection_for_write() as conn:
...     pass
get_publisher(connection=None, exchange=None, exchange_type=None, **options)

Deprecated method to get the task publisher (now called producer).

Should be replaced with kombu.Producer:

with app.connection_for_write() as conn:
    with app.amqp.Producer(conn) as prod:
        my_task.apply_async(producer=prod)

or even better is to use the :class:`@amqp.producer_pool`:

.. code-block:: python

    with app.producer_or_acquire() as prod:
        my_task.apply_async(producer=prod)
get_consumer(connection=None, queues=None, **kwargs)

Get consumer for the queue this task is sent to.

Deprecated!

Should be replaced by @amqp.TaskConsumer.

class PeriodicTask

A task that adds itself to the :setting:`beat_schedule` setting.

__init__()
on_bound(app)
task(*args, **kwargs)

Deprecated decorator, please use celery.task().

periodic_task(*args, **options)

Deprecated decorator, please use :setting:`beat_schedule`.