Skip to content

Commit 796bbbc

Browse files
authored
Update thread.py
1 parent 2278dcf commit 796bbbc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ThreadPoolExecutorPlus/thread.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ def run(self):
103103
try:
104104
work_item = self._work_queue.get(block=True , timeout = self._keep_alive_time)
105105
except queue.Empty:
106-
if self._executor._free_thread_count > self._executor._min_workers:
107-
# Got lock problem here , may cause dead lock slightly chance , don't know how to fix it.
108-
self._executor._adjust_free_thread_count(-1)
109-
self._executor._remove_thread(self)
110-
break
111-
else:
112-
continue
106+
# Got lock problem here , may cause dead lock slightly chance , don't know how to fix it.
107+
with self._executor_free_thread_count_lock:
108+
if self._executor._free_thread_count > self._executor._min_workers:
109+
self._executor._free_thread_count -= 1
110+
break
111+
else:
112+
continue
113113

114114
if work_item is not None:
115115
self._executor._adjust_free_thread_count(-1)

0 commit comments

Comments
 (0)