|
|
@@ -249,7 +249,7 @@ def clone(self, args=(), kwargs={}, **opts): |
|
|
partial = clone
|
|
|
|
|
|
def freeze(self, _id=None, group_id=None, chord=None,
|
|
|
root_id=None, parent_id=None):
|
|
|
root_id=None, parent_id=None, group_index=None):
|
|
|
"""Finalize the signature by adding a concrete task id.
|
|
|
|
|
|
The task won't be called and you shouldn't call the signature
|
|
|
@@ -276,6 +276,8 @@ def freeze(self, _id=None, group_id=None, chord=None, |
|
|
opts['group_id'] = group_id
|
|
|
if chord:
|
|
|
opts['chord'] = chord
|
|
|
if group_index is not None:
|
|
|
opts['group_index'] = group_index
|
|
|
# pylint: disable=too-many-function-args
|
|
|
# Borks on this, as it's a property.
|
|
|
return self.AsyncResult(tid)
|
|
|
@@ -585,19 +587,21 @@ def run(self, args=(), kwargs={}, group_id=None, chord=None, |
|
|
return results[0]
|
|
|
|
|
|
def freeze(self, _id=None, group_id=None, chord=None,
|
|
|
root_id=None, parent_id=None):
|
|
|
root_id=None, parent_id=None, group_index=None):
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
# XXX chord is also a class in outer scope.
|
|
|
_, results = self._frozen = self.prepare_steps(
|
|
|
self.args, self.kwargs, self.tasks, root_id, parent_id, None,
|
|
|
self.app, _id, group_id, chord, clone=False,
|
|
|
group_index=group_index,
|
|
|
)
|
|
|
return results[0]
|
|
|
|
|
|
def prepare_steps(self, args, kwargs, tasks,
|
|
|
root_id=None, parent_id=None, link_error=None, app=None,
|
|
|
last_task_id=None, group_id=None, chord_body=None,
|
|
|
clone=True, from_dict=Signature.from_dict):
|
|
|
clone=True, from_dict=Signature.from_dict,
|
|
|
group_index=None):
|
|
|
app = app or self.app
|
|
|
# use chain message field for protocol 2 and later.
|
|
|
# this avoids pickle blowing the stack on the recursion
|
|
|
@@ -664,6 +668,7 @@ def prepare_steps(self, args, kwargs, tasks, |
|
|
res = task.freeze(
|
|
|
last_task_id,
|
|
|
root_id=root_id, group_id=group_id, chord=chord_body,
|
|
|
group_index=group_index,
|
|
|
)
|
|
|
else:
|
|
|
res = task.freeze(root_id=root_id)
|
|
|
@@ -1073,7 +1078,7 @@ def _freeze_gid(self, options): |
|
|
return options, group_id, options.get('root_id')
|
|
|
|
|
|
def freeze(self, _id=None, group_id=None, chord=None,
|
|
|
root_id=None, parent_id=None):
|
|
|
root_id=None, parent_id=None, group_index=None):
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
# XXX chord is also a class in outer scope.
|
|
|
opts = self.options
|
|
|
@@ -1085,6 +1090,8 @@ def freeze(self, _id=None, group_id=None, chord=None, |
|
|
opts['group_id'] = group_id
|
|
|
if chord:
|
|
|
opts['chord'] = chord
|
|
|
if group_index is not None:
|
|
|
opts['group_index'] = group_index
|
|
|
root_id = opts.setdefault('root_id', root_id)
|
|
|
parent_id = opts.setdefault('parent_id', parent_id)
|
|
|
new_tasks = []
|
|
|
@@ -1104,6 +1111,7 @@ def _freeze_unroll(self, new_tasks, group_id, chord, root_id, parent_id): |
|
|
# pylint: disable=redefined-outer-name
|
|
|
# XXX chord is also a class in outer scope.
|
|
|
stack = deque(self.tasks)
|
|
|
i = 0
|
|
|
while stack:
|
|
|
task = maybe_signature(stack.popleft(), app=self._app).clone()
|
|
|
if isinstance(task, group):
|
|
|
@@ -1112,7 +1120,9 @@ def _freeze_unroll(self, new_tasks, group_id, chord, root_id, parent_id): |
|
|
new_tasks.append(task)
|
|
|
yield task.freeze(group_id=group_id,
|
|
|
chord=chord, root_id=root_id,
|
|
|
parent_id=parent_id)
|
|
|
parent_id=parent_id,
|
|
|
group_index=i)
|
|
|
i += 1
|
|
|
|
|
|
def __repr__(self):
|
|
|
if self.tasks:
|
|
|
@@ -1189,14 +1199,15 @@ def __call__(self, body=None, **options): |
|
|
return self.apply_async((), {'body': body} if body else {}, **options)
|
|
|
|
|
|
def freeze(self, _id=None, group_id=None, chord=None,
|
|
|
root_id=None, parent_id=None):
|
|
|
root_id=None, parent_id=None, group_index=None):
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
# XXX chord is also a class in outer scope.
|
|
|
if not isinstance(self.tasks, group):
|
|
|
self.tasks = group(self.tasks, app=self.app)
|
|
|
header_result = self.tasks.freeze(
|
|
|
parent_id=parent_id, root_id=root_id, chord=self.body)
|
|
|
bodyres = self.body.freeze(_id, root_id=root_id)
|
|
|
bodyres = self.body.freeze(
|
|
|
_id, root_id=root_id, group_index=group_index)
|
|
|
# we need to link the body result back to the group result,
|
|
|
# but the body may actually be a chain,
|
|
|
# so find the first result without a parent
|
|
|
|
0 comments on commit
026c813