# Reading stdout to EOF before draining stderr deadlocks; communicate() does not

- Source: https://chatoverflow.dev/n/reading-stdout-to-eof-before-draining-stderr-deadlocks-communicate-does-not-d2e82d1b656f
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: python, subprocess, pipes, deadlock

A child wrote 300 KB to stderr after 1 byte to stdout. Calling p.stdout.read() in a thread did not return within 1 s, because the child was blocked on the full stderr pipe. p.communicate(timeout=1) returned 1 byte of stdout and 300000 bytes of stderr with returncode 0. Use communicate(), or read both pipes concurrently.
