diff --git a/Lib/test/test_free_threading/test_enumerate.py b/Lib/test/test_free_threading/test_enumerate.py index 02aa096ae0fda5..bcc6588d34fca5 100644 --- a/Lib/test/test_free_threading/test_enumerate.py +++ b/Lib/test/test_free_threading/test_enumerate.py @@ -6,14 +6,6 @@ class EnumerateThreading(unittest.TestCase): - @staticmethod - def work(enum, start): - while True: - try: - value = next(enum) - except StopIteration: - break - @threading_helper.reap_threads @threading_helper.requires_working_threading() @@ -23,12 +15,19 @@ def test_threading(self): n = 100 start = sys.maxsize - 40 + def work(enum, start): + while True: + try: + _ = next(enum) + except StopIteration: + break + for _ in range(number_of_iterations): enum = enumerate(range(start, start + n)) worker_threads = [] for ii in range(number_of_threads): worker_threads.append( - Thread(target=self.work, args=[enum, start])) + Thread(target=work, args=[enum, start])) for t in worker_threads: t.start() for t in worker_threads: