From: Sergey BELASH Date: Mon, 17 Nov 2014 14:43:00 +0000 (+0300) Subject: Proper handling of Python's GIL by SWIG X-Git-Tag: V_0.7.0_rc1~57^2~3^2~14 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2c57385fd92d41daeef4b987269545c5e6a579f;p=modules%2Fshaper.git Proper handling of Python's GIL by SWIG --- diff --git a/src/Config/Config_ModuleReader.cpp b/src/Config/Config_ModuleReader.cpp index 5fec456ad..83b16f27d 100644 --- a/src/Config/Config_ModuleReader.cpp +++ b/src/Config/Config_ModuleReader.cpp @@ -14,6 +14,7 @@ #include #include +// Have to be included before std headers #include //Necessary for cerr @@ -134,13 +135,9 @@ void Config_ModuleReader::loadPlugin(const std::string thePluginName) void Config_ModuleReader::loadScript(const std::string theFileName) { std::string aPythonFile = theFileName + ".py"; - PyGILState_STATE gstate; - /* aquire python thread */ - gstate = PyGILState_Ensure(); - + PyGILState_STATE gstate = PyGILState_Ensure(); PyObject* module = PyImport_ImportModule(aPythonFile.c_str()); - /* release python thread */ PyGILState_Release(gstate); } diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index c49ab5a06..9ee8694c8 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -58,7 +58,7 @@ SET(PROJECT_LIBRARIES ADD_DEFINITIONS(-DGEOMAPI_EXPORTS ${CAS_DEFINITIONS}) ADD_LIBRARY(GeomAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) -SET(CMAKE_SWIG_FLAGS "-Wall") +SET(CMAKE_SWIG_FLAGS -threads -Wall) SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(GeomAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow") diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 54c0b472d..149a7fe8a 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -46,8 +46,7 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES Config ) - -SET(CMAKE_SWIG_FLAGS "-Wall") +SET(CMAKE_SWIG_FLAGS -threads -Wall) ADD_DEFINITIONS(-DMODELAPI_EXPORTS -DSWIG_TYPE_TABLE=ModelAPI) ADD_LIBRARY(ModelAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})