Is it possible to deadlock a cython.pymutex by taking the GIL?
Cython has a built-in lock, called cython.pymutex. This lock is implemented using PyThread_type_lock() in Python 3.12, and PyMutex in Python 3.13+. The Cython documentation warns against acquiring the GIL while holding a pymutex. acquire will avoid deadlocks if the GIL is held (only relevant in non-freethreading versions of Python). However, you are at risk of deadlock if you attempt to acquire the GIL while holding a cython.pymutex lock. Be aware that it is also possible for Cython to acquire the GIL implicitly (for example by raising an exception) and this is also a deadlock risk. I read thi
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.