-
-
Notifications
You must be signed in to change notification settings - Fork 31.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asyncio proc.kill()
and proc.wait()
are counter intuitive
#119710
Comments
It's a surprising feature. communicate() waits until stdout (and stderr) is closed. If a child process spawns "sleep 20", the "sleep 20" inherits stdout and keeps it open for 20 seconds. Maybe you should create a new process group and kill the whole process group, rather than only killing the "parent" process (parent of "sleep 20"). See the start_new_session parameter of subprocess.Popen and then use That's what I did in test.libregrtest to make sure that CTRL+C kills immediately all processes, and not only direct child processes. |
Indeed the process groups can help, if the child process does not create
another process group. But that is another story.
Here my point is that we should clarify The documentation ton avoid any
surprise. The same behavior applies to proc.wait().
For the record, the crurent documentation says "Wait for child process to
terminate" which looks missleading to me.
|
wait() and communicate() are very different. |
Indeed. This issue is about proc.wait() documentation. I updated the code snippet to male it clearer. |
I really consider this a pretty bad bug. It is absolutely impossible to wait for the executed process. I specifically wanted to wait for the launched process and not the pipe to be closed. Unfortunately, with the current API that is pretty much impossible. There is not even a Considering we have the mess, maybe one could:
|
Bug report
Bug description:
On Linux
proc.wait()
does not return afterproc.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.I don't know if it's a documentation issue or a bug.
proc.wait()
after aproc.kill()
returned when the process exited, and does not depend on other processes completion.CPython versions tested on:
3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: