Forráskód Böngészése

Built-in tasks may not have a default request

Ask Solem 12 éve
szülő
commit
e3ef8411a6
1 módosított fájl, 3 hozzáadás és 2 törlés
  1. 3 2
      celery/task/trace.py

+ 3 - 2
celery/task/trace.py

@@ -392,8 +392,9 @@ def _install_stack_protection():
         _patched['BaseTask.__call__'] = orig = BaseTask.__call__
 
         def __protected_call__(self, *args, **kwargs):
-            req, stack = self.request, self.request_stack
-            if not req._protected and len(stack) == 2 and \
+            stack = self.request_stack
+            req = stack.top
+            if req and not req._protected and len(stack) == 2 and \
                     not req.called_directly:
                 req._protected = 1
                 return self.run(*args, **kwargs)