8000 Make `ctrl-c` interrupt `threading.Lock.acquire()` on Windows · Issue #125541 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Make ctrl-c interrupt threading.Lock.acquire() on Windows #125541

New issue

Have 8000 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

Closed
colesbury opened this issue Oct 15, 2024 · 2 comments
Closed

Make ctrl-c interrupt threading.Lock.acquire() on Windows #125541

colesbury opened this issue Oct 15, 2024 · 2 comments
Labels
OS-windows type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor
colesbury commented Oct 15, 2024

Feature or enhancement

Since Python 3.2, pressing ctrl-c (SIGINT) interrupts threading.Lock.acquire() on POSIX platforms, including Linux and macOS. However, this does not work on Windows.

Now that threading.Lock and threading.RLock use PyMutex and _PyRecursiveMutex internally, this should be a lot easier to implement efficiently.

See also #125058

cc @pitrou @zooba @gpshead

Linked PRs

@colesbury colesbury added type-feature A feature request or enhancement OS-windows labels Oct 15, 2024
@pitrou
Copy link
Member
pitrou commented Oct 15, 2024

You mean here

wait = WaitForSingleObjectEx(sema->platform_sem, millis, FALSE);
?

@colesbury
Copy link
Contributor Author

Yes, we can use WaitForMultipleObjectsEx() with _PyOS_SigintEvent() there without performance implications because that is the slow path that's only taken if the thread is about to block.

colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
colesbury added a commit to colesbury/cpython that referenced this issue Oct 15, 2024
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-windows type-feature A feature request or enhancement
Projects
Development

No branches or pull requests

2 participants
0