From: Gunnar Beutner Date: Wed, 27 Mar 2013 06:27:44 +0000 (+0000) Subject: Python build fix. X-Git-Tag: v0.0.2~173 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9ded4a851c3fddafedc14cf2d7dfb312665bea7;p=icinga2 Python build fix. --- diff --git a/lib/python/pythoninterpreter.cpp b/lib/python/pythoninterpreter.cpp index 95b9b7457..8d311559a 100644 --- a/lib/python/pythoninterpreter.cpp +++ b/lib/python/pythoninterpreter.cpp @@ -74,8 +74,7 @@ void PythonInterpreter::UnregisterPythonFunction(const String& name) m_Functions.erase(name); } -void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& function, - const std::vector& arguments) +Value PythonInterpreter::ProcessCall(const String& function, const std::vector& arguments) { ObjectLock olock(this); @@ -120,11 +119,14 @@ void PythonInterpreter::ProcessCall(const ScriptTask::Ptr& task, const String& f Value vresult = PythonLanguage::MarshalFromPython(result); Py_DECREF(result); - task->FinishResult(vresult); + m_Language->SetCurrentInterpreter(interp); + PyEval_ReleaseThread(m_ThreadState); + + return vresult; } catch (...) { - task->FinishException(boost::current_exception()); - } + m_Language->SetCurrentInterpreter(interp); + PyEval_ReleaseThread(m_ThreadState); - m_Language->SetCurrentInterpreter(interp); - PyEval_ReleaseThread(m_ThreadState); + throw; + } } diff --git a/lib/python/pythoninterpreter.h b/lib/python/pythoninterpreter.h index 088877d7a..15a8956e3 100644 --- a/lib/python/pythoninterpreter.h +++ b/lib/python/pythoninterpreter.h @@ -49,8 +49,7 @@ protected: PyThreadState *m_ThreadState; std::map m_Functions; - virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function, - const std::vector& arguments); + virtual Value ProcessCall(const String& function, const std::vector& arguments); }; } diff --git a/lib/python/pythonlanguage.cpp b/lib/python/pythonlanguage.cpp index 21f813a62..6f952df4e 100644 --- a/lib/python/pythonlanguage.cpp +++ b/lib/python/pythonlanguage.cpp @@ -19,6 +19,7 @@ #include "python/pythonlanguage.h" #include "python/pythoninterpreter.h" +#include "base/scriptfunction.h" #include "base/dynamictype.h" #include "base/objectlock.h" #include "base/application.h" @@ -320,9 +321,7 @@ PyObject *PythonLanguage::PyCallNativeFunction(PyObject *self, PyObject *args) Value result; try { - ScriptTask::Ptr task = boost::make_shared(function, arguments); - task->Start(); - result = task->GetResult(); + result = function->Invoke(arguments); } catch (const std::exception& ex) { PyEval_RestoreThread(tstate);