From: jfa Date: Thu, 30 Mar 2023 13:26:30 +0000 (+0100) Subject: Debug hanging-up in some KERNEL tests X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=24777e0766dc2469b027e35ce0a538e39331591f;p=modules%2Fkernel.git Debug hanging-up in some KERNEL tests --- diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index a10833689..80008d123 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -29,7 +29,10 @@ #include "SALOME_ModuleCatalog.hh" #include "Basics_Utils.hxx" #include "Basics_DirUtils.hxx" + +#include // must be before Python.h ! #include "PythonCppUtils.hxx" + #include #include #include @@ -847,7 +850,13 @@ std::string GetCommandFromTemplate(const std::string& theScriptName, std::queue& 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())); @@ -907,8 +916,11 @@ std::string GetCommandFromTemplate(const std::string& theScriptName, Py_XDECREF(mod); } } - + PyGILState_Release(gstate); + if (_save) { + PyEval_RestoreThread(_save); + } MESSAGE("Command from template is ... " << command << std::endl); return command;