]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-109401: Fix threading barrier test_default_timeout() (#109875)
authorVictor Stinner <vstinner@python.org>
Tue, 26 Sep 2023 00:07:12 +0000 (02:07 +0200)
committerGitHub <noreply@github.com>
Tue, 26 Sep 2023 00:07:12 +0000 (00:07 +0000)
Increase timeouts. Barrier default timeout should be long enough to
spawn 4 threads on a slow CI.

Lib/test/lock_tests.py

index a4f52cb20ad301694ec5e322e301d05d3a52380f..0890ec87afd1c6e7c0a3ce8f284e9c1593a4aee5 100644 (file)
@@ -1014,13 +1014,15 @@ class BarrierTests(BaseTestCase):
         """
         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)