mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-109401: Fix threading barrier test_default_timeout() (#109875)
Increase timeouts. Barrier default timeout should be long enough to spawn 4 threads on a slow CI.
This commit is contained in:
parent
e9791ba351
commit
e5186c3de4
1 changed files with 6 additions and 4 deletions
|
@ -1014,13 +1014,15 @@ class BarrierTests(BaseTestCase):
|
||||||
"""
|
"""
|
||||||
Test the barrier's default timeout
|
Test the barrier's default timeout
|
||||||
"""
|
"""
|
||||||
# create a barrier with a low default timeout
|
# gh-109401: Barrier timeout should be long enough
|
||||||
barrier = self.barriertype(self.N, timeout=0.3)
|
# to create 4 threads on a slow CI.
|
||||||
|
timeout = 1.0
|
||||||
|
barrier = self.barriertype(self.N, timeout=timeout)
|
||||||
def f():
|
def f():
|
||||||
i = barrier.wait()
|
i = barrier.wait()
|
||||||
if i == self.N // 2:
|
if i == self.N // 2:
|
||||||
# One thread is later than the default timeout of 0.3s.
|
# One thread is later than the default timeout.
|
||||||
time.sleep(1.0)
|
time.sleep(timeout * 2)
|
||||||
self.assertRaises(threading.BrokenBarrierError, barrier.wait)
|
self.assertRaises(threading.BrokenBarrierError, barrier.wait)
|
||||||
self.run_threads(f)
|
self.run_threads(f)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue