summaryrefslogtreecommitdiff
path: root/Lib/test/fork_wait.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-03-18 00:39:04 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-03-18 00:39:04 +0100
commit1e48eb3b9bce45e596af16cf09930b1c239d7c9d (patch)
tree5d0ba195e5272626240aa7355fd850da8c188bdd /Lib/test/fork_wait.py
parentf8cbf78bbdd88daeb47ee07cd3f26bb83efe7b8e (diff)
downloadcpython-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.py7
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)))