-
-
Notifications
You must be signed in to change notification settings - Fork 34.1k
Closed
Labels
topic-C-APItopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
The critical section API is useful for making C API extensions thread-safe when the GIL is disabled. Compared to plain mutexes, the API makes it easier to avoid deadlocks, especially when interacting with the Python C API, where calls like Py_DECREF() may invoke destructors that themselves acquire locks.
A more detailed description and motivation is in PEP 703: https://peps.python.org/pep-0703/#python-critical-sections
The underlying implementation is hooked into Python's PyThreadState management, so it would not be practical to implement this API outside of CPython.
C-API WG Issue
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
topic-C-APItopic-free-threadingtype-featureA feature request or enhancementA feature request or enhancement