MCPcopy
hub / github.com/borgbackup/borg / acquire

Method acquire

src/borg/fslocking.py:412–425  ·  view source on GitHub ↗
(self, exclusive=None, remove=None, sleep=None)

Source from the content-addressed store, hash-verified

410 return f"<{self.__class__.__name__}: {self.id!r}>"
411
412 def acquire(self, exclusive=None, remove=None, sleep=None):
413 if exclusive is None:
414 exclusive = self.is_exclusive
415 sleep = sleep or self.sleep or 0.2
416 if exclusive:
417 self._wait_for_readers_finishing(remove, sleep)
418 self._roster.modify(EXCLUSIVE, ADD)
419 else:
420 with self._lock:
421 if remove is not None:
422 self._roster.modify(remove, REMOVE)
423 self._roster.modify(SHARED, ADD)
424 self.is_exclusive = exclusive
425 return self
426
427 def _wait_for_readers_finishing(self, remove, sleep):
428 timer = TimeoutTimer(self.timeout, sleep).start()

Callers 15

__enter__Method · 0.95
upgradeMethod · 0.95
downgradeMethod · 0.95
openMethod · 0.45
openMethod · 0.45
test_exclusive_lockMethod · 0.45
test_break_lockMethod · 0.45
test_migrate_lockMethod · 0.45

Calls 2

modifyMethod · 0.80

Tested by 15

test_exclusive_lockMethod · 0.36
test_break_lockMethod · 0.36
test_migrate_lockMethod · 0.36
test_timeoutMethod · 0.36
test_kill_staleMethod · 0.36
test_migrate_lockMethod · 0.36
test_sharedMethod · 0.36
test_breakMethod · 0.36