You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
multiprocessing.Pool.imap(buffersize=...) deadlocks on close()/join() after partial consumption #155477
Using the new buffersize parameter of Pool.imap() (or imap_unordered())
and then calling the documented close()/join() after only partially
consuming the result deadlocks forever:
importmultiprocessingasmpdeff(x):
returnxif__name__=="__main__":
p=mp.Pool(2)
it=p.imap(f, range(1000), buffersize=2)
next(it) # consume one; the producer is now throttledp.close()
p.join() # hangs forever
terminate() works because it releases the buffersize semaphores; close()
does not, so the task-handler thread stays blocked in sema.acquire() inside _guarded_task_generation and join() waits on it. buffersize is new in
3.16 (gh-64192).
Activity
picnixz commentedon Aug 10, 2026
picnixz commentedon Aug 10, 2026
gh-155477: Fix multiprocessing.Pool deadlock on close() with a buffer…