-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Expose PyMutex_IsLocked
in the public C API
#134009
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
Comments
I ran into this when I was writing PyMutex bindings for PyO3 - it was very difficult to test the bindings because the |
Ideally, we should document that it's for use in assertions only. We need to make sure we're not enabling people to write thread-unsafe code like this: if (PyMutex_IsLocked(lock)) {
PyMutex_Unlock(lock);
} |
maybe something like #define ASSERT_PY_MUTEX_IS_LOCKED(mutex, msg) assert(PyMutex_IsLocked(mutex) && msg) ? but not sure if this y'all's style (i came here from mlir...) |
It's important to expose an API like |
Yeah, I just want to echo @hawkinsp comment. I think we should expose |
We should also open a corresponding issue in the C API working group |
PyMutex_IsLocked
in the public API for free-threadingPyMutex_IsLocked
in the public API
PyMutex_IsLocked
in the public APIPyMutex_IsLocked
in the public C API
Feature or enhancement
Proposal:
In my C extension, I wanted to write:
to verify that my own code is maintaining its own locking invariants.
PyMutex_IsLocked
exists, but is private:cpython/Include/internal/pycore_lock.h
Line 30 in 0afbd4e
Could we make it public and document it, please?
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response
The text was updated successfully, but these errors were encountered: