Skip to content

Instantly share code, notes, and snippets.

@gthomas
Created March 21, 2012 20:52
Show Gist options
  • Save gthomas/2152752 to your computer and use it in GitHub Desktop.
Save gthomas/2152752 to your computer and use it in GitHub Desktop.
eager chords
diff --git a/celery/app/registry.py b/celery/app/registry.py
index 43d65f6..2789547 100644
--- a/celery/app/registry.py
+++ b/celery/app/registry.py
@@ -61,7 +61,7 @@ class TaskRegistry(dict):
def filter_types(self, type):
return dict((name, task) for name, task in self.iteritems()
- if task.type == type)
+ if getattr(task, 'type', "regular") == type)
def _unpickle_task(name):
diff --git a/celery/task/chords.py b/celery/task/chords.py
index 1870b0a..3b522f7 100644
--- a/celery/task/chords.py
+++ b/celery/task/chords.py
@@ -13,7 +13,7 @@ from __future__ import absolute_import
from .. import current_app
from ..utils import uuid
-
+from ..task.sets import subtask
class chord(object):
Chord = None
@@ -25,6 +25,9 @@ class chord(object):
def __call__(self, body, **options):
tid = body.options.setdefault("task_id", uuid())
- self.Chord.apply_async((list(self.tasks), body), self.options,
+ taskset_result = self.Chord.apply_async((list(self.tasks), body), self.options,
**options)
+ if self.Chord.app.conf.CELERY_ALWAYS_EAGER:
+ return subtask(body).apply(args=(taskset_result.result.join(),))
+
return body.type.AsyncResult(tid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment