Pārlūkot izejas kodu

utils.debug: Fixes memsample IndexError bug

Ask Solem 11 gadi atpakaļ
vecāks
revīzija
894023a414
1 mainītis faili ar 4 papildinājumiem un 1 dzēšanām
  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