Skip to main content

DjangoTask

Extend the base :class:~celery.app.task.Task for Django. Provide a nicer API to trigger tasks at the end of the DB transaction.

Methods


delay_on_commit()

@classmethod
def delay_on_commit(
*args: Any,
**kwargs: Any
) - > null

Call :meth:~celery.app.task.Task.delay with Django's on_commit().

Parameters

NameTypeDescription
*argsAnyPositional arguments to be passed to the task function when it is executed.
**kwargsAnyKeyword arguments to be passed to the task function when it is executed.

Returns

TypeDescription
nullNothing is returned; the task is scheduled for execution after the current database transaction commits.

apply_async_on_commit()

@classmethod
def apply_async_on_commit(
*args: Any,
**kwargs: Any
) - > null

Call :meth:~celery.app.task.Task.apply_async with Django's on_commit().

Parameters

NameTypeDescription
*argsAnyPositional arguments to be passed to the task's apply_async method.
**kwargsAnyKeyword arguments representing execution options such as countdown, eta, or queue names.

Returns

TypeDescription
nullNothing is returned; the task execution is deferred until the database transaction is successfully committed.