diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-03-18 00:39:04 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-03-18 00:39:04 +0100 |
commit | 1e48eb3b9bce45e596af16cf09930b1c239d7c9d (patch) | |
tree | 5d0ba195e5272626240aa7355fd850da8c188bdd /Lib/test/fork_wait.py | |
parent | f8cbf78bbdd88daeb47ee07cd3f26bb83efe7b8e (diff) | |
download | cpython-git-1e48eb3b9bce45e596af16cf09930b1c239d7c9d.tar.gz |
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
Diffstat (limited to 'Lib/test/fork_wait.py')
-rw-r--r-- | Lib/test/fork_wait.py | 7 |
1 files changed, 6 insertions, 1 deletions
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))) |