コード例 #1
0
 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
コード例 #2
0
ファイル: vfs_local.py プロジェクト: nom3ad/obnam
 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
コード例 #3
0
ファイル: lockmgr.py プロジェクト: dfries/obnam
 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()
コード例 #4
0
 def lock(self, lockname):
     try:
         self.write_file(lockname, '')
     except OSError, e:
         raise obnamlib.LockFail(lock_name=lockname, reason=str(e))