Преглед на файлове

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

Ask Solem преди 10 години
родител
ревизия
b8be30a35d
променени са 1 файла, в които са добавени 9 реда и са изтрити 6 реда
  1. 9 6
      celery/app/task.py

+ 9 - 6
celery/app/task.py

@@ -664,15 +664,18 @@ class Task(object):
                 "Can't retry {0}[{1}] args:{2} kwargs:{3}".format(
                 "Can't retry {0}[{1}] args:{2} kwargs:{3}".format(
                     self.name, request.id, S.args, S.kwargs))
                     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:
         try:
-            S.apply().get() if is_eager else S.apply_async()
+            S.apply_async()
         except Exception as exc:
         except Exception as exc:
-            if is_eager:
-                raise
             raise Reject(exc, requeue=False)
             raise Reject(exc, requeue=False)
-        ret = Retry(exc=exc, when=eta or countdown)
         if throw:
         if throw:
             raise ret
             raise ret
         return ret
         return ret