Jelajahi Sumber

locking: no traceback on lock timeout (expected)

Thomas Waldmann 9 bulan lalu
induk
melakukan
a509a0c463

+ 1 - 2
src/borg/storelocking.py

@@ -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)

+ 1 - 1
src/borg/testsuite/archiver/lock_cmds.py

@@ -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

+ 3 - 3
src/borg/testsuite/storelocking.py

@@ -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):