Browse Source

Task: Do not raise retry exception when retry executed in eager mode. Partially fixes #2164

Ask Solem 10 years ago
parent
commit
6dcd2c3296
1 changed files with 9 additions and 6 deletions
  1. 9 6
      celery/app/task.py

+ 9 - 6
celery/app/task.py

@@ -574,15 +574,18 @@ class Task(object):
                 "Can't retry {0}[{1}] args:{2} kwargs:{3}".format(
                     self.name, request.id, S.args, S.kwargs))
 
-        # If task was executed eagerly using apply(),
-        # then the retry must also be executed eagerly.
+        ret = Retry(exc=exc, when=eta or countdown)
+
+        if is_eager:
+            # if task was executed eagerly using apply(),
+            # then the retry must also be executed eagerly.
+            S.apply().get()
+            return ret
+
         try:
-            S.apply().get() if is_eager else S.apply_async()
+            S.apply_async()
         except Exception as exc:
-            if is_eager:
-                raise
             raise Reject(exc, requeue=False)
-        ret = Retry(exc=exc, when=eta or countdown)
         if throw:
             raise ret
         return ret