summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2011-10-24 16:43:51 (GMT)
committerCharles-François Natali <neologix@free.fr>2011-10-24 16:43:51 (GMT)
commit46f990e58cb462bbf98fef88a3ba41ffa4a4e35d (patch)
tree5493080bcfbf94367a3186de82cbfa3f2f4e8ff6 /Lib/test/test_multiprocessing.py
parent22dabb6ffa5860ee08138c2f67b0406d566df5f4 (diff)
downloadcpython-46f990e58cb462bbf98fef88a3ba41ffa4a4e35d.zip
cpython-46f990e58cb462bbf98fef88a3ba41ffa4a4e35d.tar.gz
cpython-46f990e58cb462bbf98fef88a3ba41ffa4a4e35d.tar.bz2
Issue #10332: multiprocessing: fix a race condition when a Pool is closed
before all tasks have completed.
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 201fa98..14847d9 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1168,6 +1168,20 @@ class _TestPoolWorkerLifetime(BaseTestCase):
p.close()
p.join()
+ def test_pool_worker_lifetime_early_close(self):
+ # Issue #10332: closing a pool whose workers have limited lifetimes
+ # before all the tasks completed would make join() hang.
+ p = multiprocessing.Pool(3, maxtasksperchild=1)
+ results = []
+ for i in range(6):
+ results.append(p.apply_async(sqr, (i, 0.3)))
+ p.close()
+ p.join()
+ # check the results
+ for (j, res) in enumerate(results):
+ self.assertEqual(res.get(), sqr(j))
+
+
#
# Test that manager has expected number of shared objects left
#