[Python-checkins] cpython (merge 3.5 -> default): Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool) was
antoine.pitrou
python-checkins at python.org
Tue Mar 15 05:56:05 EDT 2016
https://hg.python.org/cpython/rev/131f92510164
changeset: 100542:131f92510164
parent: 100540:1d72402c1c91
parent: 100541:4cabf12b7fc6
user: Antoine Pitrou <solipsis at pitrou.net>
date: Tue Mar 15 10:52:51 2016 +0100
summary:
Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool) was untested.
files:
Lib/test/_test_multiprocessing.py | 27 +++++++++++-------
Misc/NEWS | 3 ++
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1822,13 +1822,19 @@
expected_values.remove(value)
def test_make_pool(self):
- self.assertRaises(ValueError, multiprocessing.Pool, -1)
- self.assertRaises(ValueError, multiprocessing.Pool, 0)
-
- p = multiprocessing.Pool(3)
- self.assertEqual(3, len(p._pool))
- p.close()
- p.join()
+ expected_error = (RemoteError if self.TYPE == 'manager'
+ else ValueError)
+
+ self.assertRaises(expected_error, self.Pool, -1)
+ self.assertRaises(expected_error, self.Pool, 0)
+
+ if self.TYPE != 'manager':
+ p = self.Pool(3)
+ try:
+ self.assertEqual(3, len(p._pool))
+ finally:
+ p.close()
+ p.join()
def test_terminate(self):
result = self.pool.map_async(
@@ -1837,7 +1843,8 @@
self.pool.terminate()
join = TimingWrapper(self.pool.join)
join()
- self.assertLess(join.elapsed, 0.5)
+ # Sanity check the pool didn't wait for all tasks to finish
+ self.assertLess(join.elapsed, 2.0)
def test_empty_iterable(self):
# See Issue 12157
@@ -1855,7 +1862,7 @@
if self.TYPE == 'processes':
L = list(range(10))
expected = [sqr(i) for i in L]
- with multiprocessing.Pool(2) as p:
+ with self.Pool(2) as p:
r = p.map_async(sqr, L)
self.assertEqual(r.get(), expected)
self.assertRaises(ValueError, p.map_async, sqr, L)
@@ -3858,7 +3865,7 @@
connection = multiprocessing.dummy.connection
current_process = staticmethod(multiprocessing.dummy.current_process)
active_children = staticmethod(multiprocessing.dummy.active_children)
- Pool = staticmethod(multiprocessing.Pool)
+ Pool = staticmethod(multiprocessing.dummy.Pool)
Pipe = staticmethod(multiprocessing.dummy.Pipe)
Queue = staticmethod(multiprocessing.dummy.Queue)
JoinableQueue = staticmethod(multiprocessing.dummy.JoinableQueue)
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -803,6 +803,9 @@
Tests
-----
+- Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool)
+ was untested.
+
- Issue #26015: Added new tests for pickling iterators of mutable sequences.
- Issue #26325: Added test.support.check_no_resource_warning() to check that
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list