[Python-checkins] r78653 - in python/trunk/Lib: multiprocessing/process.py test/test_multiprocessing.py
florent.xicluna
python-checkins at python.org
Thu Mar 4 16:58:54 CET 2010
Author: florent.xicluna
Date: Thu Mar 4 16:58:54 2010
New Revision: 78653
Log:
#7805: wait until all workers are started before collecting their PIDs
Modified:
python/trunk/Lib/multiprocessing/process.py
python/trunk/Lib/test/test_multiprocessing.py
Modified: python/trunk/Lib/multiprocessing/process.py
==============================================================================
--- python/trunk/Lib/multiprocessing/process.py (original)
+++ python/trunk/Lib/multiprocessing/process.py Thu Mar 4 16:58:54 2010
@@ -179,7 +179,7 @@
@property
def ident(self):
'''
- Return indentifier (PID) of process or `None` if it has yet to start
+ Return identifier (PID) of process or `None` if it has yet to start
'''
if self is _current_process:
return os.getpid()
Modified: python/trunk/Lib/test/test_multiprocessing.py
==============================================================================
--- python/trunk/Lib/test/test_multiprocessing.py (original)
+++ python/trunk/Lib/test/test_multiprocessing.py Thu Mar 4 16:58:54 2010
@@ -1070,8 +1070,16 @@
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()
More information about the Python-checkins
mailing list