-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Bug report
Bug description:
I am trying to run a subprocess shell command using asyncio.create_subprocess_shell() and then kill it after some amount of time.
When the command contains a pipe, then the subprocess is impossible to kill from within python. It can still be killed from the outside obviously (e.g. the kill command).
Here is a code that exhibits this behaviour:
import asyncio
async def test():
proc = await asyncio.create_subprocess_shell("yes | while read l; do sleep 1; echo $l; done")
await asyncio.sleep(1)
proc.kill()
await proc.wait()
asyncio.run(test())
A similar command, without a pipe, can be killed, for example: "while true; do sleep 1; echo test; done"
CPython versions tested on:
3.11
Operating systems tested on:
Linux