Module: kamailio Branch: master Commit: c81b2b3383c5900aba83672da024c812d8e6d89d URL: https://github.com/kamailio/kamailio/commit/c81b2b3383c5900aba83672da024c812...
Author: S-P Chan shihping.chan@gmail.com Committer: S-P Chan shihping.chan@gmail.com Date: 2024-10-19T10:15:34+08:00
app_python3s: initial support for free-threading Python
* build the modules as free-threading compatible if free-threading Python is detected * can be gated by -DKSR_PYTHON_DISABLE_FREETHREADING
---
Modified: src/modules/app_python3s/apy3s_kemi.c
---
Diff: https://github.com/kamailio/kamailio/commit/c81b2b3383c5900aba83672da024c812... Patch: https://github.com/kamailio/kamailio/commit/c81b2b3383c5900aba83672da024c812...
---
diff --git a/src/modules/app_python3s/apy3s_kemi.c b/src/modules/app_python3s/apy3s_kemi.c index 38c67b9e1d5..0fb7879ef6b 100644 --- a/src/modules/app_python3s/apy3s_kemi.c +++ b/src/modules/app_python3s/apy3s_kemi.c @@ -746,6 +746,11 @@ static PyObject *init_KSR(void) /* special sub-modules - x.modf() can have variable number of params */ _sr_apy_ksr_modules_list[m] = PyModule_Create(&KSR_x_moduledef); PyModule_AddObject(_sr_apy_ksr_module, "x", _sr_apy_ksr_modules_list[m]); +#if defined(Py_GIL_DISABLED) && !defined(KSR_PYTHON_DISABLE_FREETHREADING) +#warning Python Free Threading build + PyUnstable_Module_SetGIL(_sr_apy_ksr_module, Py_MOD_GIL_NOT_USED); + PyUnstable_Module_SetGIL(_sr_apy_ksr_modules_list[m], Py_MOD_GIL_NOT_USED); +#endif Py_INCREF(_sr_apy_ksr_modules_list[m]); m++;
@@ -781,6 +786,11 @@ static PyObject *init_KSR(void) mmodule->m_size = -1;
_sr_apy_ksr_modules_list[m] = PyModule_Create(mmodule); +#if defined(Py_GIL_DISABLED) && !defined(KSR_PYTHON_DISABLE_FREETHREADING) +#warning Python Free Threading build + PyUnstable_Module_SetGIL( + _sr_apy_ksr_modules_list[m], Py_MOD_GIL_NOT_USED); +#endif PyModule_AddObject(_sr_apy_ksr_module, emods[k].kexp[0].mname.s, _sr_apy_ksr_modules_list[m]); Py_INCREF(_sr_apy_ksr_modules_list[m]);