Skip to content

Commit e9d8dc4

Browse files
committed
Merge branch '3.0'
Conflicts: celery/app/builtins.py
2 parents 8a5c41f + 7044d56 commit e9d8dc4

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

Changelog

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ If you're looking for versions prior to 3.x you should see :ref:`history`.
4545
- Pool now sets a ``current_process().index`` attribute that can be used to create
4646
as many log files as there are processes in the pool.
4747

48+
- Canvas: chord/group/chain no longer modifies the state when called
49+
50+
Previously calling a chord/group/chain would modify the ids of subtasks
51+
so that::
52+
53+
>>> c = chord([add.s(2, 2), add.s(4, 4)], xsum.s())
54+
>>> c()
55+
>>> c() <-- call again
56+
57+
at the second time the ids for the tasks would be the same as in the
58+
previous invocation. This is now fixed, so that calling a subtask
59+
won't mutate any options.
60+
61+
- Canvas: Chaining a chord to another task now works.
62+
4863
- Worker: Fixed a bug where the request stack could be corrupted if
4964
relative imports are used.
5065

@@ -53,9 +68,6 @@ If you're looking for versions prior to 3.x you should see :ref:`history`.
5368

5469
Fix contributed by Sam Cooke.
5570

56-
- ``subtask.clone`` now deepcopies options so that original subtask
57-
is not modified when used in chains/groups etc.
58-
5971
- Because of many bugs the fast local optimization has been disabled,
6072
and can only be enabled by setting the :envvar:`USE_FAST_LOCALS` attribute.
6173

celery/app/builtins.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ def prepare_steps(self, args, tasks):
213213
next_step = steps.popleft()
214214
except IndexError:
215215
next_step = None
216-
if next_step is not None:
217-
task = chord(task, body=next_step, task_id=tid)
216+
if next_step is not None:
217+
task = chord(task, body=next_step, task_id=tid)
218218
if prev_task:
219219
# link previous task to this task.
220220
prev_task.link(task)
@@ -276,8 +276,8 @@ def run(self, header, body, partial_args=(), interval=1,
276276
prepare_member = self._prepare_member
277277

278278
# - convert back to group if serialized
279-
if not isinstance(header, group):
280-
header = group([maybe_subtask(t) for t in header])
279+
tasks = header.tasks if isinstance(header, group) else header
280+
header = group([maybe_subtask(s).clone() for s in tasks])
281281
# - eager applies the group inline
282282
if eager:
283283
return header.apply(args=partial_args, task_id=group_id)

celery/canvas.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ def _unpack_args(header=None, body=None, **kwargs):
353353

354354
def __call__(self, body=None, **kwargs):
355355
_chord = self.Chord
356-
body = self.kwargs['body'] = body or self.kwargs['body']
356+
body = (body or self.kwargs['body']).clone()
357357
if _chord.app.conf.CELERY_ALWAYS_EAGER:
358358
return self.apply((), kwargs)
359359
callback_id = body.options.setdefault('task_id', uuid())
360-
_chord(**dict(self.kwargs, **kwargs))
360+
_chord(**dict(self.kwargs, body=body, **kwargs))
361361
return _chord.AsyncResult(callback_id)
362362

363363
def clone(self, *args, **kwargs):

0 commit comments

Comments
 (0)