diff options
| author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-04 15:58:54 (GMT) |
|---|---|---|
| committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-03-04 15:58:54 (GMT) |
| commit | 3bc5cb7e0db13ba3885c8ed3d51ea792738499b2 (patch) | |
| tree | ff7a706875291920386bedeb1e5f5b6c1cd7df8d /Lib/test/test_multiprocessing.py | |
| parent | a36e245deb9068c09092a62104c8832302f7b684 (diff) | |
| download | cpython-3bc5cb7e0db13ba3885c8ed3d51ea792738499b2.zip cpython-3bc5cb7e0db13ba3885c8ed3d51ea792738499b2.tar.gz cpython-3bc5cb7e0db13ba3885c8ed3d51ea792738499b2.tar.bz2 | |
#7805: wait until all workers are started before collecting their PIDs
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
| -rw-r--r-- | Lib/test/test_multiprocessing.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 24366a7..6e585c1 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1070,8 +1070,16 @@ class _TestPoolWorkerLifetime(BaseTestCase): self.assertEqual(res.get(), sqr(j)) # Refill the pool p._repopulate_pool() - # Finally, check that the worker pids have changed + # Wait until all workers are alive + countdown = 5 + while countdown and not all(w.is_alive() for w in p._pool): + countdown -= 1 + time.sleep(DELTA) finalworkerpids = [w.pid for w in p._pool] + # All pids should be assigned. See issue #7805. + self.assertNotIn(None, origworkerpids) + self.assertNotIn(None, finalworkerpids) + # Finally, check that the worker pids have changed self.assertNotEqual(sorted(origworkerpids), sorted(finalworkerpids)) p.close() p.join() |
