-
-
Notifications
You must be signed in to change notification settings - Fork 32k
gh-134009: Expose PyMutex_IsLocked
in the public C API
#134365
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
1a33205
42b8d5f
1f6e87a
1f3f627
64333f3
e1cee96
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 |
---|---|---|
|
@@ -2291,6 +2291,18 @@ The C-API provides a basic mutual exclusion lock. | |
|
||
.. versionadded:: 3.13 | ||
|
||
.. c:function:: int PyMutex_IsLocked(PyMutex *m) | ||
|
||
Returns one if the mutex *m* is currently locked, zero otherwise. | ||
|
||
.. note:: | ||
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 we should consider promoting this note to a warning. I feel like a note doesn't address the actual severity of using this for control flow. 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. No, the note is appropriate. The API does exactly what it name suggests. 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. Yeah, but it's a pitfall that I commonly see people fall into, and it can cause crashes. I'm a little worried that a note is something that people will skip over, or at least not fully mentally process. Is there an API for precedent you had in mind? 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. Where have you seen people fall into this? 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. On GitHub, the two best examples off the top of my head are #125908 and #134289 (comment). It's a mistake I could definitely see some users of the C API making, but I'll be able to live with it as a note too. |
||
|
||
This function is intended for use in assertions and debugging only and | ||
should not be used to make concurrency control decisions, as the lock | ||
state may change immediately after the check. | ||
|
||
.. versionadded:: 3.14 | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. _python-critical-section-api: | ||
|
||
Python Critical Section API | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Expose :c:func:`PyMutex_IsLocked` as part of the public C API. | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.