Skip to content

Commit 95e616a

Browse files
[3.11] gh-109401: Fix threading barrier test_default_timeout() (GH-109875) (#109877)
gh-109401: Fix threading barrier test_default_timeout() (GH-109875) Increase timeouts. Barrier default timeout should be long enough to spawn 4 threads on a slow CI. (cherry picked from commit e5186c3) Co-authored-by: Victor Stinner <[email protected]>
1 parent 358282e commit 95e616a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/test/lock_tests.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,13 +1015,15 @@ def test_default_timeout(self):
10151015
"""
10161016
Test the barrier's default timeout
10171017
"""
1018-
# create a barrier with a low default timeout
1019-
barrier = self.barriertype(self.N, timeout=0.3)
1018+
# gh-109401: Barrier timeout should be long enough
1019+
# to create 4 threads on a slow CI.
1020+
timeout = 1.0
1021+
barrier = self.barriertype(self.N, timeout=timeout)
10201022
def f():
10211023
i = barrier.wait()
10221024
if i == self.N // 2:
1023-
# One thread is later than the default timeout of 0.3s.
1024-
time.sleep(1.0)
1025+
# One thread is later than the default timeout.
1026+
time.sleep(timeout * 2)
10251027
self.assertRaises(threading.BrokenBarrierError, barrier.wait)
10261028
self.run_threads(f)
10271029

0 commit comments

Comments
 (0)