mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
Issue #21362: concurrent.futures does not validate that max_workers is proper
This commit is contained in:
parent
120e8edfb8
commit
20efceb757
4 changed files with 15 additions and 0 deletions
|
|
@ -334,6 +334,9 @@ class ProcessPoolExecutor(_base.Executor):
|
|||
if max_workers is None:
|
||||
self._max_workers = os.cpu_count() or 1
|
||||
else:
|
||||
if max_workers <= 0:
|
||||
raise ValueError("max_workers must be greater than 0")
|
||||
|
||||
self._max_workers = max_workers
|
||||
|
||||
# Make the call queue slightly larger than the number of processes to
|
||||
|
|
|
|||
|
|
@ -87,6 +87,9 @@ class ThreadPoolExecutor(_base.Executor):
|
|||
max_workers: The maximum number of threads that can be used to
|
||||
execute the given calls.
|
||||
"""
|
||||
if max_workers <= 0:
|
||||
raise ValueError("max_workers must be greater than 0")
|
||||
|
||||
self._max_workers = max_workers
|
||||
self._work_queue = queue.Queue()
|
||||
self._threads = set()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue