Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.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 ourterms of service andprivacy 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 interruptthe main thread when Ctrl-C is pressed. Previously, we also waited onthe event from other threads, but ignored the result. However, this canrace with interpreter shutdown because the main thread closes the handlein `_PySignal_Fini` and threads may still be running and using mutexesduring interpreter shtudown.Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, likewe do in other places in the CPython codebase.
Manually verified that Ctrl-C still interrupts lock acquisitions on Windows. |
!buildbot Windows |
bedevere-bot commentedJun 3, 2025
🤖 New build scheduled with the buildbot fleet by@colesbury for commit7c7d96e 🤖 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. |
cc581f3
intopython:mainUh oh!
There was an error while loading.Please reload this page.
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 interruptthe main thread when Ctrl-C is pressed. Previously, we also waited onthe event from other threads, but ignored the result. However, this canrace with interpreter shutdown because the main thread closes the handlein `_PySignal_Fini` and threads may still be running and using mutexesduring interpreter shtudown.Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, likewe do in other places in the CPython codebase.(cherry picked from commitcc581f3)Co-authored-by: Sam Gross <colesbury@gmail.com>
GH-135116 is a backport of this pull request to the3.14 branch. |
…H-135100) (GH-135116)On Windows, the `_PyOS_SigintEvent()` event handle is used to interruptthe main thread when Ctrl-C is pressed. Previously, we also waited onthe event from other threads, but ignored the result. However, this canrace with interpreter shutdown because the main thread closes the handlein `_PySignal_Fini` and threads may still be running and using mutexesduring interpreter shtudown.Only use `_PyOS_SigintEvent()` in the main thread in parking_lot.c, likewe do in other places in the CPython codebase.(cherry picked from commitcc581f3)Co-authored-by: Sam Gross <colesbury@gmail.com>
Uh oh!
There was an error while loading.Please reload this page.
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