Add post_execute_in_worker signal (#309)

This commit is contained in:
prollings
2025-12-11 02:54:14 +11:00
committed by GitHub
parent fd927087f1
commit b51575a4b0
4 changed files with 53 additions and 4 deletions

View File

@@ -32,8 +32,14 @@ executed by a worker. This signal provides two arguments:
After executing a task
""""""""""""""""""""""
The ``django_q.signals.post_execute`` signal is emitted after a task is
executed by a worker and processed by the monitor. It included the ``task`` dictionary with the result.
- The ``django_q.signals.post_execute_in_worker`` signal is emitted after a task
is executed by a worker and processed by the **worker**. It included the ``task``
dictionary with the result. Note that this signal is **emitted from, and handled
by, the worker process itself**, not the monitor, unlike the ``post_execute``
signal below.
- The ``django_q.signals.post_execute`` signal is emitted after a task is
executed by a worker and processed by the **monitor**. It included the ``task``
dictionary with the result.
Subscribing to a signal
@@ -56,6 +62,10 @@ signal::
@receiver(post_execute)
def my_post_execute_callback(sender, task, **kwargs):
print(f"Task {task['name']} was executed with result {task['result']}")
@receiver(post_execute_in_worker)
def my_post_execute_in_worker_callback(sender, func, task, **kwargs):
print(f"Task {task['name']} was executed with result {task['result']}")
@receiver(post_spawn)
def my_post_spawn_callback(sender, proc_name, **kwargs):