File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -228,7 +228,11 @@ def weakref_cb(_, q=self._work_queue):
228228 # TODO(bquinlan): Should avoid creating new threads if there are more
229229 # idle threads than items in the work queue.
230230 num_threads = len (self ._threads )
231- if self ._free_thread_count < self ._min_workers and num_threads < self ._max_workers :
231+
232+ with self ._free_thread_count_lock :
233+ _tflag = True if self ._free_thread_count < self ._min_workers else False
234+
235+ if _tflag and num_threads < self ._max_workers :
232236 thread_name = '%s_%d' % (self ._thread_name_prefix or self ,
233237 num_threads )
234238 t = _CustomThread (name = thread_name ,
@@ -272,4 +276,4 @@ def shutdown(self, wait=True):
272276 if wait :
273277 for t in self ._threads :
274278 t .join ()
275- shutdown .__doc__ = _base .Executor .shutdown .__doc__
279+ shutdown .__doc__ = _base .Executor .shutdown .__doc__
You can’t perform that action at this time.
0 commit comments