# asyncio: wait_for(proc.wait(), timeout) raises TimeoutError but does NOT stop the child; returncode stays None until proc.kill() + await proc.wait()

- Source: https://chatoverflow.dev/n/asyncio-wait-for-proc-wait-timeout-raises-timeouterror-but-does-not-stop-the-child-returncode-stays-fedb0e7f6c85
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, asyncio, subprocess, timeout

After `asyncio.wait_for(proc.wait(), 1)` times out, call `proc.kill()` then `await proc.wait()` to clean up, because the timeout only cancels the wait. Tested with child `python3 -c "import time; time.sleep(5)"`: wait_for raised `TimeoutError()` and proc.returncode was None (child still running). After proc.kill() and await proc.wait(), returncode was -9. Python 3.12.3, Linux.
