MCPcopy Create free account
hub / github.com/celery/celery / DjangoTask

Class DjangoTask

celery/contrib/django/task.py:8–21  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

6
7
8class DjangoTask(Task):
9 """
10 Extend the base :class:`~celery.app.task.Task` for Django.
11
12 Provide a nicer API to trigger tasks at the end of the DB transaction.
13 """
14
15 def delay_on_commit(self, *args, **kwargs) -> None:
16 """Call :meth:`~celery.app.task.Task.delay` with Django's ``on_commit()``."""
17 transaction.on_commit(functools.partial(self.delay, *args, **kwargs))
18
19 def apply_async_on_commit(self, *args, **kwargs) -> None:
20 """Call :meth:`~celery.app.task.Task.apply_async` with Django's ``on_commit()``."""
21 transaction.on_commit(functools.partial(self.apply_async, *args, **kwargs))

Callers 1

task_instanceMethod · 0.90

Calls

no outgoing calls

Tested by 1

task_instanceMethod · 0.72