Explorar o código

Fixes infinite recursion when logger_isa receives patched logger object

Ask Solem %!s(int64=10) %!d(string=hai) anos
pai
achega
8914e1f64f
Modificáronse 1 ficheiros con 6 adicións e 2 borrados
  1. 6 2
      celery/utils/log.py

+ 6 - 2
celery/utils/log.py

@@ -78,9 +78,9 @@ def in_sighandler():
         set_in_sighandler(False)
 
 
-def logger_isa(l, p):
+def logger_isa(l, p, max=1000):
     this, seen = l, set()
-    while this:
+    for _ in range(max):
         if this == p:
             return True
         else:
@@ -90,6 +90,10 @@ def logger_isa(l, p):
                 )
             seen.add(this)
             this = this.parent
+            if not this:
+                break
+    else:
+        raise RuntimeError('Logger hierarchy exceeds {0}'.format(max))
     return False