From 949057e730bcb273d01a3fd9a53025c6df4fb4f9 Mon Sep 17 00:00:00 2001 From: GoodManWEN <44322449+GoodManWEN@users.noreply.github.com> Date: Tue, 29 Dec 2020 11:52:40 +0000 Subject: [PATCH] Update thread.py --- ThreadPoolExecutorPlus/thread.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ThreadPoolExecutorPlus/thread.py b/ThreadPoolExecutorPlus/thread.py index 7ce27be..e83bb02 100644 --- a/ThreadPoolExecutorPlus/thread.py +++ b/ThreadPoolExecutorPlus/thread.py @@ -212,8 +212,10 @@ def __init__(self, max_workers=None, thread_name_prefix='', # Use this number because ThreadPoolExecutor is often # used to overlap I/O instead of CPU work. max_workers = DEFAULT_MAXIMUM_WORKER_NUM - if max_workers <= self._min_workers: - raise ValueError(f"max_workers must be greater than min_workers = {self._min_workers}") + if max_workers < 1: + raise ValueError(f"max_workers must be greater than min_workers , min_workers must be greater than 1") + elif 1 <= max_workers < self._min_workers: + self._min_workers = max_workers if initializer is not None and not callable(initializer): raise TypeError("initializer must be a callable") @@ -320,4 +322,4 @@ def shutdown(self, wait=True): if wait: for t in self._threads: t.join() - shutdown.__doc__ = _base.Executor.shutdown.__doc__ \ No newline at end of file + shutdown.__doc__ = _base.Executor.shutdown.__doc__