Open
Description
Bug report
Bug description:
On Linux proc.wait()
does not return after proc.kill()
when there as sub/sub processes.
This only happens when the standard streams are piped, it looks like wait()
blocks until the pipes are closed.
import asyncio
import os
import time
async def main():
proc = await asyncio.create_subprocess_exec(
"/usr/bin/python3", "-c", "import os;os.system('sleep 20')",
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE)
time.sleep(1)
os.system("ps -f --forest --format pid,ppid,pgid,sid,comm")
print(f">> This python proces pid={os.getpid()} has a `python3` child process, which has a `sleep` child process.")
print(f">> Kill the `python3` child process pid={proc.pid}")
proc.kill()
os.system("ps -f --forest --format pid,ppid,pgid,sid,comm")
print(f">> The `python3` child process was killed, the `sleep` process gets orfaned.")
print(f">> Calling `proc.wait()` or `proc.communicate()` does not return until `sleep` process exits.")
await proc.wait()
asyncio.run(main())
I don't know if it's a documentation issue or a bug.
- It would be more intuitive that
proc.wait()
after aproc.kill()
returned when the process exited, and does not depend on other processes completion. - It would be more intuitive to use have the same behavior when standard streams are piped and when they are not.
CPython versions tested on:
3.11
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Projects
Status
Todo