import Engines
import salome
import os
+import sys
salome.salome_init()
from datetime import datetime
SetVerbosityActivated( {} )
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
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":