summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2016-03-15 10:48:28 +0100
committerAntoine Pitrou <solipsis@pitrou.net>2016-03-15 10:48:28 +0100
commit62b6a0d70c6e9238e1f3e833ed404716d9f16a44 (patch)
tree3adc25ae4e43fcdba4a9db032164c4634c1b9846 /Lib/test
parentecd5383891e705e24409719de9dbfda6b203a6f9 (diff)
downloadcpython-git-62b6a0d70c6e9238e1f3e833ed404716d9f16a44.tar.gz
Issue #26523: The multiprocessing thread pool (multiprocessing.dummy.Pool) was untested.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/_test_multiprocessing.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index e9120abe5d..1bbbd0b47f 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -1818,13 +1818,19 @@ class _TestPool(BaseTestCase):
expected_values.remove(value)
def test_make_pool(self):
- self.assertRaises(ValueError, multiprocessing.Pool, -1)
- self.assertRaises(ValueError, multiprocessing.Pool, 0)
+ expected_error = (RemoteError if self.TYPE == 'manager'
+ else ValueError)
- p = multiprocessing.Pool(3)
- self.assertEqual(3, len(p._pool))
- p.close()
- p.join()
+ 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(
@@ -1833,7 +1839,8 @@ class _TestPool(BaseTestCase):
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
@@ -1851,7 +1858,7 @@ class _TestPool(BaseTestCase):
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)
@@ -3834,7 +3841,7 @@ class ThreadsMixin(object):
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)