mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-15 21:47:53 +08:00
Compare commits
1 Commits
v1.7.3
...
post-spawn
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35bea76ec3 |
@@ -13,6 +13,12 @@ Before enqueuing a task
|
|||||||
The ``django_q.signals.pre_enqueue`` signal is emitted before a task is
|
The ``django_q.signals.pre_enqueue`` signal is emitted before a task is
|
||||||
enqueued. The task dictionary is given as the ``task`` argument.
|
enqueued. The task dictionary is given as the ``task`` argument.
|
||||||
|
|
||||||
|
After spawning a worker process
|
||||||
|
"""""""""""""""""""""""""""""""
|
||||||
|
|
||||||
|
The ``django_q.signals.post_spawn`` signal is emitted after a worker process has
|
||||||
|
spawned. The process name is given as the ``proc_name`` argument (string).
|
||||||
|
|
||||||
Before executing a task
|
Before executing a task
|
||||||
"""""""""""""""""""""""
|
"""""""""""""""""""""""
|
||||||
|
|
||||||
@@ -37,7 +43,7 @@ Connecting to a Django Q2 signal is done the same as any other Django
|
|||||||
signal::
|
signal::
|
||||||
|
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django_q.signals import pre_enqueue, pre_execute, post_execute
|
from django_q.signals import pre_enqueue, pre_execute, post_execute, post_spawn
|
||||||
|
|
||||||
@receiver(pre_enqueue)
|
@receiver(pre_enqueue)
|
||||||
def my_pre_enqueue_callback(sender, task, **kwargs):
|
def my_pre_enqueue_callback(sender, task, **kwargs):
|
||||||
@@ -51,4 +57,8 @@ signal::
|
|||||||
def my_post_execute_callback(sender, task, **kwargs):
|
def my_post_execute_callback(sender, task, **kwargs):
|
||||||
print(f"Task {task['name']} was executed with result {task['result']}")
|
print(f"Task {task['name']} was executed with result {task['result']}")
|
||||||
|
|
||||||
|
@receiver(post_spawn)
|
||||||
|
def my_post_spawn_callback(sender, proc_name, **kwargs):
|
||||||
|
print(f"Process {proc_name} has spawned")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user