DicoForProxyFile = { }
-from ctypes import c_int
-TypeCounter = c_int
-
-def GetSizeOfTCnt():
- return len( bytes(TypeCounter(0) ) )
-
def GetSizeOfBufferedReader(f):
"""
This method returns in bytes size of a file openned.
def GetObjectFromFile(fname, visitor = None):
with open(fname,"rb") as f:
- cntb = f.read( GetSizeOfTCnt() )
- cnt = TypeCounter.from_buffer_copy( cntb ).value
if visitor:
visitor.setHDDMem( GetSizeOfBufferedReader(f) )
visitor.setFileName( fname )
obj = pickle.load(f)
- return obj,cnt
+ return obj
def DumpInFile(obj,fname):
with open(fname,"wb") as f:
- f.write( bytes( TypeCounter(1) ) )
f.write( obj )
def IncrRefInFile(fname):
DicoForProxyFile[fname] = 2
pass
-def IncrRefInFileOld(fname):
- with open(fname,"rb") as f:
- cntb = f.read( GetSizeOfTCnt() )
- cnt = TypeCounter.from_buffer_copy( cntb ).value
- with open(fname,"rb+") as f:
- #import KernelServices ; KernelServices.EntryForDebuggerBreakPoint()
- f.write( bytes( TypeCounter(cnt+1) ) )
-
def DecrRefInFile(fname):
if fname not in DicoForProxyFile:
cnt = 1
os.unlink( fname )
pass
-def DecrRefInFileOld(fname):
- import os
- with open(fname,"rb") as f:
- cntb = f.read( GetSizeOfTCnt() )
- cnt = TypeCounter.from_buffer_copy( cntb ).value
- #
- #import KernelServices ; KernelServices.EntryForDebuggerBreakPoint()
- if cnt == 1:
- os.unlink( fname )
- else:
- with open(fname,"rb+") as f:
- f.write( bytes( TypeCounter(cnt-1) ) )
-
def GetBigObjectOnDiskThreshold():
import os
if SALOME_BIG_OBJ_ON_DISK_THRES_VAR in os.environ:
DumpInFile( objSerialized, self._filename )
def get(self, visitor = None):
- obj, _ = GetObjectFromFile( self._filename, visitor )
+ obj = GetObjectFromFile( self._filename, visitor )
return obj
def __float__(self):