def __init__(self, filename): self.filename = filename self.lockfilename = filename + '.locked' self.locked = 0 # Avoid deadlocks ExitFunctions.register(self.unlock)
def __del__(self): if self.locked: self.unlock(0) try: ExitFunctions.deregister(self.unlock) except: pass