Bugfixes: Finalizing the interpreter might crash.

This commit is contained in:
Gunnar Beutner 2013-02-14 15:51:50 +01:00
parent d4afb4087d
commit 413f81c29d
2 changed files with 7 additions and 5 deletions

View File

@ -29,11 +29,11 @@ PythonInterpreter::PythonInterpreter(const PythonLanguage::Ptr& language, const
PyInterpreterState *interp = m_Language->GetMainThreadState()->interp; PyInterpreterState *interp = m_Language->GetMainThreadState()->interp;
m_ThreadState = PyThreadState_New(interp); m_ThreadState = PyThreadState_New(interp);
PyEval_ReleaseLock(); (void) PyThreadState_Swap(m_ThreadState);
PyEval_AcquireThread(m_ThreadState);
PyRun_SimpleString(script->GetCode().CStr()); PyRun_SimpleString(script->GetCode().CStr());
PyEval_ReleaseThread(m_ThreadState); (void) PyThreadState_Swap(m_Language->GetMainThreadState());
PyEval_ReleaseLock();
} }
PythonInterpreter::~PythonInterpreter(void) PythonInterpreter::~PythonInterpreter(void)

View File

@ -40,7 +40,9 @@ PythonLanguage::PythonLanguage(void)
PythonLanguage::~PythonLanguage(void) PythonLanguage::~PythonLanguage(void)
{ {
Py_Finalize(); /* Due to how we're destructing objects it might not be safe to
* call Py_Finalize() when the Icinga instance is being shut
* down - so don't bother calling it. */
} }
ScriptInterpreter::Ptr PythonLanguage::CreateInterpreter(const Script::Ptr& script) ScriptInterpreter::Ptr PythonLanguage::CreateInterpreter(const Script::Ptr& script)