You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose PyMutex_IsLocked in the public C API #134009
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);
}
It's important to expose an API like PyMutex_IsLocked even if you expose some sort of assertion helper, because people want to use their own debugging/printing/logging libraries to handle this sort of failure.
Yeah, I just want to echo @hawkinsp comment. I think we should expose PyMutex_IsLocked() and document its intended purposes. I don't think we need to be overly concerned about people misusing it.
changed the title [-]Expose `PyMutex_IsLocked` in the public API for free-threading[/-][+]Expose `PyMutex_IsLocked` in the public API[/+]on May 15, 2025
Activity
ngoldbaum commentedon May 14, 2025
I ran into this when I was writing PyMutex bindings for PyO3 - it was very difficult to test the bindings because the
PyMutexAPI is so limited.ZeroIntensity commentedon May 14, 2025
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:
makslevental commentedon May 14, 2025
maybe something like
?
but not sure if this y'all's style (i came here from mlir...)
hawkinsp commentedon May 14, 2025
It's important to expose an API like
PyMutex_IsLockedeven if you expose some sort of assertion helper, because people want to use their own debugging/printing/logging libraries to handle this sort of failure.colesbury commentedon May 14, 2025
Yeah, I just want to echo @hawkinsp comment. I think we should expose
PyMutex_IsLocked()and document its intended purposes. I don't think we need to be overly concerned about people misusing it.colesbury commentedon May 14, 2025
We should also open a corresponding issue in the C API working group
[-]Expose `PyMutex_IsLocked` in the public API for free-threading[/-][+]Expose `PyMutex_IsLocked` in the public API[/+][-]Expose `PyMutex_IsLocked` in the public API[/-][+]Expose `PyMutex_IsLocked` in the public C API[/+]pythongh-134009: Expose `PyMutex_IsLocked` in the public C API
Merge branch 'main' into pythongh-134009-pymutex-is-locked
Merge branch 'main' into pythongh-134009-pymutex-is-locked
gh-134009: Expose `PyMutex_IsLocked` in the public C API (gh-134365)
pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (pytho…
pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (pytho…
pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (pytho…
[3.14] pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (…
[3.14] gh-134009: Expose `PyMutex_IsLocked` in the public C API (gh-1…
pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (pytho…
pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (pytho…
[3.14] pythongh-134009: Expose `PyMutex_IsLocked` in the public C API (…