classification
Title: Unexpected behavior for 0 or negative processes in multiprocessing.pool()
Type: Stage:
Components: Library (Lib) Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: jaraco, jorgsk, martin.panter, python-dev, vstinner
Priority: normal Keywords: patch

Created on 2011-06-08 13:55 by jorgsk, last changed 2016-09-02 02:20 by jaraco. This issue is now closed.

Files
File name Uploaded Description Edit
multitest_pool.py jorgsk, 2011-06-08 13:55
multiprocessing_pool.patch vstinner, 2011-06-09 00:35 review
Messages (6)
msg137908 - (view) Author: Jorgen Skancke (jorgsk) Date: 2011-06-08 13:55
A normal way to start a multiprocessing-pool is like this:

Multiprocessing.Pool(processes=some_number).

However, if 'some_number' is 0 or negative, Python hangs and must be killed. I would expect an error message of the type: "Number of processes must be at least 1".

Attaching a script that reproduces this.

I struggled a bit with this for a program that uses cpu_count() - 4 to calculate 'some_number'. Guess what happens when the number of cores is 4 :) Even though the fix is easy (if some_number < 1), it would be nice to be warned about it.
msg137933 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-06-09 00:35
multiprocessing_pool.patch: raise a ValueError if processes is less than 1. A test should be added.
msg138735 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-06-20 15:55
New changeset 1f171dd21bdb by Victor Stinner in branch '3.2':
Issue #12285: multiprocessing.Pool() raises a ValueError if the number of
http://hg.python.org/cpython/rev/1f171dd21bdb

New changeset 1861683793d9 by Victor Stinner in branch 'default':
(merge 3.2) Issue #12285: multiprocessing.Pool() raises a ValueError if the
http://hg.python.org/cpython/rev/1861683793d9

New changeset 815263546757 by Victor Stinner in branch '2.7':
Issue #12285: multiprocessing.Pool() raises a ValueError if the number of
http://hg.python.org/cpython/rev/815263546757
msg274192 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-09-02 01:17
New changeset 941346104718 by Jason R. Coombs in branch '3.4':
Issue #12285: Add test capturing failure.
https://hg.python.org/cpython/rev/941346104718

New changeset 56c60b3d06fb by Jason R. Coombs in branch '3.4':
Issue #12285: Replace implementation of findall with implementation from Setuptools 7ce820d524db.
https://hg.python.org/cpython/rev/56c60b3d06fb

New changeset 13619a3e0737 by Jason R. Coombs in branch '3.4':
Issue #12285: Update NEWS
https://hg.python.org/cpython/rev/13619a3e0737

New changeset ade53661607a by Jason R. Coombs in branch '3.5':
Issue #12285: Merge with 3.4
https://hg.python.org/cpython/rev/ade53661607a
msg274194 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-09-02 02:03
Looks like that last lot was meant to reference Issue 12885
msg274198 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2016-09-02 02:20
Yep. Sorry for the misfile.
History
Date User Action Args
2016-09-02 02:20:26jaracosetnosy: + jaraco
messages: + msg274198
2016-09-02 02:03:33martin.pantersetnosy: + martin.panter
messages: + msg274194
2016-09-02 01:17:09python-devsetmessages: + msg274192
2011-06-20 15:56:45vstinnersetstatus: open -> closed
resolution: fixed
2011-06-20 15:55:42python-devsetnosy: + python-dev
messages: + msg138735
2011-06-09 00:35:44vstinnersetfiles: + multiprocessing_pool.patch
versions: + Python 2.7, Python 3.2, Python 3.3, - Python 2.6
nosy: + vstinner

messages: + msg137933

keywords: + patch
2011-06-08 13:55:28jorgskcreate