From 1e347ee688da17adcf3605336a277726a24f7f89 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 5 Jan 2024 11:52:41 +0100 Subject: [PATCH] [EDF29150] : End of save / load of LogManager + non regression test. --- idl/SALOME_LogManager.idl | 2 +- src/Container/SALOME_ContainerHelper.py | 66 ++++++- src/Container/SALOME_ContainerManager.cxx | 2 +- .../ScriptsTemplate/script_parameters.py | 14 +- src/KERNEL_PY/__init__.py | 25 ++- src/Launcher/SALOME_LogManager.cxx | 69 ++------ src/Launcher/SALOME_LogManager.hxx | 5 +- src/Launcher/Test/CMakeLists.txt | 10 +- src/Launcher/Test/CTestTestfileInstall.cmake | 16 +- src/Launcher/Test/testPerfLogManager1.py | 167 ++++++++++++++++++ 10 files changed, 284 insertions(+), 92 deletions(-) create mode 100644 src/Launcher/Test/testPerfLogManager1.py diff --git a/idl/SALOME_LogManager.idl b/idl/SALOME_LogManager.idl index c461c66d7..3e56d300f 100644 --- a/idl/SALOME_LogManager.idl +++ b/idl/SALOME_LogManager.idl @@ -57,7 +57,7 @@ module Engines { ContainerPerfLog declareContainer(in string contInNS, in string logfile); ListOfContainerPerfLog listOfContainerLogs(); - SALOME::vectorOfByte getAllStruct(); + SALOME::vectorOfByte getAllStruct( in boolean clearMemory ); }; }; diff --git a/src/Container/SALOME_ContainerHelper.py b/src/Container/SALOME_ContainerHelper.py index 2d3562846..7725f3f2c 100644 --- a/src/Container/SALOME_ContainerHelper.py +++ b/src/Container/SALOME_ContainerHelper.py @@ -307,6 +307,8 @@ class ScriptInfoDeco: return self._eff def __getitem__(self,i): return ScriptExecInfoDeco( self._eff[i], self ) + def __len__(self): + return self._eff.__len__() def __str__(self): return self._eff.__str__() def __repr__(self): @@ -343,7 +345,7 @@ class ContainerLogInfoClt(ContainerLogInfoAbstract): self._scripts = [ScriptInfoClt(elt) for elt in contLogPtr.listOfScripts()] class ContainerLogInfo(ContainerLogInfoAbstract): - def __init__(self, logFile, nsEntry, scripts): + def __init__(self, nsEntry, logFile, scripts): self._log_file = logFile self._ns_entry = nsEntry self._scripts = scripts @@ -445,3 +447,65 @@ class InOutputObjVisitorCM: if self._visitor: self._visitor.leave() pass + +class OffsetType: + def __init__(self,i): + self._i = i + def __int__(self): + return self._i + def __iadd__(self,delta): + self._i += delta + return self + +def unserializeInt(structData, offset): + from ctypes import c_int + sz_of_cint = 4 + sz = c_int.from_buffer_copy( structData[int(offset):int(offset)+sz_of_cint] ).value + offset += sz_of_cint + return sz + +def unserializeString(structData,offset): + sz = unserializeInt(structData,offset) + ret = structData[int(offset):int(offset)+sz].decode() + offset += sz + return ret + +def unserializeContainerScriptExecPerfLog(structData, offset): + import pickle + sz = unserializeInt(structData,offset) + inst = None + if sz > 0: + inst = pickle.loads( structData[int(offset):int(offset)+sz] ) + offset += sz + return inst + +def unserializeContainerScriptPerfLog(structData, offset): + name = unserializeString(structData,offset) + code = unserializeString(structData,offset) + numberOfSessions = unserializeInt(structData,offset) + sessions = [] + for _ in range(numberOfSessions): + session = unserializeContainerScriptExecPerfLog(structData,offset) + sessions.append( session ) + return ScriptInfo(name,code,sessions) + +def unserializeContainerPerfLog(structData, offset): + nsEntry = unserializeString(structData,offset) + logFile = unserializeString(structData,offset) + scripts = [] + nbScripts = unserializeInt(structData,offset) + for _ in range(nbScripts): + script = unserializeContainerScriptPerfLog(structData,offset) + scripts.append( script ) + return ContainerLogInfo(nsEntry,logFile,scripts) + +def unserializeLogManager(structData): + offset = OffsetType(0) + numberOfScripts = unserializeInt(structData,offset) + logManagerInst = [] + for _ in range(numberOfScripts): + containerPerfLogInst = unserializeContainerPerfLog(structData,offset) + logManagerInst.append( containerPerfLogInst ) + if int(offset) != len(structData): + raise RuntimeError("Something went wrong during unserialization phase.") + return logManagerInst diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index e8d434d76..506a44e51 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -500,7 +500,7 @@ Engines::Container_ptr SALOME_ContainerManager::GiveContainer(const Engines::Con cont->monitoringtimeresms( this->_delta_time_measure_in_ms ); INFOS("[GiveContainer] container " << containerNameInNS << " first CORBA invocation OK"); std::ostringstream envInfo; - std::for_each( _override_env.begin(), _override_env.end(), [&envInfo](const std::pair& p) { envInfo << p.first << " = " << p.second << std::endl; } ); + std::for_each( _override_env.begin(), _override_env.end(), [&envInfo](const std::pair& p) { envInfo << p.first << " = " << p.second << " "; } ); INFOS("[GiveContainer] container " << containerNameInNS << " override " << envInfo.str()); Engines::FieldsDict envCorba; { diff --git a/src/Container/ScriptsTemplate/script_parameters.py b/src/Container/ScriptsTemplate/script_parameters.py index ee1c6d3e7..cc1d3a8aa 100644 --- a/src/Container/ScriptsTemplate/script_parameters.py +++ b/src/Container/ScriptsTemplate/script_parameters.py @@ -21,15 +21,5 @@ class ScriptLocalParameters: return value def __str__(self): - str = [] - str.append("nb_proc: %s" % self.nb_proc) - str.append("workdir: %s" % self.workdir) - str.append("isTmpDir: %s" % self.isTmpDir) - str.append("name_server: %s" % self.name_server) - str.append("container: %s" % self.container) - str.append("container_name: %s" % self.container_name) - str.append("libbatch_nodefile: %s" % self.libbatch_nodefile) - str.append("machine_file: %s" % self.machine_file) - str.append("ompi_uri_file: %s" % self.ompi_uri_file) - str.append("--") - return "\n".join(str) \ No newline at end of file + str = """nb_proc: {self.nb_proc} workdir: {self.workdir} isTmpDir: {self.isTmpDir} name_server: {self.name_server} container: {self.container} container_name: {self.container_name} libbatch_nodefile: {self.libbatch_nodefile} machine_file: {self.machine_file} ompi_uri_file: {self.ompi_uri_file}""".format(**locals()) + return str diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py index 9a8a02a85..cdc0ead26 100644 --- a/src/KERNEL_PY/__init__.py +++ b/src/KERNEL_PY/__init__.py @@ -268,7 +268,10 @@ def salome_init_without_session(path=None, embedded=False, iorfakensfile=None): esm = KernelLauncher.GetExternalServer() # idem for logm logm = KernelLauncher.myLogManager() + type(logm).NaiveFetch = LogManagerNaiveFetch type(logm).Fetch = LogManagerFetch + type(logm).DumpInFile = LogManagerDumpInFile + type(logm).LoadFromFile = LogManagerLoadFromFile # import KernelLogger naming_service.Register(KernelLogger.myLogger(),"/Logger") @@ -451,9 +454,29 @@ def ContainerManagerSetOverrideEnvForContainersSimple(self,env): envEff = [ Engines.KeyValPairString(key=k,val=v) for k,v in env ] return self.SetOverrideEnvForContainers( envEff ) -def LogManagerFetch(self): +def LogManagerNaiveFetch(self): + """ + Fetch data from server with multiple CORBA invokations. + """ import SALOME_ContainerHelper return [SALOME_ContainerHelper.ContainerLogInfoClt(elt) for elt in self.listOfContainerLogs()] +def LogManagerFetch(self,clearMemory = False): + """ + Fetch data from server in one shot mode. + """ + from SALOME_ContainerHelper import unserializeLogManager + return unserializeLogManager( self.getAllStruct(clearMemory) ) + +def LogManagerDumpInFile(self,fileName,clearMemory = False): + with open(fileName,"wb") as f: + f.write( self.getAllStruct( clearMemory ) ) + +def LogManagerLoadFromFile(self,fileName): + from SALOME_ContainerHelper import unserializeLogManager + with open(fileName,"rb") as f: + data = f.read() + return unserializeLogManager( data ) + #to expose all objects to pydoc __all__=dir() diff --git a/src/Launcher/SALOME_LogManager.cxx b/src/Launcher/SALOME_LogManager.cxx index baaa30783..b47772476 100644 --- a/src/Launcher/SALOME_LogManager.cxx +++ b/src/Launcher/SALOME_LogManager.cxx @@ -138,7 +138,7 @@ void SALOME_ContainerScriptPerfLog::accept(SALOME_VisitorContainerLog &visitor) SALOME_ContainerScriptExecPerfLog *servC = dynamic_cast(serv); visitor.visitContainerScriptExecPerfLog( *servC ); } - visitor.enterContainerScriptPerfLog( *this ); + visitor.leaveContainerScriptPerfLog( *this ); } Engines::ContainerScriptExecPerfLog_ptr SALOME_ContainerScriptPerfLog::addExecutionSession() @@ -304,9 +304,12 @@ void SALOME_LogManager::accept(SALOME_VisitorContainerLog &visitor) visitor.leaveLogManager( *this ); } -SALOME::vectorOfByte *SALOME_LogManager::getAllStruct() +/*! + \param [in] unloadMemory - specify if big part of struct data (SALOME_ContainerScriptExecPerfLog) is cleared after retrieving data + */ +SALOME::vectorOfByte *SALOME_LogManager::getAllStruct(bool clearMemory) { - std::vector data = this->dumpCppInternalFrmt(); + std::vector data = this->dumpCppInternalFrmt(clearMemory); return FromVectCharToCorba(data); } @@ -331,7 +334,7 @@ static void PushStringInVC(const T& str, std::vector& data) class InternalFormatVisitorDump : public SALOME_VisitorContainerLog { public: - InternalFormatVisitorDump(std::vector *data):_data(data) { } + InternalFormatVisitorDump(bool clearMemory, std::vector *data):_clear_memory(clearMemory),_data(data) { } void enterLogManager(SALOME_LogManager& inst) override; void leaveLogManager(SALOME_LogManager& inst) override { } void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override; @@ -340,12 +343,15 @@ public: void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { } void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override; private: + bool _clear_memory = false; std::vector *_data = nullptr; }; void InternalFormatVisitorDump::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) { PushStringInVC>(inst.data(),*_data); + if( _clear_memory ) + inst.clear(); } void InternalFormatVisitorDump::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) @@ -367,61 +373,10 @@ void InternalFormatVisitorDump::enterLogManager(SALOME_LogManager& inst) PushIntInVC((std::uint32_t)inst.getNumberOfContainers(),*_data); } -/////////////////////// - -std::vector FetchVCFromVC(std::vector& data, std::size_t& offset) -{ - std::uint32_t *sz = reinterpret_cast( data.data()+offset); - std::vector ret(data.data()+offset+sizeof(std::uint32_t),data.data()+offset+sizeof(std::uint32_t)+*sz); - offset += sizeof(std::uint32_t)+*sz; - return ret; -} - -std::string FetchStringFromVC(std::vector& data, std::size_t& offset) -{ - std::uint32_t *sz = reinterpret_cast( data.data() ); - std::string ret(data.data()+sizeof(std::uint32_t),*sz); - offset += sizeof(std::uint32_t)+*sz; - return ret; -} - -class InternalFormatVisitorLoad : public SALOME_VisitorContainerLog -{ -public: - InternalFormatVisitorLoad(std::vector *data):_data(data) { } - void enterContainerPerfLog(SALOME_ContainerPerfLog& inst) override; - void leaveContainerPerfLog(SALOME_ContainerPerfLog& inst) override { } - void enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override; - void leaveContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) override { } - void visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) override; -private: - std::vector *_data = nullptr; - std::size_t _offset = 0; -}; - -void InternalFormatVisitorLoad::visitContainerScriptExecPerfLog(SALOME_ContainerScriptExecPerfLog& inst) -{ - inst.setData( FetchVCFromVC( *_data, _offset ) ); -} - -void InternalFormatVisitorLoad::enterContainerScriptPerfLog(SALOME_ContainerScriptPerfLog& inst) -{ - inst.setName( FetchStringFromVC(*_data, _offset) ); - inst.setCode( FetchStringFromVC(*_data, _offset) ); -} - -void InternalFormatVisitorLoad::enterContainerPerfLog(SALOME_ContainerPerfLog& inst) -{ - inst.setNameInNS( FetchStringFromVC(*_data, _offset) ); - inst.setLogFile( FetchStringFromVC(*_data, _offset) ); -} - -/////////////////////// - -std::vector SALOME_LogManager::dumpCppInternalFrmt() +std::vector SALOME_LogManager::dumpCppInternalFrmt(bool clearMemory) { std::vector ret; - InternalFormatVisitorDump visitor(&ret); + InternalFormatVisitorDump visitor(clearMemory,&ret); this->accept( visitor ); return ret; } diff --git a/src/Launcher/SALOME_LogManager.hxx b/src/Launcher/SALOME_LogManager.hxx index 80cc55514..755e25268 100644 --- a/src/Launcher/SALOME_LogManager.hxx +++ b/src/Launcher/SALOME_LogManager.hxx @@ -68,6 +68,7 @@ public: public: void start(); AutoPyRef end(); + void clear() { _data.clear(); } private: AutoPyRef _pyExecutionLog; SALOME_ContainerScriptPerfLog *_father = nullptr; @@ -137,12 +138,12 @@ class SALOMELAUNCHER_EXPORT SALOME_LogManager : public POA_Engines::LogManager virtual ~SALOME_LogManager() = default; Engines::ContainerPerfLog_ptr declareContainer(const char *contInNS, const char *logfile) override; Engines::ListOfContainerPerfLog *listOfContainerLogs() override; - SALOME::vectorOfByte *getAllStruct() override; + SALOME::vectorOfByte *getAllStruct(bool clearMemory) override; std::size_t getNumberOfContainers() const { return _containers.size(); } public: void accept(SALOME_VisitorContainerLog &visitor); private: - std::vector dumpCppInternalFrmt(); + std::vector dumpCppInternalFrmt(bool clearMemory); private: PyObject *_pyLogManager = nullptr; std::unique_ptr _NS; diff --git a/src/Launcher/Test/CMakeLists.txt b/src/Launcher/Test/CMakeLists.txt index f349063ea..41d0759fc 100644 --- a/src/Launcher/Test/CMakeLists.txt +++ b/src/Launcher/Test/CMakeLists.txt @@ -20,15 +20,9 @@ # --- rules --- IF(NOT WIN32) -# ** Now in CTestTestfileInstall.cmake ** -# ** In this file only remain unit tests (no SALOME session is needed) ** -# ADD_TEST(NAME SalomeLauncher -# COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../UnitTests/prepare_test.py -# ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py -# -d KERNEL_ROOT_DIR=${CMAKE_INSTALL_PREFIX} -# ) + INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/test_launcher.py ${CMAKE_CURRENT_SOURCE_DIR}/TestSSLAttached.py - DESTINATION ${KERNEL_TEST_DIR}/Launcher) + ${CMAKE_CURRENT_SOURCE_DIR}/testPerfLogManager1.py DESTINATION ${KERNEL_TEST_DIR}/Launcher) INSTALL(FILES CTestTestfileInstall.cmake DESTINATION ${KERNEL_TEST_DIR}/Launcher diff --git a/src/Launcher/Test/CTestTestfileInstall.cmake b/src/Launcher/Test/CTestTestfileInstall.cmake index 040518a5c..07808c2ff 100644 --- a/src/Launcher/Test/CTestTestfileInstall.cmake +++ b/src/Launcher/Test/CTestTestfileInstall.cmake @@ -20,21 +20,19 @@ IF(NOT WIN32) SET(TEST_NAME ${COMPONENT_NAME}_Launcher) ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 test_launcher.py) - SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" - # TIMEOUT 500 - ) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") SET(TEST_NAME ${COMPONENT_NAME}_AttachedLauncher) ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 TestSSLAttached.py) - SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" - # TIMEOUT 500 - ) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") SET(TEST_NAME ${COMPONENT_NAME}_StressLauncher) ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 ./test_stress.sh) - SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}" - # TIMEOUT 500 - ) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") + + SET(TEST_NAME ${COMPONENT_NAME}_PerfLogManager1) + ADD_TEST(${TEST_NAME} ${PYTHON_TEST_DRIVER} 2000 testPerfLogManager1.py) + SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES LABELS "${COMPONENT_NAME}") # /!\ DO NOT SET TIMEOUT PROPERTY IF USING ${SALOME_TEST_DRIVER} # BUT PASS TIMEOUT VALUE TO THE DRIVER diff --git a/src/Launcher/Test/testPerfLogManager1.py b/src/Launcher/Test/testPerfLogManager1.py new file mode 100644 index 000000000..0279df2ed --- /dev/null +++ b/src/Launcher/Test/testPerfLogManager1.py @@ -0,0 +1,167 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2024 CEA/DEN, EDF R&D +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +import unittest +import os +import salome +import Engines +import pylauncher +import SALOME_PyNode + +import pickle +import tempfile +import logging + +def flush(): + import sys + sys.stdout.flush() + sys.stderr.flush() + +def unProxyfy( objs ): + """ + objs is a list of SenderByte + """ + ret = [] + fileNamesProxyOut = [] + for ret2 in objs: + ret3 = pickle.loads( SALOME_PyNode.SeqByteReceiver(ret2).data() ) + ret4 = ret3 + fileNameProxyOut = None + if SALOME_PyNode.GetBigObjectOnDiskThreshold() != -1: + if isinstance( ret3, SALOME_PyNode.BigObjectOnDiskBase ): + ret4 = ret3.get() + else: + raise RuntimeError("Oooops") + ret3.unlinkOnDestructor() + fileNameProxyOut = ret3.getFileName() + logging.debug("Prxy file : {}".format( fileNameProxyOut )) + ret.append( ret3 ) + fileNamesProxyOut.append( fileNameProxyOut ) + return ret, fileNamesProxyOut + +class testPerfLogManager1(unittest.TestCase): + def testPerfLogManager0(self): + """ + [EDF29150] : This test checks measure performance methods + """ + hostname = "localhost" + cp = pylauncher.GetRequestForGiveContainer(hostname,"container_test") + #PROXY_THRES = "-1" + PROXY_THRES = "1" + with tempfile.TemporaryDirectory() as tmpdirname: + val_for_big_obj = str( tmpdirname ) + # Override environement for all containers launched + salome.cm.SetOverrideEnvForContainersSimple(env = [("SALOME_FILE_BIG_OBJ_DIR",val_for_big_obj),("SALOME_BIG_OBJ_ON_DISK_THRES",PROXY_THRES)]) + salome.cm.SetDeltaTimeBetweenCPUMemMeasureInMilliSecond( 250 ) + cont = salome.cm.GiveContainer(cp) + logging.debug("{} {}".format(40*"*",cont.getPID())) + script_st = """ +import logging +import sys +import KernelBasis +cst = KernelBasis.GetTimeAdjustmentCst() +logging.debug("constant = {}".format(cst)) +nbcore = 3 +print("coucou {} {}".format(len(zeinput0),len(zeinput1))) +logging.debug("debug or not debug") +ob = [ [ bytes(3000000) ] ] +pihm, ts = KernelBasis.HeatMarcel(1 * nbcore * cst,nbcore) +print("Time ellapse spent : {} s".format(ts)) +ob2 = [ [ bytes(100000) ] ] +pihm, ts = KernelBasis.HeatMarcel(1 * nbcore * cst,nbcore) +print("Time ellapse spent : {} s".format(ts)) +sys.stderr.write("fake error message\\n") +""" + poa = salome.orb.resolve_initial_references("RootPOA") + zeinput0 = [ bytes(100000000) ] + if SALOME_PyNode.GetBigObjectOnDiskThreshold() != -1: + zeinput0 = SALOME_PyNode.ProxyfyPickeled( zeinput0 ) + zeinput0.unlinkOnDestructor() + obj = SALOME_PyNode.SenderByte_i(poa,pickle.dumps( (["zeinput0"],{"zeinput0": [zeinput0], "zeinput1": [ [zeinput0], [zeinput0] ] }) )) + id_o = poa.activate_object(obj) + refPtr = poa.id_to_reference(id_o) + pyscript2 = cont.createPyScriptNode("testScript2",script_st) + pyscript2.executeFirst(refPtr) + ret2 = pyscript2.executeSecond(["ob","ob2"])# generate a DeprecationWarning: PY_SSIZE_T_CLEAN will be required for '#' formats on debian11 ? + ret3, fileNamesProxyOut = unProxyfy( ret2 ) + logging.getLogger().debug("test logging 1") + logging.debug("test logging 2") + logging.debug( salome.orb.object_to_string( salome.logm ) ) + a = salome.logm.NaiveFetch() + logging.debug(a) + logging.debug(a[0][1][0]) + logging.debug( a[0][1][0].get()._input_hdd_mem._data[0]._data[0]._hdd_mem ) # important + logging.debug( a[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important + fileNameProxyIn = a[0][1][0].get()._input_hdd_mem._data[0]._data[0]._file_name + logging.debug( fileNameProxyIn ) + del zeinput0 + del ret3 + import gc ; gc.collect() + if fileNameProxyIn is not None: + if os.path.exists(fileNameProxyIn): + raise RuntimeError("Oooops 2") + for fileNameProxyOut in fileNamesProxyOut: + if fileNameProxyOut is not None: + if os.path.exists(fileNameProxyOut): + raise RuntimeError("Oooops 3") + + # execution #2 inside last + script_st2 = """ +import logging +b = 7+a +logging.debug("Execution 2") +import time +time.sleep(1) +""" + obj2 = SALOME_PyNode.SenderByte_i(poa,pickle.dumps((["a"],{"a":3}))) + id2_o = poa.activate_object(obj2) + refPtr2 = poa.id_to_reference(id2_o) + pyscript2.assignNewCompiledCode(script_st2) + pyscript2.executeFirst(refPtr2) + ret2_0 = pyscript2.executeSecond(["b"]) + ret2_1, fileNamesProxyOut2 = unProxyfy( ret2_0 ) + logging.debug( fileNamesProxyOut2 ) + a = salome.logm.NaiveFetch() + del ret2_1 + import gc ; gc.collect() + for fileNameProxyOut in fileNamesProxyOut2: + if fileNameProxyOut is not None: + if os.path.exists(fileNameProxyOut): + raise RuntimeError("Oooops 3") + # + fname = os.path.join(str( tmpdirname ),"perf.log") + salome.logm.DumpInFile( fname ) + logManagerInst0 = salome.logm.LoadFromFile( fname ) + logging.debug( logManagerInst0[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important + logManagerInst = salome.logm.Fetch(True) + logManagerInst2 = salome.logm.Fetch(True) + logging.debug( logManagerInst[0][1][0].get()._input_hdd_mem._data[1]._data[0]._data[0]._hdd_mem ) # important + self.assertTrue( logManagerInst2[0][1][0].get() is None ) + self.assertTrue( logManagerInst[0][1][1].get()._output_hdd_mem._data[0]._file_name == fileNamesProxyOut2[0] ) + logging.debug( logManagerInst[0][1][1].log() ) + cont.Shutdown() + +if __name__ == '__main__': + from salome_utils import positionVerbosityOfLoggerRegardingState,setVerboseLevel,setVerbose + salome.standalone() + salome.salome_init() + setVerboseLevel(logging.DEBUG) + positionVerbosityOfLoggerRegardingState() + unittest.main() -- 2.39.2