#include "SALOME_ModuleCatalog.hh"
#include "Basics_Utils.hxx"
#include "Basics_DirUtils.hxx"
+
+#include <pthread.h> // must be before Python.h !
#include "PythonCppUtils.hxx"
+
#include <sys/types.h>
#include <sys/stat.h>
#include <signal.h>
std::queue<std::string>& theScriptParameters)
{
std::string command;
-
+
+ // manage GIL
+ PyThreadState *_save = NULL;
+ PyThreadState *pts = PyGILState_GetThisThreadState();
+ if (!pts) {
+ _save = PyEval_SaveThread();
+ }
PyGILState_STATE gstate = PyGILState_Ensure();
PyObject* mod(PyImport_ImportModule(theScriptName.c_str()));
Py_XDECREF(mod);
}
}
-
+
PyGILState_Release(gstate);
+ if (_save) {
+ PyEval_RestoreThread(_save);
+ }
MESSAGE("Command from template is ... " << command << std::endl);
return command;