From: rnv Date: Wed, 23 Dec 2015 09:24:58 +0000 (+0300) Subject: Add python GIL Ensure / Release. X-Git-Tag: V8_0_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a14009a6685fdbb64b471d128b0568e97603d8c;p=modules%2Fmed.git Add python GIL Ensure / Release. --- diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index a396313c0..7309619b3 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -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} diff --git a/src/MEDCalc/cmp/MEDPresentation.cxx b/src/MEDCalc/cmp/MEDPresentation.cxx index 66f3b879c..46ec07145 100644 --- a/src/MEDCalc/cmp/MEDPresentation.cxx +++ b/src/MEDCalc/cmp/MEDPresentation.cxx @@ -21,7 +21,6 @@ #include "MEDFactoryClient.hxx" #include "MEDPresentation.hxx" #include "MEDCouplingRefCountObject.hxx" -//#include #include 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