def release(self): logging.debug("Releasing lock on %s", self.path) if self.i_am_locking: fcntl.flock(self.lock_file.fileno(), fcntl.LOCK_UN) self._has_lock = False else: raise lockfile.NotLocked() logging.debug("Unlocked %s", self.path)
def mock_release(): if scenario['locking_pid'] is None: raise lockfile.NotLocked() if scenario['locking_pid'] != scenario['pid']: raise lockfile.NotMyLock() scenario['locking_pid'] = None