Explorar o código

Adds Task.send_event for sending custom task events. Issue mher/flower#143

Ask Solem %!s(int64=11) %!d(string=hai) anos
pai
achega
695436f812
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      celery/app/task.py

+ 5 - 0
celery/app/task.py

@@ -769,6 +769,11 @@ class Task(object):
         from celery import xstarmap
         return xstarmap(self.s(), it, app=self.app)
 
+    def send_event(self, type_, **fields):
+        req = self.request
+        with self.app.events.default_dispatcher(hostname=req.hostname) as d:
+            return d.send(type_, uuid=req.id, **fields)
+
     def update_state(self, task_id=None, state=None, meta=None):
         """Update task state.