New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
concurrent.futures does not validate that max_workers is proper #65561
Comments
Due to some bad math on my side, I passed max_workers=0 to concurrent.futures.ThreadPoolExecutor. This didn't fail properly, but hanged. The same behaviour occurs in ProcessPoolExecutor, but this time it fails internally with something like this: Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "C:\Python34\lib\threading.py", line 869, in run
self._target(*self._args, **self._kwargs)
File "C:\Python34\lib\concurrent\futures\process.py", line 225, in _queue_management_worker
assert sentinels
AssertionError The attached patch checks that *max_workers* is <= 0 and raises ValueError if so. |
For instance, multiprocessing behaves like this: >>> multiprocessing.Pool(-1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\multiprocessing\context.py", line 118, in Pool
context=self.get_context())
File "C:\Python34\lib\multiprocessing\pool.py", line 157, in __init__
raise ValueError("Number of processes must be at least 1")
ValueError: Number of processes must be at least 1
>>> |
Attached patch with improvements suggested by Charles-François Natali. Thank you for the review. |
I confirm the bug. |
The patch looks good to me too. I'll commit it soon. |
New changeset 3024ad49f00e by Brian Quinlan in branch 'default': |
Committed, thanks for the fix! |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: