diff --git a/src/mod/languages/mod_python/mod_python.c b/src/mod/languages/mod_python/mod_python.c index 1c5b1c05d6..1853ceb773 100644 --- a/src/mod/languages/mod_python/mod_python.c +++ b/src/mod/languages/mod_python/mod_python.c @@ -198,7 +198,10 @@ static void eval_some_python(const char *funcname, char *args, switch_core_sessi } if (tstate) { + // thread state must be cleared explicitly or we'll get memory leaks + PyThreadState_Clear(tstate); PyEval_ReleaseThread(tstate); + PyThreadState_Delete(tstate); } done: