-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Use _winapi.WaitForMultipleObjects in Popen.wait() #72355
Comments
On Unix, waiting on an instance of subprocess.Popen in the main thread is interruptible by Ctrl+C. On Windows, it currently calls _winapi.WaitForSingleObject, which isn't interruptible. It should instead call _winapi.WaitForMultipleObjects, which automatically adds the SIGINT event object from _PyOS_SigintEvent() when called from the main thread. |
This patch makes the trivial change to the Popen.wait() method and also modifies _winapi.WaitForMultipleObjects to restart the wait if SIGINT is ignored or the handler didn't raise an exception. |
Hopefully this is my last change until someone reviews this. I decided to make it an error to pass an empty sequence, which previously would implicitly wait on the SIGINT event. This way simplifies the code and prevents someone from accidentally waiting forever on SIGINT when it's ignored or doesn't raise an exception. There should always be at least 1 other handle in the wait list. |
Oh nice, you implemented the PEP-475 for _winapi.WaitForMultipleObjects()! I missed this function when implementing this PEP :-) |
It makes sense since the original WaitForMultipleObjects() also requires at least one object: https://msdn.microsoft.com/en-us/library/windows/desktop/ms687025(v=vs.85).aspx nCount [in]
|
I'm no longer interested in solving the SIGINT event problem locally at the wait site. A common implementation of _Py_Sleep, _Py_WaitForSingleObject, and _Py_WaitForMultipleObjects is needed. _winapi.WaitForSingleObject would call _Py_WaitForSingleObject and automatically support the SIGINT event on the main thread. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: