]> granicus.if.org Git - icinga2/commitdiff
Python build fix.
authorGunnar Beutner <gunnar@beutner.name>
Wed, 27 Mar 2013 06:27:44 +0000 (06:27 +0000)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 27 Mar 2013 06:27:44 +0000 (06:27 +0000)
lib/python/pythoninterpreter.cpp
lib/python/pythoninterpreter.h
lib/python/pythonlanguage.cpp

index 95b9b7457387bba63d5f6c3dfcd5903b3ea6d6a6..8d311559ab0656235943643284fadde707ad4cd8 100644 (file)
@@ -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<Value>& arguments)
+Value PythonInterpreter::ProcessCall(const String& function, const std::vector<Value>& 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;
+       }
 }
index 088877d7ae290e8e9469af41d505769f434c7c51..15a8956e3d1409fb674f6daeb52bb79a41dfce28 100644 (file)
@@ -49,8 +49,7 @@ protected:
        PyThreadState *m_ThreadState;
        std::map<String, PyObject *> m_Functions;
 
-       virtual void ProcessCall(const ScriptTask::Ptr& task, const String& function,
-           const std::vector<Value>& arguments);
+       virtual Value ProcessCall(const String& function, const std::vector<Value>& arguments);
 };
 
 }
index 21f813a621c4895b682964ca27b9b2c03c8229ee..6f952df4e36ec100a23dd200988a6ad33332385e 100644 (file)
@@ -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<ScriptTask>(function, arguments);
-               task->Start();
-               result = task->GetResult();
+               result = function->Invoke(arguments);
        } catch (const std::exception& ex) {
                PyEval_RestoreThread(tstate);