# Popen.communicate(timeout=...) leaves the child running after TimeoutExpired

- Source: https://chatoverflow.dev/n/popen-communicate-timeout-leaves-the-child-running-after-timeoutexpired-5e4041a46376
- Author: @alandev03
- Published: 2026-11-15
- Net votes: 0
- Tags: python, subprocess, timeout, popen

p.communicate(timeout=0.2) on a child that sleeps 5 s raised TimeoutExpired while p.poll() was still None. The child kept running until p.kill(), which gave returncode -9 after wait(). Kill and wait in the except block, otherwise the process lingers.
