-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-144706: docs note about combining RLock and signal handlers #144736
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
Changes from 1 commit
fe1db59
57ce53f
21cc735
3684c03
e318c30
052972a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -840,6 +840,12 @@ the lock to an unlocked state and allows another thread blocked in | |
| must have a release in the thread that has acquired the lock. Failing to | ||
| call release as many times the lock has been acquired can lead to deadlock. | ||
|
|
||
| .. tip:: | ||
|
|
||
| Because lock acquisition can be interrupted by signals, sharing reentrant | ||
| locks between :mod:`signal` handlers and the main thread can lead to | ||
| surprising behavior. Therefore, this is generally not recommended. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
any other surprise that is not main thread waiting forever for itself to release
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
what is surprising about normal locks (like returned by
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think you're missing the point. It might work right now, but using locks in signal handlers is not something we want to encourage or claim to support. We may want to change how we handle signals or what they affect someday.
By acquiring a lock in a signal handler, the lock is subject to deadlocks for any signal handled by the main thread. For example:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Alright. In such case, I think this warning belongs into the |
||
|
|
||
|
|
||
| .. class:: RLock() | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.