-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
gh-96863: Fix subprocess.Popen.wait to raise ProcessLookupError for external waits #137804
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
Changes from all commits
ea5a376
d8af14f
cb8d874
a542c71
f77e2ea
327f904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -607,7 +607,12 @@ async def kill_running(): | |
|
||
# kill the process (but asyncio is not notified immediately) | ||
proc.kill() | ||
proc.wait() | ||
try: | ||
proc.wait() | ||
except ProcessLookupError: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you like to use https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertRaises if it is always happened? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I’ll use assertRaises here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems it’s not always raised, so I’ll revert to using a try–except block on cb8d874. |
||
# Process already exited, which is expected but not always | ||
# raised | ||
pass | ||
|
||
proc.kill = mock.Mock() | ||
proc_returncode = proc.poll() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Fix :meth:`subprocess.Popen.wait` returning zero always when process already | ||
waited on externally. Now raises :exc:`ProcessLookupError` instead of losing | ||
exit status. Preserves ``SIGCHLD=SIG_IGN`` compatibility. |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gpshead I think that we should specify status code rather than raise exception because it will change current behavior. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callers do not expect wait() to raise an exception when the process has died by default because our behavior has been not to raise. Often callers don't even care about the exit code. As seen in the tests that had to be updated due to this proposed change. I'm sure people have written code that calls wait multiple times as well, expecting later calls to be no-ops. We don't want to break that.
I'll reply further on the issue. I do not think we want this feature.