From 75156042443781f630d126422fa8e09ad8a90b5a Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 25 Aug 2023 09:49:51 +0200 Subject: [PATCH] Temporary disable proxy file deletion to have time to solve refcnt problem --- src/Container/SALOME_PyNode.py | 14 +++++++++++++- src/Container/Test/testProxy.py | 18 +++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index d98ae6cfa..df59850ca 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -155,7 +155,10 @@ def DecrRefInFile(fname): cnt = TypeCounter.from_buffer_copy( cntb ).value # if cnt == 1: - os.unlink( fname ) + pass + #print("Remove {}".format(fname)) + #print("Remove {}".format(str(GetObjectFromFile(fname)[0]))) + #os.unlink( fname ) else: with open(fname,"rb+") as f: f.write( bytes( TypeCounter(cnt-1) ) ) @@ -233,6 +236,15 @@ class BigObjectOnDiskBase: if self._destroy: DecrRefInFile( self._filename ) + def delDebug(self): + import os + if self._destroy: + if os.path.exists( self._filename ): + DecrRefInFile( self._filename ) + else: + import KernelServices + KernelServices.GenerateViolentMemoryFaultForTestPurpose() + def getFileName(self): return self._filename diff --git a/src/Container/Test/testProxy.py b/src/Container/Test/testProxy.py index d3e7b50db..4ed4dce82 100644 --- a/src/Container/Test/testProxy.py +++ b/src/Container/Test/testProxy.py @@ -70,9 +70,9 @@ c = os.environ["SALOME_BIG_OBJ_ON_DISK_THRES"] j = a,b,c""" pyscript = cont.createPyScriptNode("testScript",script_st) a,b,c = pickle.loads(pyscript.execute(["j"],pickle.dumps(([],{}))))[0] - assert( a == val_for_big_obj ) - assert( b == val_for_jj ) - assert( c == val_for_thres ) + self.assertTrue( a == val_for_big_obj ) + self.assertTrue( b == val_for_jj ) + self.assertTrue( c == val_for_thres ) # check environment using POSIX API in the container process for k,v in [("SALOME_FILE_BIG_OBJ_DIR",val_for_big_obj),("SALOME_BIG_OBJ_ON_DISK_THRES",val_for_thres),("jj",val_for_jj)]: assert( {elt.key:elt.value.value() for elt in cont.get_os_environment()}[k] == v ) @@ -86,19 +86,19 @@ j = a,b,c""" pyscript2 = cont.createPyScriptNode("testScript2",script_st2) pyscript2.executeFirst(refPtr) ret2 = pyscript2.executeSecond(["ob"]) - assert( len(ret2) == 1) + self.assertTrue( len(ret2) == 1) ret2 = ret2[0] ret3 = pickle.loads( SALOME_PyNode.SeqByteReceiver(ret2).data() ) - assert( isinstance( ret3, SALOME_PyNode.BigObjectOnDiskList ) ) - assert( val_for_big_obj == os.path.dirname( ret3.getFileName() ) )# very important part of test - assert( ret3.get() == list(range(100)) ) + self.assertTrue( isinstance( ret3, SALOME_PyNode.BigObjectOnDiskList ) ) + self.assertTrue( val_for_big_obj == os.path.dirname( ret3.getFileName() ) )# very important part of test + self.assertTrue( ret3.get() == list(range(100)) ) fn = ret3.getFileName() - assert( os.path.exists( fn ) ) + self.assertTrue( os.path.exists( fn ) ) ret3.unlinkOnDestructor() del ret3 import gc gc.collect(0) - assert( not os.path.exists( fn ) ) # at destruction of ret3 the corresponding pckl file must be destructed + #self.assertTrue( not os.path.exists( fn ) ) # at destruction of ret3 the corresponding pckl file must be destructed cont.Shutdown() if __name__ == '__main__': -- 2.39.2