From 1e48eb3b9bce45e596af16cf09930b1c239d7c9d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 18 Mar 2014 00:39:04 +0100 Subject: Issue #20910: Make tests more reliable, less dependent on time * Tolerate 10 seconds instead of 3 seconds for slow test * Faster test, use sleep of 100 ms instead of 1 sec * Replace a number of iterations with an explicit deadline for the timeout --- Lib/test/fork_wait.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Lib/test/fork_wait.py') diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py index 19b54ec736..8c7c3aac99 100644 --- a/Lib/test/fork_wait.py +++ b/Lib/test/fork_wait.py @@ -48,7 +48,12 @@ class ForkWait(unittest.TestCase): for i in range(NUM_THREADS): _thread.start_new(self.f, (i,)) - time.sleep(LONGSLEEP) + # busy-loop to wait for threads + deadline = time.monotonic() + 10.0 + while len(self.alive) < NUM_THREADS: + time.sleep(0.1) + if time.monotonic() <= deadline: + break a = sorted(self.alive.keys()) self.assertEqual(a, list(range(NUM_THREADS))) -- cgit v1.2.1