Skip to content

Commit

Permalink
fix: Ensure group tasks are deeply deserialised
Browse files Browse the repository at this point in the history
Fixes #6341
  • Loading branch information
maybe-sybr committed Oct 15, 2020
1 parent 7034adf commit cd979e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 9 additions & 1 deletion celery/canvas.py
Expand Up @@ -1047,8 +1047,16 @@ class group(Signature):

@classmethod
def from_dict(cls, d, app=None):
# We need to mutate the `kwargs` element in place to avoid confusing
# `freeze()` implementations which end up here and expect to be able to
# access elements from that dictionary later and refer to objects
# canonicalized here
orig_tasks = d["kwargs"]["tasks"]
d["kwargs"]["tasks"] = rebuilt_tasks = type(orig_tasks)((
maybe_signature(task, app=app) for task in orig_tasks
))
return _upgrade(
d, group(d['kwargs']['tasks'], app=app, **d['options']),
d, group(rebuilt_tasks, app=app, **d['options']),
)

def __init__(self, *tasks, **options):
Expand Down
3 changes: 0 additions & 3 deletions t/integration/test_canvas.py
Expand Up @@ -1133,23 +1133,20 @@ def test_rebuild_nested_chain_chord(self, manager):
)
sig.delay().get(timeout=TIMEOUT)

@pytest.mark.xfail(reason="#6341")
def test_rebuild_nested_group_chain(self, manager):
sig = chain(
tasks.return_nested_signature_group_chain.s(),
tasks.rebuild_signature.s()
)
sig.delay().get(timeout=TIMEOUT)

@pytest.mark.xfail(reason="#6341")
def test_rebuild_nested_group_group(self, manager):
sig = chain(
tasks.return_nested_signature_group_group.s(),
tasks.rebuild_signature.s()
)
sig.delay().get(timeout=TIMEOUT)

@pytest.mark.xfail(reason="#6341")
def test_rebuild_nested_group_chord(self, manager):
try:
manager.app.backend.ensure_chords_allowed()
Expand Down
4 changes: 0 additions & 4 deletions t/unit/tasks/test_canvas.py
Expand Up @@ -694,7 +694,6 @@ def test_from_dict(self):
x['args'] = None
assert group.from_dict(dict(x))

@pytest.mark.xfail(reason="#6341")
def test_from_dict_deep_deserialize(self):
original_group = group([self.add.s(1, 2)] * 42)
serialized_group = json.loads(json.dumps(original_group))
Expand All @@ -704,7 +703,6 @@ def test_from_dict_deep_deserialize(self):
for child_task in deserialized_group.tasks
)

@pytest.mark.xfail(reason="#6341")
def test_from_dict_deeper_deserialize(self):
inner_group = group([self.add.s(1, 2)] * 42)
outer_group = group([inner_group] * 42)
Expand Down Expand Up @@ -1112,7 +1110,6 @@ def test_from_dict_deep_deserialize(self, subtests):
with subtests.test(msg="Verify chord body is deserialized"):
assert isinstance(deserialized_chord.body, Signature)

@pytest.mark.xfail(reason="#6341")
def test_from_dict_deep_deserialize_group(self, subtests):
header = body = group([self.add.s(1, 2)] * 42)
original_chord = chord(header=header, body=body)
Expand All @@ -1139,7 +1136,6 @@ def test_from_dict_deep_deserialize_group(self, subtests):
for body_child_task in deserialized_chord.body.tasks
)

@pytest.mark.xfail(reason="#6341")
def test_from_dict_deeper_deserialize_group(self, subtests):
inner_group = group([self.add.s(1, 2)] * 42)
header = body = group([inner_group] * 42)
Expand Down

0 comments on commit cd979e8

Please sign in to comment.