From: Anthony Geay Date: Mon, 6 Apr 2020 13:24:34 +0000 (+0200) Subject: First attempt to reduce memory peak on remote python invokation X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f14c1fb3d220b93e235c26d45d2e76799540c3b8;p=modules%2Fkernel.git First attempt to reduce memory peak on remote python invokation --- diff --git a/idl/SALOME_PyNode.idl b/idl/SALOME_PyNode.idl index 6c8af4241..2e017f9c6 100644 --- a/idl/SALOME_PyNode.idl +++ b/idl/SALOME_PyNode.idl @@ -82,7 +82,14 @@ module Engines */ pickledArgs execute(in listofstring outargsname, in pickledArgs inargs) raises (SALOME::SALOME_Exception); - + /*! \brief first part of whole execute method. This split is to reduce the memory peak. + */ + void executeFirst(in pickledArgs inargs) raises (SALOME::SALOME_Exception); + + /*! \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); + pickledArgs getValueOfVarInContext(in string varName) raises (SALOME::SALOME_Exception); void assignVarInContext(in string varName, in pickledArgs value) raises (SALOME::SALOME_Exception); diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 48a839e8c..b74a7f2f7 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -143,6 +143,32 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic): l=traceback.format_exception(exc_typ,exc_val,exc_fr) raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s, outargsname: %s" % (self.nodeName,outargsname),0)) + def executeFirst(self,argsin): + """ Same than first part of self.execute to reduce memory peak.""" + try: + _,kws=pickle.loads(argsin) + self.context.update(kws) + exec(self.ccode, self.context) + except: + exc_typ,exc_val,exc_fr=sys.exc_info() + l=traceback.format_exception(exc_typ,exc_val,exc_fr) + raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode:First %s" % (self.nodeName),0)) + + def executeSecond(self,outargsname): + """ Same than second part of self.execute to reduce memory peak.""" + try: + argsout=[] + for arg in outargsname: + if arg not in self.context: + raise KeyError("There is no variable %s in context" % arg) + argsout.append(self.context[arg]) + argsout=pickle.dumps(tuple(argsout),-1) + return argsout + except: + exc_typ,exc_val,exc_fr=sys.exc_info() + l=traceback.format_exception(exc_typ,exc_val,exc_fr) + raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode:Second %s, outargsname: %s" % (self.nodeName,outargsname),0)) + def getValueOfVarInContext(self,varName): try: return pickle.dumps(self.context[varName],-1)