Skip to content

Commit 949057e

Browse files
authored
Update thread.py
1 parent 19404ba commit 949057e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ThreadPoolExecutorPlus/thread.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,10 @@ def __init__(self, max_workers=None, thread_name_prefix='',
212212
# Use this number because ThreadPoolExecutor is often
213213
# used to overlap I/O instead of CPU work.
214214
max_workers = DEFAULT_MAXIMUM_WORKER_NUM
215-
if max_workers <= self._min_workers:
216-
raise ValueError(f"max_workers must be greater than min_workers = {self._min_workers}")
215+
if max_workers < 1:
216+
raise ValueError(f"max_workers must be greater than min_workers , min_workers must be greater than 1")
217+
elif 1 <= max_workers < self._min_workers:
218+
self._min_workers = max_workers
217219

218220
if initializer is not None and not callable(initializer):
219221
raise TypeError("initializer must be a callable")
@@ -320,4 +322,4 @@ def shutdown(self, wait=True):
320322
if wait:
321323
for t in self._threads:
322324
t.join()
323-
shutdown.__doc__ = _base.Executor.shutdown.__doc__
325+
shutdown.__doc__ = _base.Executor.shutdown.__doc__

0 commit comments

Comments
 (0)