X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2FDistributedPythonNode.cxx;h=626e2126e4e38fee71887be698af757c5b780abd;hb=3bd065d98e6be54641662dae58e489e7b97b5400;hp=96263202dfbcca120a0edb42e08005ee5a39d035;hpb=802458daad8b198beabbb058dc87437bdc63b1a3;p=modules%2Fyacs.git diff --git a/src/runtime/DistributedPythonNode.cxx b/src/runtime/DistributedPythonNode.cxx index 96263202d..626e2126e 100644 --- a/src/runtime/DistributedPythonNode.cxx +++ b/src/runtime/DistributedPythonNode.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2015 CEA/DEN, EDF R&D +// Copyright (C) 2006-2022 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 @@ -23,7 +23,7 @@ #include "PythonNode.hxx" #include "SalomeHPContainer.hxx" #include "SalomeContainerTmpForHP.hxx" -#include "AutoGIL.hxx" +#include "PythonCppUtils.hxx" #include "PythonPorts.hxx" #include "YacsTrace.hxx" @@ -72,7 +72,7 @@ void DistributedPythonNode::load() _errorDetails=msg.str(); throw Exception(msg.str()); } - const char picklizeScript[]="import cPickle\ndef pickleForDistPyth2009(*args,**kws):\n return cPickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n args=cPickle.loads(st)\n return args\n"; + const char picklizeScript[]="import pickle\ndef pickleForDistPyth2009(*args,**kws):\n return pickle.dumps((args,kws),-1)\n\ndef unPickleForDistPyth2009(st):\n args=pickle.loads(st)\n return args\n"; PyObject *res=PyRun_String(picklizeScript,Py_file_input,_context,_context); if(res == NULL) { @@ -134,7 +134,7 @@ void DistributedPythonNode::load() } else { - Engines::PyNode_var dftPyScript(objContainer->getDefaultPyNode()); + Engines::PyNode_var dftPyScript(objContainer->getDefaultPyNode(getName().c_str())); if(CORBA::is_nil(dftPyScript)) _pynode = objContainer->createPyNode(getName().c_str(),getScript().c_str()); else @@ -181,11 +181,12 @@ void DistributedPythonNode::execute() PyTuple_SetItem(args,pos,ob); } PyObject *serializationInput=PyObject_CallObject(_pyfuncSer,args); - std::string serializationInputC=PyString_AsString(serializationInput); + Py_ssize_t len = PyBytes_Size(serializationInput); + char* serializationInputC = PyBytes_AsString(serializationInput); + //int ret = PyBytes_AsStringAndSize(serializationInput, &serializationInputC, &len); serializationInputCorba=new Engines::pickledArgs; - int len=serializationInputC.length(); - serializationInputCorba->length(serializationInputC.length()); - for(int i=0;ilength(len+1); + for(int i=0;ilength()]='\0'; for(int i=0;ilength();i++) resultCorbaC[i]=(*resultCorba)[i]; + int lenResCorba=resultCorba->length(); delete resultCorba; { AutoGIL agil; args = PyTuple_New(1); - PyObject* resultPython=PyString_FromString(resultCorbaC); + //PyObject* resultPython=PyBytes_FromString(resultCorbaC); + PyObject* resultPython=PyBytes_FromStringAndSize(resultCorbaC,lenResCorba); delete [] resultCorbaC; PyTuple_SetItem(args,0,resultPython); PyObject *finalResult=PyObject_CallObject(_pyfuncUnser,args); DEBTRACE( "-----------------DistributedPythonNode::outputs-----------------" ); + if(finalResult == NULL) + { + std::stringstream msg; + msg << "Conversion with pickle of output ports failed !"; + msg << " : " << __FILE__ << ":" << __LINE__; + _errorDetails=msg.str(); + throw YACS::ENGINE::ConversionException(msg.str()); + } int nres=1; if(finalResult == Py_None) nres=0; @@ -238,7 +249,7 @@ void DistributedPythonNode::execute() { OutputPyPort *p=(OutputPyPort *)*iter; DEBTRACE( "port name: " << p->getName() ); - DEBTRACE( "port kind: " << p->edGetType()->kind() ); + DEBTRACE( "port kind: " << p->typeName() ); DEBTRACE( "port pos : " << pos ); if(PyTuple_Check(finalResult))ob=PyTuple_GetItem(finalResult,pos) ; else ob=finalResult;