From 57faef2b6b84e420c59e2d4228e4ae3aaed2ea12 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 9 Sep 2024 18:22:00 +0200 Subject: [PATCH] [EDF30875] : Fix lost entries in logging in case of insulated python process --- src/Container/SALOME_ContainerHelper.py | 3 +++ src/Container/SALOME_PyNode.py | 1 + src/Launcher/SALOME_LogManager.py | 14 +++++++++----- src/Launcher/Test/testCrashProofContainer.py | 1 + 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Container/SALOME_ContainerHelper.py b/src/Container/SALOME_ContainerHelper.py index da46cd6ed..eddce54ea 100644 --- a/src/Container/SALOME_ContainerHelper.py +++ b/src/Container/SALOME_ContainerHelper.py @@ -81,6 +81,9 @@ class ScriptExecInfo: def preappendFreestyle(self, value): self._freestyle_log = value + self._freestyle_log + def appendFreestyle(self, value): + self._freestyle_log += value + @property def measureTimeResolution(self): return self._measure_time_resolution_ms diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index 4f4129efe..4ed8fd958 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -1414,6 +1414,7 @@ class PyScriptNode_Abstract_i(Engines__POA.PyScriptNode,Generic,abc.ABC): self.addTimeInfoOnLevel2("startExecTime") ## self.addInfoOnLevel2("measureTimeResolution",self.my_container_py.monitoringtimeresms()) + self._current_execution_session.finalizeAndPushToMaster() # flush it to the server (scheduler hosting ContainerManager) in order to retrieve it in Python server cpumeminfo, self._current_execution_session._current_instance = executeSecondInternal( self.my_container_py.monitoringtimeresms() ) ## self.addInfoOnLevel2("CPUMemDuringExec",cpumeminfo) diff --git a/src/Launcher/SALOME_LogManager.py b/src/Launcher/SALOME_LogManager.py index 58114fc41..7404a35cf 100644 --- a/src/Launcher/SALOME_LogManager.py +++ b/src/Launcher/SALOME_LogManager.py @@ -45,16 +45,20 @@ class SALOME_ContainerScriptExecPerfLog: :param alreadyOnSiteBytes: pickle of instance of ScriptExecInfo of previous value (if any) [bytes] :param instanceRemoteBytes: pickle of current instance of ScriptExecInfo (if any) [bytes] """ + instanceRemote = pickle.loads(instanceRemoteBytes) alreadyOnSite = None if len( alreadyOnSiteBytes ) > 0: alreadyOnSite = pickle.loads(alreadyOnSiteBytes) - instanceRemote = pickle.loads(instanceRemoteBytes) self._stop_pos = os.path.getsize( self.father.father.logfilename ) - setattr(instanceRemote,"tracePosStop",self._stop_pos) - setattr(instanceRemote,"tracePosStart",self._start_pos) if alreadyOnSite: - instanceRemote.preappendFreestyle( alreadyOnSite._freestyle_log ) - return pickle.dumps(instanceRemote) + setattr(alreadyOnSite,"tracePosStop",self._stop_pos) + setattr(alreadyOnSite,"tracePosStart",self._start_pos) + alreadyOnSite.appendFreestyle( instanceRemote._freestyle_log ) + return pickle.dumps(alreadyOnSite) + else: + setattr(instanceRemote,"tracePosStop",self._stop_pos) + setattr(instanceRemote,"tracePosStart",self._start_pos) + return pickle.dumps(instanceRemote) def start(self): self._start_pos = os.path.getsize( self.father.father.logfilename ) diff --git a/src/Launcher/Test/testCrashProofContainer.py b/src/Launcher/Test/testCrashProofContainer.py index eb30ec1cc..044a62c38 100644 --- a/src/Launcher/Test/testCrashProofContainer.py +++ b/src/Launcher/Test/testCrashProofContainer.py @@ -309,6 +309,7 @@ class testPerfLogManager1(unittest.TestCase): logInfoForCont = [elt for elt in a if "container_crash_test_5" in elt.ns_entry] self.assertEqual( len(logInfoForCont), 1 ) logInfoForCont = logInfoForCont[0] + self.assertTrue( logInfoForCont[1][0].startExecTime is not None ) self.assertEqual( [elt[0] for elt in logInfoForCont[1][0].get().freestyle] , ['b4loadctx', 'afterloadctx', 'bforeexec', 'b4loadctx', 'afterloadctx', 'bforeexec', 'afterexec', 'strtdumpout', 'afterdump'] ) # <- aim of test is here. First 3 entries ('b4loadctx', 'afterloadctx', 'bforeexec') prove that first attempt fails to return within 10 sececonds as requested by KernelBasis.SetExecutionTimeOut(10) pass pass -- 2.39.2