]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Additionnal remote callable methods for debugging and for remote python invocation...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 6 Apr 2020 13:24:34 +0000 (15:24 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 8 Apr 2020 08:48:19 +0000 (10:48 +0200)
idl/SALOME_PyNode.idl
src/Container/SALOME_PyNode.py

index 6c8af42415530227ea50aef0cac27cc32d1bb453..efdb6d855cbe399a7b9f6abfc00ed23531f71a82 100644 (file)
@@ -37,9 +37,16 @@ module Engines
 {
   typedef sequence<octet> pickledArgs;
   typedef sequence<string> listofstring;
+  interface Container;
 
   interface PyNodeBase : SALOME::GenericObj
   {
+    Container getContainer();
+
+    string getCode();
+
+    string getName();
+
     /*!
       This method allows to define a new global var called \a varName. This newly created var will be
       set to value \a valueOfVar.
@@ -82,7 +89,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);
index 48a839e8c8c31e0627aee67aa6cb84695d6946a3..dee1f18969b0a37ebc5ed98ffbba9845cf8e4d8f 100644 (file)
@@ -68,6 +68,15 @@ class PyNode_i (Engines__POA.PyNode,Generic):
     self.context["my_container"] = self.my_container
     exec(ccode, self.context)
 
+  def getContainer(self):
+    return self.my_container
+
+  def getCode(self):
+    return self.code
+
+  def getName(self):
+    return self.nodeName
+
   def defineNewCustomVar(self,varName,valueOfVar):
     self.context[varName] = pickle.loads(valueOfVar)
     pass
@@ -106,6 +115,15 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
     self.context={}
     self.context["my_container"] = self.my_container
 
+  def getContainer(self):
+    return self.my_container
+
+  def getCode(self):
+    return self.code
+
+  def getName(self):
+    return self.nodeName
+
   def defineNewCustomVar(self,varName,valueOfVar):
     self.context[varName] = pickle.loads(valueOfVar)
     pass
@@ -143,6 +161,33 @@ 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."""
+    import time
+    try:
+      _,kws=pickle.loads(argsin)
+      self.context.update(kws)
+    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:
+      exec(self.ccode, self.context)
+      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)