X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2FPythonNode.cxx;h=66c7aae24dfb4ceaad737d3e8a0aebc1756049fe;hb=13ca785a6bf36d005ee74eba2bc28d0cf4f8dca7;hp=a20eca38214cce02c27aff039eb416d29624f303;hpb=237b241699ced019d48ecc8cac65bf9abeb4b5e1;p=modules%2Fyacs.git diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index a20eca382..66c7aae24 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2020 CEA/DEN, EDF R&D +// Copyright (C) 2006-2021 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -21,7 +21,7 @@ #include "PythonNode.hxx" #include "PythonPorts.hxx" #include "TypeCode.hxx" -#include "AutoGIL.hxx" +#include "PythonCppUtils.hxx" #include "Container.hxx" #include "SalomeContainer.hxx" #include "SalomeHPContainer.hxx" @@ -77,6 +77,12 @@ const char PyFuncNode::SCRIPT_FOR_SERIALIZATION[]="import pickle\n" " args=pickle.loads(st)\n" " return args\n"; +// pickle.load concurrency issue : see https://bugs.python.org/issue12680 +#if PY_VERSION_HEX < 0x03070000 +#include +static std::mutex data_mutex; +#endif + PythonEntry::PythonEntry():_context(0),_pyfuncSer(0),_pyfuncUnser(0),_pyfuncSimpleSer(0) { } @@ -185,6 +191,9 @@ void PythonEntry::loadRemoteContext(InlineNode *reqNode, Engines::Container_ptr Engines::PyNodeBase_var pynode(getRemoteInterpreterHandle()); /// { +#if PY_VERSION_HEX < 0x03070000 + std::unique_lock lock(data_mutex); +#endif AutoGIL agil; const char *picklizeScript(getSerializationScript()); PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context); @@ -412,6 +421,9 @@ void PythonNode::executeRemote() std::unique_ptr serializationInputCorba(new Engines::pickledArgs); AutoPyRef serializationInput; { +#if PY_VERSION_HEX < 0x03070000 + std::unique_lock lock(data_mutex); +#endif AutoGIL agil; PyObject *args(0),*ob(0); //=========================================================================== @@ -501,6 +513,9 @@ void PythonNode::executeRemote() auto length(resultCorba->length()); char *resultCorbaC(reinterpret_cast(resultCorba->get_buffer())); { +#if PY_VERSION_HEX < 0x03070000 + std::unique_lock lock(data_mutex); +#endif AutoGIL agil; PyObject *args(0),*ob(0); PyObject* resultPython=PyMemoryView_FromMemory(resultCorbaC,length,PyBUF_READ); @@ -1091,6 +1106,9 @@ void PyFuncNode::executeRemote() // Engines::pickledArgs_var serializationInputCorba(new Engines::pickledArgs);; { +#if PY_VERSION_HEX < 0x03070000 + std::unique_lock lock(data_mutex); +#endif AutoGIL agil; PyObject *ob(0); //=========================================================================== @@ -1150,6 +1168,9 @@ void PyFuncNode::executeRemote() resultCorbaC[i]=resultCorba[i]; { +#if PY_VERSION_HEX < 0x03070000 + std::unique_lock lock(data_mutex); +#endif AutoGIL agil; PyObject *resultPython(PyBytes_FromStringAndSize(resultCorbaC,resultCorba->length()));