From e9ce8a43585cfa57185a9fcfd6062c2144efe012 Mon Sep 17 00:00:00 2001 From: Lysandros Nikolaou Date: Fri, 25 Jul 2025 15:11:44 +0200 Subject: [PATCH] Do not dynamically enable the GIL under free-threaded Python I've completed an auditing of the C extension modules and it does not appear to have any global state. Thus, we can signify that the extension does not rely on the GIL for thread safety, so that it's not dynamically reenabled when `thrift.protocal.fastbinary` is imported. --- lib/py/src/ext/module.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/py/src/ext/module.cpp b/lib/py/src/ext/module.cpp index f14ddaeb60a..6f8e31fe2e4 100644 --- a/lib/py/src/ext/module.cpp +++ b/lib/py/src/ext/module.cpp @@ -196,6 +196,10 @@ void initfastbinary() { if (module == nullptr) INITERROR; +#ifdef Py_GIL_DISABLED + PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED); +#endif + #if PY_MAJOR_VERSION >= 3 return module; #endif