Parcourir la source

utils.debug: Fixes memsample IndexError bug

Ask Solem il y a 12 ans
Parent
commit
894023a414
1 fichiers modifiés avec 4 ajouts et 1 suppressions
  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