Skip to content

Commit

Permalink
fix: race condition in pruning thread pool
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler committed Nov 14, 2024
1 parent 76db6ae commit e171658
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion a_sync/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ def _worker(

with executor._adjusting_lock: # NOTE: NEW
# NOTE: We keep a minimum of one thread active to prevent locks
if len(executor) > 1: # NOTE: NEW
if len(executor) > 1 or executor._idle_semaphore.acquire(
blocking=False
): # NOTE: NEW
t = threading.current_thread() # NOTE: NEW
executor._threads.remove(t) # NOTE: NEW
thread._threads_queues.pop(t) # NOTE: NEW
Expand Down

0 comments on commit e171658

Please sign in to comment.