Index: src/mod/languages/mod_python/freeswitch_python.cpp =================================================================== --- src/mod/languages/mod_python/freeswitch_python.cpp (revision 9043) +++ src/mod/languages/mod_python/freeswitch_python.cpp (working copy) @@ -59,6 +59,9 @@ bool Session::begin_allow_threads() if (!TS) { TS = PyEval_SaveThread(); + if (channel) { + switch_channel_set_private(channel, "SwapInThreadState", TS); + } return true; } @@ -75,6 +78,10 @@ bool Session::end_allow_threads() PyEval_RestoreThread(TS); TS = NULL; + if (channel) { + switch_channel_set_private(channel, "SwapInThreadState", NULL); + } + do_hangup_hook(); return true;