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 Sep 18, 2020
1 parent 1edcfb7 commit 77d1082
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 @@ -1027,8 +1027,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 @@ -1050,23 +1050,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 @@ -633,15 +633,13 @@ 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))
deserialized_group = group.from_dict(serialized_group)
for ds_task in deserialized_group.tasks:
assert isinstance(ds_task, Signature)

@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 @@ -986,7 +984,6 @@ def test_from_dict_deep_deserialize(self):
assert isinstance(task, Signature)
assert isinstance(deserialized_chord.body, Signature)

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

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

0 comments on commit 77d1082

Please sign in to comment.