Browse Source

Added signal: task_sent, triggered when a task has been sent to the broker.

Ask Solem 15 years ago
parent
commit
b3a468ef60
2 changed files with 33 additions and 0 deletions
  1. 3 0
      celery/messaging.py
  2. 30 0
      celery/signals.py

+ 3 - 0
celery/messaging.py

@@ -5,6 +5,7 @@ Sending and Receiving Messages
 """
 from carrot.messaging import Publisher, Consumer, ConsumerSet
 from celery import conf
+from celery import signals
 from celery.utils import gen_unique_id
 from celery.utils import mitemgetter
 from celery.serialization import pickle
@@ -58,6 +59,8 @@ class TaskPublisher(Publisher):
             message_data["taskset"] = part_of_set
 
         self.send(message_data, **extract_msg_options(kwargs))
+        signals.task_sent.send(sender=task_name, **message_data)
+
         return task_id
 
 

+ 30 - 0
celery/signals.py

@@ -1,8 +1,38 @@
 from django.dispatch import Signal
 
+"""
+
+.. DATA: task_sent
+
+Triggered when a task has been sent to the broker.
+
+Provides arguments:
+
+* task_id
+    Id of the task to be executed.
+
+* task
+    The task being executed.
+
+* args
+    the tasks positional arguments.
+
+* kwargs
+    The tasks keyword arguments.
+
+* eta
+    The time to execute the task.
+
+* taskset
+    Id of the taskset this task is part of (if any).
+
 
 """
+task_sent = Signal(providing_args=[
+                        "task_id", "task", "args", "kwargs", "eta",
+                        "taskset"])
 
+"""
 .. DATA: task_prerun
 
 Triggered before a task is executed.