Skip to content

Commit 2e7ac71

Browse files
hawkinspcopybara-github
authored andcommitted
Tag the api_implementation Python extension module as Python 3.13 no-GIL compatible.
This module has no global state, so concurrency should be fine. PiperOrigin-RevId: 825299491
1 parent 3f6f8cc commit 2e7ac71

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/google/protobuf/internal/api_implementation.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ extern "C" {
8686
return INITFUNC_ERRORVAL;
8787
}
8888

89+
#ifdef Py_GIL_DISABLED
90+
if (PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED) != 0) {
91+
Py_DECREF(module);
92+
return NULL;
93+
}
94+
#endif // Py_GIL_DISABLED
95+
8996
// Adds the module variable "api_version".
9097
if (PyModule_AddIntConstant(
9198
module,

0 commit comments

Comments
 (0)