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
Implement Python Critical Sections from PEP 703 #111569
PEP 703 introduces the concept of "Python Critical Sections", which are an abstraction to help replace the GIL with finer grained locking. The key ideas is to replace the GIL with per-object locks and implicitly release these locks in the same places where the GIL would have been released. The mechanism is:
Keep track of locked mutexes in a per-thread stack
These will be no-ops in the default build of CPython.
Note that if you need to operate on two objects at once, then you must use the Py_BEGIN_CRITICAL_SECTION2 macro. Nesting two calls to Py_BEGIN_CRITICAL_SECTION does not guarantee that both objects are locked because the inner calls may suspend the outer critical section.
At least at the start, even these "public" macros will still be internal-only (i.e., in Include/internal). I expect that we will eventually want to make them public so that C-API extensions can make use of them. ↩
Activity
pythongh-111569: Implement Python critical section API
gh-111569: Implement Python critical section API (gh-111571)
brettcannon commentedon Nov 9, 2023
The latest PR related to this change broke the WebAssembly buildbots by causing them to time out: https://buildbot.python.org/all/#/builders/1046/builds/3456/steps/11/logs/stdio .
pythongh-111569: Fix critical sections test on WebAssembly
gh-111569: Fix critical sections test on WebAssembly (GH-111897)
pythongh-111569: Implement Python critical section API (pythongh-111571)
pythongh-111569: Fix critical sections test on WebAssembly (pythonGH-…
pythongh-111569: Implement Python critical section API (pythongh-111571)
pythongh-111569: Fix critical sections test on WebAssembly (pythonGH-…