summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/multiprocessing/pool.py2
-rw-r--r--Lib/test/test_multiprocessing.py3
2 files changed, 5 insertions, 0 deletions
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 92170f2..e450319 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -148,6 +148,8 @@ class Pool(object):
processes = cpu_count()
except NotImplementedError:
processes = 1
+ if processes < 1:
+ raise ValueError("Number of processes must be at least 1")
if initializer is not None and not hasattr(initializer, '__call__'):
raise TypeError('initializer must be a callable')
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 85094cc..b752d8d 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1138,6 +1138,9 @@ class _TestPool(BaseTestCase):
self.assertEqual(sorted(it), list(map(sqr, list(range(1000)))))
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()