Skip to content

Commit

Permalink
Fix chords with chained groups (#5947)
Browse files Browse the repository at this point in the history
  • Loading branch information
the-owl authored and auvipy committed Mar 2, 2020
1 parent 6892beb commit 01dd66c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions celery/canvas.py
Expand Up @@ -1366,6 +1366,8 @@ def _traverse_tasks(self, tasks, value=None):
task = stack.popleft()
if isinstance(task, group):
stack.extend(task.tasks)
elif isinstance(task, _chain) and isinstance(task.tasks[-1], group):
stack.extend(task.tasks[-1].tasks)
else:
yield task if value is None else value

Expand Down
7 changes: 7 additions & 0 deletions t/unit/tasks/test_canvas.py
Expand Up @@ -742,6 +742,13 @@ def test_app_fallback_to_current(self):
x = chord([t1], body=t1)
assert x.app is current_app

def test_chord_size_with_groups(self):
x = chord([
self.add.s(2, 2) | group([self.add.si(2, 2), self.add.si(2, 2)]),
self.add.s(2, 2) | group([self.add.si(2, 2), self.add.si(2, 2)]),
], body=self.add.si(2, 2))
assert x.__length_hint__() == 4

def test_set_immutable(self):
x = chord([Mock(name='t1'), Mock(name='t2')], app=self.app)
x.set_immutable(True)
Expand Down

0 comments on commit 01dd66c

Please sign in to comment.