Skip to content

Commit

Permalink
Update executor.py (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Jun 18, 2023
1 parent 1773c06 commit 66d05ca
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions dank_mids/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ def _worker(executor_reference, work_queue, initializer, initargs, timeout): #
executor = executor_reference() # NOTE: NEW

with executor._adjusting_lock: # NOTE: NEW
t = threading.current_thread() # NOTE: NEW
executor._threads.remove(t) # NOTE: NEW
thread._threads_queues.pop(t) # NOTE: NEW
# Let the executor know we have one less idle thread available
executor._idle_semaphore.acquire(blocking=False) # NOTE: NEW

return # NOTE: NEW
# NOTE: We keep a minimum of one thread active to prevent locks
if len(executor) > 1: # NOTE: NEW
t = threading.current_thread() # NOTE: NEW
executor._threads.remove(t) # NOTE: NEW
thread._threads_queues.pop(t) # NOTE: NEW
# Let the executor know we have one less idle thread available
executor._idle_semaphore.acquire(blocking=False) # NOTE: NEW
return # NOTE: NEW

if work_item is not None:
work_item.run()
Expand Down

0 comments on commit 66d05ca

Please sign in to comment.