Skip to content

Commit

Permalink
Regen working on Python 2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed May 31, 2012
1 parent 0fba468 commit 4094ce8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions celery/app/builtins.py
Expand Up @@ -219,6 +219,8 @@ def run(self, header, body, interval=1, max_retries=None,
opts["chord"] = body
opts["taskset_id"] = setid
r.append(app.AsyncResult(tid))
if eager:
return header.apply(task_id=setid)
app.backend.on_chord_apply(setid, body,
interval=interval,
max_retries=max_retries,
Expand All @@ -238,9 +240,11 @@ def apply_async(self, args=(), kwargs={}, task_id=None, **options):
body_result.parent = parent
return body_result

def apply(self, args=(), kwargs={}, **options):
def apply(self, args=(), kwargs={}, propagate=True, **options):
body = kwargs["body"]
res = super(Chord, self).apply(args, kwargs, **options)
return maybe_subtask(body).apply(args=(res.get().join(), ))
res = super(Chord, self).apply(args, dict(kwargs, eager=True),
**options)
return maybe_subtask(body).apply(
args=(res.get(propagate=propagate).get().join(), ))

return Chord
2 changes: 1 addition & 1 deletion celery/canvas.py
Expand Up @@ -333,7 +333,7 @@ def __call__(self, body=None, **options):
_chord = self.Chord
self.kwargs["body"] = body or self.kwargs["body"]
if _chord.app.conf.CELERY_ALWAYS_EAGER:
return _chord.apply((), self.kwargs)
return self.apply((), {}, **options)
callback_id = body.options.setdefault("task_id", uuid())
_chord(**self.kwargs)
return _chord.AsyncResult(callback_id)
Expand Down
3 changes: 3 additions & 0 deletions celery/utils/functional.py
Expand Up @@ -256,6 +256,9 @@ def __init__(self, it):
def data(self):
return list(self.__it)

def __iter__(self): # needed for Python 2.5
return iter(self.data)


def regen(it):
if isinstance(it, (list, tuple)):
Expand Down

0 comments on commit 4094ce8

Please sign in to comment.