]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
[EDF30875] : Fix problem of COMM_FAILURE_WaitingForReply after 200 execs
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 11 Sep 2024 20:04:38 +0000 (22:04 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Fri, 13 Sep 2024 07:47:54 +0000 (09:47 +0200)
idl/SALOME_PyNode.idl
src/Basics/KernelBasis.i
src/Container/SALOME_PyNode.py

index e0baf0131f10136e0853e0d2982c64b3c685ed81..2953a51427e10afbaa723236e5fb20489a95d60c 100644 (file)
@@ -114,7 +114,8 @@ module Engines
   interface ContextExchanger
   {
     SALOME::SenderByte getInputContext() raises (SALOME::SALOME_Exception);
-    void pushOutputContext( in SALOME::SenderByte ctx ) raises (SALOME::SALOME_Exception);
+    void pushOutputContext( in pickledArgs ctx ) raises (SALOME::SALOME_Exception);
+    void finishPushContext() raises (SALOME::SALOME_Exception);
   };
 
 };
index 06e0e0e785dc91ab96039bfb08831e34520c7b0d..c94b1e92b62dd8b87d51fa2f01c5556cf26b4b68 100644 (file)
@@ -106,6 +106,11 @@ void WriteInStderr(const std::string& msg);
 
 %inline
 {
+void IncrementRefCounter( PyObject * obj )
+{
+  Py_XINCREF( obj );
+}
+
 PyObject *HeatMarcelSwig(double timeAjustment, unsigned int nbThreads = 0)
 {
   double timeInS = 0.0;
index 65eaec8438fe1d3978ef75e0a373664662c8e1d8..d38a351fde82f8e403f760dd0de213aa8deea871 100644 (file)
@@ -863,6 +863,7 @@ from salome_utils import positionVerbosityOfLoggerRegardingState
 import Engines
 import salome
 import os
+import sys
 salome.salome_init()
 from datetime import datetime
 SetVerbosityActivated( {} )
@@ -990,6 +991,7 @@ class ContextExchanger_i(Engines__POA.ContextExchanger):
     import salome
     self._poa = salome.orb.resolve_initial_references("RootPOA")
     self._in_ctx = inCtx
+    self._out_ctx = bytes(0)
 
   def getPOA(self):
     return self._poa
@@ -997,27 +999,44 @@ class ContextExchanger_i(Engines__POA.ContextExchanger):
   def getInputContext(self):
     obj = SenderByte_i(self._poa, pickle.dumps( self._in_ctx ) ) ; id_o = self._poa.activate_object(obj) ; refPtr = self._poa.id_to_reference(id_o)
     return refPtr
-
+    
   def pushOutputContext(self, ctx):
-    self._output_context = pickle.loads( SeqByteReceiver( ctx ).data() )
+    try:
+      self._out_ctx += ctx
+    except Exception as e:
+      raise SALOME.SALOME_Exception( SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,str(e),"pushOutputContext",0) )
+
+  def finishPushContext(self):
+    try:
+      #raise RuntimeError(f"Anthony {dir(self)}")
+      self._output_context = pickle.loads( self._out_ctx )
+      #del self._out_ctx
+    except Exception as e:
+      raise SALOME.SALOME_Exception( SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,str(e),"finishPushContext",0) )
 
   def getOutputContext(self):
     return self._output_context
 
 class ExchangeContextUsingTCP( ExchangeContextBridgeAbs ):
   def buildContextPointEntry(self, caseDir, contextEntry):
-    import CORBA
-    self._orb = CORBA.ORB_init([''])
+    import salome
+    salome.salome_init()
+    self._orb = salome.orb
     self._data_exchange_channel = self._orb.string_to_object( contextEntry )
     return pickle.loads( SeqByteReceiver( self._data_exchange_channel.getInputContext() ).data() )
   
   def pushContext(self, contextPointEntry, context):
-    poa = self._orb.resolve_initial_references("RootPOA")
-    pman = poa.the_POAManager
-    pman.activate()
-    obj = SenderByte_i(poa, pickle.dumps( context) ) ; id_o = poa.activate_object(obj) ; refPtr = poa.id_to_reference(id_o)
-    self._data_exchange_channel.pushOutputContext( refPtr )
-    pman.deactivate(True,True)
+    ctxBytes = pickle.dumps( context )
+    size = len( ctxBytes )
+    if size <= SeqByteReceiver.CHUNK_SIZE:
+      self._data_exchange_channel.pushOutputContext( ctxBytes )
+    else:
+      EFF_CHUNK_SIZE = SeqByteReceiver.CHUNK_SIZE // 8
+      iStart = 0 ; iEnd = EFF_CHUNK_SIZE
+      while iStart!=iEnd and iEnd <= size:
+        self._data_exchange_channel.pushOutputContext( ctxBytes[iStart:iEnd] )
+        iStart = iEnd; iEnd = min(iStart + EFF_CHUNK_SIZE,size)
+    self._data_exchange_channel.finishPushContext()
 
 def ExchangeModeServerSideFactory( exchangeMode ):
   if exchangeMode == "File":