-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-135099: Only wait on _PyOS_SigintEvent()
in main thread
#135100
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
On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase.
Manually verified that Ctrl-C still interrupts lock acquisitions on Windows. |
!buildbot Windows |
🤖 New build scheduled with the buildbot fleet by @colesbury for commit 7c7d96e 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F135100%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
Thank you! The Windows buildbots look very happy with this change. |
Thanks @colesbury for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14. |
…ythonGH-135100) On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase. (cherry picked from commit cc581f3) Co-authored-by: Sam Gross <colesbury@gmail.com>
GH-135116 is a backport of this pull request to the 3.14 branch. |
…H-135100) (GH-135116) On Windows, the `_PyOS_SigintEvent()` event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in `_PySignal_Fini` and threads may still be running and using mutexes during interpreter shtudown. Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, like we do in other places in the CPython codebase. (cherry picked from commit cc581f3) Co-authored-by: Sam Gross <colesbury@gmail.com>
On Windows, the
_PyOS_SigintEvent()
event handle is used to interrupt the main thread when Ctrl-C is pressed. Previously, we also waited on the event from other threads, but ignored the result. However, this can race with interpreter shutdown because the main thread closes the handle in_PySignal_Fini
and threads may still be running and using mutexes during interpreter shtudown.Only use
_PyOS_SigintEvent()
in the main thread in parking_lot.c, like we do in other places in the CPython codebase.PyMutex
failure inparking_lot.c
on Windows during interpreter shutdown #135099