From 20efceb75790f2a40fad449fd92a6b3d8fe40c8b Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Sat, 17 May 2014 13:51:10 -0700 Subject: Issue #21362: concurrent.futures does not validate that max_workers is proper --- Lib/concurrent/futures/process.py | 3 +++ Lib/concurrent/futures/thread.py | 3 +++ 2 files changed, 6 insertions(+) (limited to 'Lib/concurrent') diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 07b5225d1d..12993901e3 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -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 diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py index f9beb0f7f7..8d6081cf15 100644 --- a/Lib/concurrent/futures/thread.py +++ b/Lib/concurrent/futures/thread.py @@ -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() -- cgit v1.2.1