Kaydet (Commit) 395dc58e authored tarafından Victor Stinner's avatar Victor Stinner

(merge 3.2) Issue #12285: multiprocessing.Pool() raises a ValueError if the

number of processes if negative or null.
......@@ -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')
......
......@@ -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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment