-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
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
Conversation
proc.wait() | ||
try: | ||
proc.wait() | ||
except ProcessLookupError: |
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.
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 comment
The 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 comment
The 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.
sts = 0 | ||
return (pid, sts) | ||
|
||
raise ProcessLookupError(f'Process {self.pid} is already waited on externally') |
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.
BTW, thanks for the contribution! not all PRs make sense, getting eyeballs on issues that perhaps haven't had sufficient discussion and discussing what is actually needed is the larger benefit in such situations. :) (ie: don't feel bad that i'm closing your PR, it was helpful regardless - see the discussion on the issue, i think other PR opportunities exist for this one) |
Patch for the Issue: #96863