Explorar el Código

Support for piping a subtask to a chain

This allows to do things like:
pipe = sometask.s() | someothertask.s()
new_pipe = mytask.s() | pipe
Steeve Morin hace 12 años
padre
commit
79d04e3de0
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      celery/canvas.py

+ 3 - 1
celery/canvas.py

@@ -166,7 +166,9 @@ class Signature(dict):
                     for link in maybe_list(self.options.get('link')) or []))))
 
     def __or__(self, other):
-        if isinstance(other, chain):
+        if not isinstance(self, chain) and isinstance(other, chain):
+            return chain((self,) + other.tasks)
+        elif isinstance(other, chain):
             return chain(*self.tasks + other.tasks)
         elif isinstance(other, Signature):
             if isinstance(self, chain):