def lock(self, lockname, data): tracing.trace('attempting lockname=%s', lockname) try: self.write_file(lockname, data) except OSError, e: if e.errno == errno.EEXIST: raise obnamlib.LockFail(lock_name=lockname, reason='already exists') else: raise # pragma: no cover
def lock(self, lockname): tracing.trace('attempting lockname=%s', lockname) try: tempname = self._create_tempfile(lockname) self._rename_temp_to_real(tempname, lockname) except OSError, e: if e.errno == errno.EEXIST: raise obnamlib.LockFail(lock_name=lockname, reason='already exists') else: raise # pragma: no cover
def _lock_one(self, dirname): started = self._time() while True: lock_name = self._lockname(dirname) try: self._fs.lock(lock_name, self.data) except obnamlib.LockFail: if self._time() - started >= self.timeout: raise obnamlib.LockFail(lock_name=lock_name, reason='timeout') else: return self._sleep()
def lock(self, lockname): try: self.write_file(lockname, '') except OSError, e: raise obnamlib.LockFail(lock_name=lockname, reason=str(e))