Skip to content

Commit

Permalink
Clarify delay_on_commit documentation doesn't return the task ID
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke committed Apr 27, 2024
1 parent 1a10133 commit e515a3c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/django/first-steps-with-django.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ This API takes care of wrapping the call into the `on_commit`_ hook for you.
In rare cases where you want to trigger a task without waiting, the existing
:meth:`~celery.app.task.Task.delay` API is still available.

One key difference compared to the ``delay`` method, is that ``delay_on_commit``
will NOT return the task ID back to the caller. The task is not sent to the broken
when you call the method, only when the Django transaction finishes. If you need the
task ID, best to stick to :meth:`~celery.app.task.Task.delay`.

This task class should be used automatically if you've follow the setup steps above.
However, if your app :ref:`uses a custom task base class <task-custom-classes>`,
you'll need inherit from :class:`~celery.contrib.django.task.DjangoTask` instead of
Expand Down

0 comments on commit e515a3c

Please sign in to comment.