Selaa lähdekoodia

Tests passing

Ask Solem 12 vuotta sitten
vanhempi
commit
12be091134
2 muutettua tiedostoa jossa 14 lisäystä ja 11 poistoa
  1. 1 1
      celery/app/builtins.py
  2. 13 10
      celery/canvas.py

+ 1 - 1
celery/app/builtins.py

@@ -75,7 +75,7 @@ def add_unlock_chord_task(app):
     def unlock_chord(group_id, callback, interval=None, propagate=False,
             max_retries=None, result=None):
         if interval is None:
-            interval = self.default_retry_delay
+            interval = unlock_chord.default_retry_delay
         result = _res.GroupResult(group_id, map(_res.AsyncResult, result))
         j = result.join_native if result.supports_native_join else result.join
         if result.ready():

+ 13 - 10
celery/canvas.py

@@ -76,7 +76,7 @@ class Signature(dict):
     def from_dict(self, d):
         typ = d.get('subtask_type')
         if typ:
-            return self.TYPES[typ].from_dict(d)
+            return self.TYPES[typ].from_dict(kwdict(d))
         return Signature(d)
 
     def __init__(self, task=None, args=None, kwargs=None, options=None,
@@ -330,19 +330,22 @@ Signature.register_type(group)
 class chord(Signature):
     Chord = Chord
 
-    def __init__(self, header, body=None, **options):
-        kwargs = options.get('kwargs') or {}
-        Signature.__init__(self, 'celery.chord', (),
-                         dict(kwargs, header=_maybe_group(header),
-                                      body=maybe_subtask(body)), **options)
+    def __init__(self, header, body=None, task='celery.chord',
+            args=(), kwargs={}, **options):
+        Signature.__init__(self, task, args, dict(kwargs,
+            header=_maybe_group(header), body=maybe_subtask(body)), **options)
         self.subtask_type = 'chord'
 
     @classmethod
     def from_dict(self, d):
-        kwargs = d['kwargs']
-        header = kwargs.pop('header')
-        body = kwargs.pop('body', None)
-        return chord(header, body, **kwdict(d))
+        args, d['kwargs'] = self._unpack_args(**kwdict(d['kwargs']))
+        return self(*args, **kwdict(d))
+
+    @staticmethod
+    def _unpack_args(header=None, body=None, **kwargs):
+        # Python signatures are better at extracting keys from dicts
+        # than manually popping things off.
+        return (header, body), kwargs
 
     def __call__(self, body=None, **kwargs):
         _chord = self.Chord