]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Add python GIL Ensure / Release.
authorrnv <rnv@opencascade.com>
Wed, 23 Dec 2015 09:24:58 +0000 (12:24 +0300)
committerrnv <rnv@opencascade.com>
Wed, 23 Dec 2015 09:24:58 +0000 (12:24 +0300)
src/MEDCalc/cmp/CMakeLists.txt
src/MEDCalc/cmp/MEDPresentation.cxx

index a396313c06e870844e890590fdeb2a61cde3fdb7..7309619b31b35d90e483d27caf378144fd93d88c 100644 (file)
@@ -54,7 +54,7 @@ SET(COMMON_LIBS
   SalomeIDLMED
   ${KERNEL_TOOLSDS} ${KERNEL_SalomeDS} ${KERNEL_SalomeHDFPersist} ${KERNEL_SalomeContainer} ${KERNEL_SalomeCommunication}
   ${KERNEL_SalomeKernelHelpers} ${KERNEL_SalomeLifeCycleCORBA} ${KERNEL_SALOMELocalTrace} ${KERNEL_SALOMEBasics}
-  ${KERNEL_SalomeGenericObj} ${GUI_PyInterp}
+  ${KERNEL_SalomeGenericObj}
   ${MEDFILE_C_LIBRARIES}
   ${HDF5_LIBRARIES}
   ${OMNIORB_LIBRARIES}
index 66f3b879c7bbc0dda3f61832f42721072f6197e6..46ec07145585a4620d58a1214a1dba77ed0e7164 100644 (file)
@@ -21,7 +21,6 @@
 #include "MEDFactoryClient.hxx"
 #include "MEDPresentation.hxx"
 #include "MEDCouplingRefCountObject.hxx"
-//#include <PyInterp_Utils.h>
 #include <iostream>
 
 MEDPresentation::MEDPresentation(MEDCALC::FieldHandler* fieldHdl, std::string name)
@@ -115,24 +114,23 @@ void MEDPresentationScalarMap::internalGeneratePipeline()
   fileName = fileName.substr(7, fileName.size());
   std::cout << "\tfileName: " <<  fileName << std::endl;
 
-  {  // PyLock protected section
-    //PyLockWrapper lock;
+  PyGILState_STATE _gil_state = PyGILState_Ensure();
 
-    PyRun_SimpleString("print 'hello world'");
-    std::string cmd = std::string(
+  PyRun_SimpleString("print 'hello world'");
+  std::string cmd = std::string(
         "import pvsimple as pvs;"
         "__obj1 = pvs.MEDReader(FileName='") + fileName + std::string("');"
         "__disp1 = pvs.Show(__obj1);"
         "pvs.ColorBy(__disp1, ('") + fieldType + std::string("', '") + fieldName + std::string("'));"
         "pvs.GetActiveViewOrCreate('RenderView').ResetCamera()");
 
-    std::cerr << "Python command:" << std::endl;
-    std::cerr << cmd << std::endl;
-    PyRun_SimpleString(cmd.c_str());
-    // Retrieve Python object for internal storage:
-    PyObject * obj = getPythonObjectFromMain("__obj1");
-    PyObject * disp = getPythonObjectFromMain("__disp1");
-    pushInternal(obj, disp);
-  }
+  std::cerr << "Python command:" << std::endl;
+  std::cerr << cmd << std::endl;
+  PyRun_SimpleString(cmd.c_str());
+  // Retrieve Python object for internal storage:
+  PyObject * obj = getPythonObjectFromMain("__obj1");
+  PyObject * disp = getPythonObjectFromMain("__disp1");
+  pushInternal(obj, disp);
 
-}
+  PyGILState_Release(_gil_state);
+}
\ No newline at end of file