Skip to content
Prev Previous commit
Next Next commit
reduce duration of test
  • Loading branch information
eendebakpt committed Jun 1, 2025
commit bb98c5213ed745303d7b6ce80ed2a678bf626a59
6 changes: 4 additions & 2 deletions Lib/test/test_free_threading/test_threading_iter_locked.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def __iter__(self):

def __next__(self):
a = next(self.it)
time.sleep(0)
t = time.perf_counter() + 1e-6
while time.perf_counter() < t:
pass
b = next(self.it)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add time.sleep(0) (or with small non-zero argument) or Event.wait() with a timeout to force or significantly increase the chance of concurrent access.

return a, b

Expand All @@ -31,7 +33,7 @@ class iter_lockedThreading(unittest.TestCase):
@threading_helper.reap_threads
def test_iter_locked(self):
number_of_threads = 10
number_of_iterations = 10
number_of_iterations = 8
barrier = Barrier(number_of_threads)
def work(it):
while True:
Expand Down
Loading