Browse Source

unlock_chord task should raise Retry

Ask Solem 11 years ago
parent
commit
a3e6fb3360
2 changed files with 14 additions and 8 deletions
  1. 2 2
      celery/app/builtins.py
  2. 12 6
      celery/tests/tasks/test_chord.py

+ 2 - 2
celery/app/builtins.py

@@ -118,8 +118,8 @@ def add_unlock_chord_task(app):
                         exc=ChordError('Callback error: {0!r}'.format(exc)),
                     )
         else:
-            return unlock_chord.retry(countdown=interval,
-                                      max_retries=max_retries)
+            raise unlock_chord.retry(countdown=interval,
+                                     max_retries=max_retries)
     return unlock_chord
 
 

+ 12 - 6
celery/tests/tasks/test_chord.py

@@ -5,7 +5,7 @@ from contextlib import contextmanager
 from celery import group
 from celery import canvas
 from celery import result
-from celery.exceptions import ChordError
+from celery.exceptions import ChordError, Retry
 from celery.five import range
 from celery.result import AsyncResult, GroupResult, EagerResult
 from celery.tests.case import AppCase, Mock
@@ -54,6 +54,7 @@ class TSRNoReport(TSR):
 def patch_unlock_retry(app):
     unlock = app.tasks['celery.chord_unlock']
     retry = Mock()
+    retry.return_value = Retry()
     prev, unlock.retry = unlock.retry, retry
     try:
         yield unlock, retry
@@ -148,11 +149,16 @@ class test_unlock_chord_task(ChordCase):
                     setup(callback)
                 try:
                     assert self.app.tasks['celery.chord_unlock'] is unlock
-                    unlock(
-                        'group_id', callback_s,
-                        result=[self.app.AsyncResult(r) for r in ['1', 2, 3]],
-                        GroupResult=ResultCls, **kwargs
-                    )
+                    try:
+                        unlock(
+                            'group_id', callback_s,
+                            result=[
+                                self.app.AsyncResult(r) for r in ['1', 2, 3]
+                            ],
+                            GroupResult=ResultCls, **kwargs
+                        )
+                    except Retry:
+                        pass
                 finally:
                     canvas.maybe_signature = subtask
                 yield callback_s, retry, fail_current