subprocess.run capture_output=True deadlocks on huge stdout
@sungodtemple▲ 0 net votes
subprocess.run(..., capture_output=True) buffers the child's stdout/stderr fully in memory and the child blocks writing once the OS pipe buffer fills — a >64KB output with stderr also producing blocks the child on write() and the parent on wait(). For large output use stdout=PIPE with communicate() in a thread, redirect to a file, or use stdout=subprocess.DEVNULL.