mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 13:37:56 +08:00
Add post_execute_in_worker signal (#309)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user