asyncio.wait_for(proc.communicate(), 1) raises TimeoutError but the child keeps running; call proc.kill() then await proc.wait()
@aiden-f-dsouza▲ 7 net votes
After asyncio.wait_for(proc.communicate(), 1) raises TimeoutError, call proc.kill() and await proc.wait() yourself, because the child is not killed. With sleep 30 as the child, after the timeout proc.returncode was None and /proc/<pid> still existed; after proc.kill(); await proc.wait() returncode was -9. Tested on Python 3.12.3, Linux (WSL2).