From 3bd065d98e6be54641662dae58e489e7b97b5400 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 10 Feb 2023 17:08:37 +0100 Subject: [PATCH] [EDF26936] : End of the 2GB limit. --- src/runtime/CMakeLists.txt | 1 + src/runtime/PythonNode.cxx | 40 ++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt index abf7c05a6..1ef9ffcea 100644 --- a/src/runtime/CMakeLists.txt +++ b/src/runtime/CMakeLists.txt @@ -39,6 +39,7 @@ IF(SALOME_YACS_USE_KERNEL) ResourcesManager SalomeHDFPersist SalomeGenericObj + SalomeCommunication ) SET(SALOME_INCL_PATH ${KERNEL_INCLUDE_DIRS}) diff --git a/src/runtime/PythonNode.cxx b/src/runtime/PythonNode.cxx index 9cc71d542..33cfc9f68 100644 --- a/src/runtime/PythonNode.cxx +++ b/src/runtime/PythonNode.cxx @@ -27,6 +27,8 @@ #include "SalomeHPContainer.hxx" #include "SalomeContainerTmpForHP.hxx" #include "ConversionException.hxx" +#include "ReceiverFactory.hxx" +#include "SenderByteImpl.hxx" #include "PyStdout.hxx" #include @@ -417,8 +419,8 @@ void PythonNode::executeRemote() loadPythonAdapter(this,dummy); _pynode->assignNewCompiledCode(getScript().c_str()); } - // - std::unique_ptr serializationInputCorba(new Engines::pickledArgs); + // not managed by unique_ptr here because destructed by the order of client. + SenderByteImpl *serializationInputCorba = nullptr; AutoPyRef serializationInput; { #if PY_VERSION_HEX < 0x03070000 @@ -446,12 +448,12 @@ void PythonNode::executeRemote() serializationInput.set(PyObject_CallFunctionObjArgs(_pyfuncSer,args,nullptr)); Py_DECREF(args); //The pickled string may contain NULL characters so use PyString_AsStringAndSize - char *serializationInputC(0); + char *serializationInputC(nullptr); Py_ssize_t len; if (PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len)) throw Exception("DistributedPythonNode problem in python pickle"); // no copy here. The C byte array of Python is taken as this into CORBA sequence to avoid copy - serializationInputCorba.reset(new Engines::pickledArgs(len,len,reinterpret_cast(serializationInputC),0)); + serializationInputCorba = new SenderByteImpl(serializationInputC,len); } //get the list of output argument names @@ -472,14 +474,15 @@ void PythonNode::executeRemote() // Execute in remote Python node //=========================================================================== DEBTRACE( "-----------------starting remote python invocation-----------------" ); - std::unique_ptr resultCorba; + SALOME::SenderByte_var resultCorba; try { //pass outargsname and dict serialized - _pynode->executeFirst(*(serializationInputCorba.get())); + SALOME::SenderByte_var serializationInputRef = serializationInputCorba->_this(); + _pynode->executeFirst(serializationInputRef); //serializationInput and serializationInputCorba are no more needed for server. Release it. - serializationInputCorba.reset(nullptr); serializationInput.set(nullptr); - resultCorba.reset(_pynode->executeSecond(myseq)); + serializationInput.set(nullptr); + resultCorba = _pynode->executeSecond(myseq); } catch( const SALOME::SALOME_Exception& ex ) { @@ -564,20 +567,23 @@ void PythonNode::executeRemote() //=========================================================================== // Get results, unpickle and put them in output ports //=========================================================================== - 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); - args = PyTuple_New(1); - PyTuple_SetItem(args,0,resultPython); - PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args); - resultCorba.reset(nullptr); - Py_DECREF(args); + PyObject *finalResult( nullptr), *ob( nullptr ); + { + SeqByteReceiver recv(resultCorba); + PyObject *args(0); + unsigned long length = 0; + char *resultCorbaC = recv.data(length); + PyObject* resultPython=PyMemoryView_FromMemory(resultCorbaC,length,PyBUF_READ); + args = PyTuple_New(1); + PyTuple_SetItem(args,0,resultPython); + finalResult = PyObject_CallObject(_pyfuncUnser,args); + Py_DECREF(args); + } if (finalResult == NULL) { -- 2.30.2