Explorar o código

utils.debug: Fixes memsample IndexError bug

Ask Solem %!s(int64=11) %!d(string=hai) anos
pai
achega
894023a414
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      celery/utils/debug.py

+ 4 - 1
celery/utils/debug.py

@@ -117,7 +117,10 @@ def sample(x, n, k=0):
     """
     j = len(x) // n
     for _ in range(n):
-        yield x[k]
+        try:
+            yield x[k]
+        except IndexError:
+            break
         k += j