mirror of
https://github.com/borgbackup/borg.git
synced 2026-06-14 20:13:21 -04:00
locking: no traceback on lock timeout (expected)
This commit is contained in:
parent
0e183b225d
commit
a509a0c463
3 changed files with 5 additions and 6 deletions
|
|
@ -186,8 +186,7 @@ class Lock:
|
|||
self._delete_lock(key, ignore_not_found=True)
|
||||
# wait a random bit before retrying
|
||||
time.sleep(self.retry_delay_min + (self.retry_delay_max - self.retry_delay_min) * random.random())
|
||||
# timeout
|
||||
raise LockFailed(str(self.store), "timeout")
|
||||
raise LockTimeout(str(self.store))
|
||||
|
||||
def release(self):
|
||||
locks = self._find_locks(only_mine=True)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ def test_with_lock(tmp_path):
|
|||
out, err_out = p2.communicate()
|
||||
assert "second command" not in out # command2 is "locked out"
|
||||
assert "Failed to create/acquire the lock" in err_out
|
||||
assert p2.returncode == 72 # LockTimeout: could not acquire the lock, p1 already has it
|
||||
assert p2.returncode == 73 # LockTimeout: could not acquire the lock, p1 already has it
|
||||
out, err_out = p1.communicate()
|
||||
assert "first command" in out # command1 was executed and had the lock
|
||||
assert not err_out
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import pytest
|
|||
|
||||
from borgstore.store import Store
|
||||
|
||||
from ..storelocking import Lock, LockFailed, NotLocked
|
||||
from ..storelocking import Lock, NotLocked, LockTimeout
|
||||
|
||||
ID1 = "foo", 1, 1
|
||||
ID2 = "bar", 2, 2
|
||||
|
|
@ -37,11 +37,11 @@ class TestLock:
|
|||
def test_exclusive_lock(self, lockstore):
|
||||
# there must not be 2 exclusive locks
|
||||
with Lock(lockstore, exclusive=True, id=ID1):
|
||||
with pytest.raises(LockFailed):
|
||||
with pytest.raises(LockTimeout):
|
||||
Lock(lockstore, exclusive=True, id=ID2).acquire()
|
||||
# acquiring an exclusive lock will time out if the non-exclusive does not go away
|
||||
with Lock(lockstore, exclusive=False, id=ID1):
|
||||
with pytest.raises(LockFailed):
|
||||
with pytest.raises(LockTimeout):
|
||||
Lock(lockstore, exclusive=True, id=ID2).acquire()
|
||||
|
||||
def test_double_nonexclusive_lock_succeeds(self, lockstore):
|
||||
|
|
|
|||
Loading…
Reference in a new issue