Salome HOME
Protect python calls with GIL
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Apr 2016 11:54:32 +0000 (13:54 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Apr 2016 11:54:32 +0000 (13:54 +0200)
src/evalyfx/YACSEvalSession.cxx

index b4f1e2a5bf0fbc3cdb41084962f8ba2ecbc5d7e8..d28f8eb0b289b1e1a1c746021f4173fc732843d9 100644 (file)
@@ -21,6 +21,7 @@
 #include "YACSEvalSession.hxx"
 #include "YACSEvalSessionInternal.hxx"
 
+#include "AutoGIL.hxx"
 #include "Exception.hxx"
 
 #include <Python.h>
@@ -34,12 +35,16 @@ YACSEvalSession::YACSEvalSession():_isLaunched(false),_port(-1),_salomeInstanceM
   if(!Py_IsInitialized())
     Py_Initialize();
   //
-  _salomeInstanceModule=PyImport_ImportModule(const_cast<char *>("salome_instance"));
+  {
+    YACS::ENGINE::AutoGIL gal;
+    _salomeInstanceModule=PyImport_ImportModule(const_cast<char *>("salome_instance"));
+  }
 }
 
 YACSEvalSession::~YACSEvalSession()
 {
   delete _internal;
+  YACS::ENGINE::AutoGIL gal;
   if(isLaunched())
     {
       PyObject *terminateSession(PyObject_GetAttrString(_salomeInstance,const_cast<char *>("stop")));//new
@@ -55,6 +60,7 @@ void YACSEvalSession::launch()
 {
   if(isLaunched())
     return ;
+  YACS::ENGINE::AutoGIL gal;
   PyObject *salomeInstance(PyObject_GetAttrString(_salomeInstanceModule,const_cast<char *>("SalomeInstance")));//new
   PyObject *startMeth(PyObject_GetAttrString(salomeInstance,const_cast<char *>("start")));
   Py_XDECREF(salomeInstance);
@@ -103,6 +109,7 @@ std::string YACSEvalSession::getCorbaConfigFileName() const
 std::string YACSEvalSession::GetPathToAdd()
 {
   std::string ret;
+  YACS::ENGINE::AutoGIL gal;
   PyObject *osPy(PyImport_ImportModule(const_cast<char *>("os")));//new
   PyObject *kernelRootDir(0);// os.environ["KERNEL_ROOT_DIR"]
   {