def __exit__(self, type, value, traceback): self.depth -= 1 if self.depth <= 0: self.locked_by = None Lock.__exit__(self, type, value, traceback)