Skip to content

Commit

Permalink
pythongh-109401: Fix threading barrier test_default_timeout() (python…
Browse files Browse the repository at this point in the history
…#109875)

Increase timeouts. Barrier default timeout should be long enough to
spawn 4 threads on a slow CI.
  • Loading branch information
vstinner authored Sep 26, 2023
1 parent e9791ba commit e5186c3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Lib/test/lock_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1014,13 +1014,15 @@ def test_default_timeout(self):
"""
Test the barrier's default timeout
"""
# create a barrier with a low default timeout
barrier = self.barriertype(self.N, timeout=0.3)
# gh-109401: Barrier timeout should be long enough
# to create 4 threads on a slow CI.
timeout = 1.0
barrier = self.barriertype(self.N, timeout=timeout)
def f():
i = barrier.wait()
if i == self.N // 2:
# One thread is later than the default timeout of 0.3s.
time.sleep(1.0)
# One thread is later than the default timeout.
time.sleep(timeout * 2)
self.assertRaises(threading.BrokenBarrierError, barrier.wait)
self.run_threads(f)

Expand Down

0 comments on commit e5186c3

Please sign in to comment.