Browse Source

Also pass args groups in one-level chains

Ask Solem 12 years ago
parent
commit
9ec61279eb
2 changed files with 10 additions and 2 deletions
  1. 4 1
      celery/app/builtins.py
  2. 6 1
      celery/canvas.py

+ 4 - 1
celery/app/builtins.py

@@ -185,7 +185,7 @@ def add_group_task(app):
 
 @shared_task
 def add_chain_task(app):
-    from celery.canvas import chord, group, maybe_subtask
+    from celery.canvas import Signature, chord, group, maybe_subtask
     _app = app
 
     class Chain(app.Task):
@@ -209,6 +209,9 @@ def add_chain_task(app):
                     # automatically upgrade group(..) | s to chord(group, s)
                     try:
                         next_step = steps.popleft()
+                        # for chords we freeze by pretending it's a normal
+                        # task instead of a group.
+                        res = Signature._freeze(task)
                         task = chord(task, body=next_step, task_id=res.task_id)
                     except IndexError:
                         pass

+ 6 - 1
celery/canvas.py

@@ -322,7 +322,12 @@ class group(Signature):
 
     @classmethod
     def from_dict(self, d):
-        return group(d['kwargs']['tasks'], **kwdict(d['options']))
+        tasks = d['kwargs']['tasks']
+        if d['args'] and tasks:
+            # partial args passed on to all tasks in the group (Issue #1057).
+            for task in tasks:
+                task['args'] = d['args'] + task['args']
+        return group(tasks, **kwdict(d['options']))
 
     def __call__(self, *partial_args, **options):
         tasks, result, gid, args = self.type.prepare(options,