summaryrefslogtreecommitdiffstats
path: root/Modules/_testinternalcapi.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2023-11-08 22:39:29 (GMT)
committerGitHub <noreply@github.com>2023-11-08 22:39:29 (GMT)
commit31c90d5838e8d6e4c47d98500a34810ccb33a6d4 (patch)
tree5be595b11ca17cf1f1bd5875a69a04b927f10dff /Modules/_testinternalcapi.c
parent0b718e6407da65b838576a2459d630824ca62155 (diff)
downloadcpython-31c90d5838e8d6e4c47d98500a34810ccb33a6d4.zip
cpython-31c90d5838e8d6e4c47d98500a34810ccb33a6d4.tar.gz
cpython-31c90d5838e8d6e4c47d98500a34810ccb33a6d4.tar.bz2
gh-111569: Implement Python critical section API (gh-111571)
Critical sections are helpers to replace the global interpreter lock with finer grained locking. They provide similar guarantees to the GIL and avoid the deadlock risk that plain locking involves. Critical sections are implicitly ended whenever the GIL would be released. They are resumed when the GIL would be acquired. Nested critical sections behave as if the sections were interleaved.
Diffstat (limited to 'Modules/_testinternalcapi.c')
-rw-r--r--Modules/_testinternalcapi.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 7dba29a..604a59e 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -1687,6 +1687,9 @@ module_exec(PyObject *module)
if (_PyTestInternalCapi_Init_Set(module) < 0) {
return 1;
}
+ if (_PyTestInternalCapi_Init_CriticalSection(module) < 0) {
+ return 1;
+ }
if (PyModule_Add(module, "SIZEOF_PYGC_HEAD",
PyLong_FromSsize_t(sizeof(PyGC_Head))) < 0) {