typedef sequence<long> vectorOfLong;
+ typedef sequence<octet> vectorOfByte;
+
interface MultiCommClass {
void setProtocol(in TypeOfCommunication typ);
};
long getSizeOfColumn();
void release();
};
+
+ interface SenderByte
+ {
+ unsigned long getSize();
+ vectorOfByte sendPart(in unsigned long n1,in unsigned long n2);
+ };
};
#endif
#include "SALOME_GenericObj.idl"
#include "SALOME_Exception.idl"
+#include "SALOME_Comm.idl"
/*! \file SALOME_PyNode.idl \brief interface for remote python execution
*/
/*! \brief second and last part of execute method. This split is to reduce the memory peak.
*/
- pickledArgs executeSecond(in listofstring outargsname) raises (SALOME::SALOME_Exception);
+ SALOME::SenderByte executeSecond(in listofstring outargsname) raises (SALOME::SALOME_Exception);
pickledArgs getValueOfVarInContext(in string varName) raises (SALOME::SALOME_Exception);
}
}
+SeqByteReceiver::SeqByteReceiver(SALOME::SenderByte_ptr sender):_obj(SALOME::SenderByte::_duplicate(sender))
+{
+}
+
+char *SeqByteReceiver::data(unsigned long& size)
+{
+ size = _obj->getSize();
+ if(size <= CHUNK_SIZE)
+ {
+ this->fetchOneShot( size );
+ return reinterpret_cast<char *>(_data_one_shot->get_buffer());
+ }
+ else
+ {
+ this->fetchByChunks( size );
+ return _data_for_split_case.get();
+ }
+}
+
+void SeqByteReceiver::fetchOneShot(unsigned long size)
+{
+ _data_one_shot.reset( _obj->sendPart(0,size) );
+}
+
+void SeqByteReceiver::fetchByChunks(unsigned long size)
+{
+ _data_for_split_case.reset( new char[size] );
+ char *destination = _data_for_split_case.get();
+ constexpr unsigned long EFF_CHUNK_SIZE = CHUNK_SIZE / 8;
+ unsigned long iStart = 0;
+ unsigned long iEnd = EFF_CHUNK_SIZE;
+ while( iStart!=iEnd && iEnd <= size )
+ {
+ std::unique_ptr<SALOME::vectorOfByte> part( _obj->sendPart(iStart,iEnd) );
+ const unsigned char *partC = part->get_buffer();
+ std::copy(partC,partC+(iEnd-iStart),destination+iStart);
+ iStart = iEnd; iEnd = std::min(iStart + EFF_CHUNK_SIZE,size);
+ }
+}
+
static int *getValueOneShot(SALOME::SenderInt_ptr sender,long &size);
};
+#include <memory>
+
+class COMMUNICATION_EXPORT SeqByteReceiver
+{
+public:
+ SeqByteReceiver(SALOME::SenderByte_ptr sender);
+ char *data(unsigned long& size);
+private:
+ void fetchOneShot(unsigned long size);
+ void fetchByChunks(unsigned long size);
+private:
+ static constexpr unsigned long CHUNK_SIZE = 2000000000;
+ std::unique_ptr<char[]> _data_for_split_case;
+ std::unique_ptr<SALOME::vectorOfByte> _data_one_shot;
+ SALOME::SenderByte_var _obj;
+};
+
#endif
l=traceback.format_exception(exc_typ,exc_val,exc_fr)
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyNode: %s, function: %s" % (self.nodeName,funcName),0))
+class SenderByte_i(SALOME__POA.SenderByte):
+ def __init__(self,bytesToSend):
+ self.bytesToSend = bytesToSend
+
+ def getSize(self):
+ return len(self.bytesToSend)
+
+ def sendPart(self,n1,n2):
+ return self.bytesToSend[n1:n2]
+
class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
"""The implementation of the PyScriptNode CORBA IDL that executes a script"""
def __init__(self, nodeName,code,poa,my_container):
raise KeyError("There is no variable %s in context" % arg)
argsout.append(self.context[arg])
argsout=pickle.dumps(tuple(argsout),-1)
- return argsout
+ ret = SenderByte_i( argsout )
+ id_o = self.poa.activate_object(ret)
+ retObj = self.poa.id_to_reference(id_o)
+ return retObj._narrow( SALOME.SenderByte )
except Exception:
exc_typ,exc_val,exc_fr=sys.exc_info()
l=traceback.format_exception(exc_typ,exc_val,exc_fr)