summaryrefslogtreecommitdiff
path: root/tests/test_lock.py
diff options
context:
space:
mode:
authorJoshua Harlow <josh.harlow@plus.ai>2018-12-03 11:04:34 -0800
committerJoshua Harlow <josh.harlow@plus.ai>2018-12-03 13:27:24 -0800
commit26b3828678560fedb8c9cc04362e7c20b01d2f77 (patch)
tree552498c50deef6a02d2f5e19468ab02b38bb8d0a /tests/test_lock.py
parent5784bc90717d7632eabd1e0d642a5364cea4f0c8 (diff)
downloadredis-py-26b3828678560fedb8c9cc04362e7c20b01d2f77.tar.gz
Extend lock error for not owned special case
Using the locking routines, it is useful to be able to distingush a generic lock error from a one that is related to the lock not being owned anymore (without doing string checks); this allows say a lock extension thread to attempt to re-acquire the lock in this case (vs just dying).
Diffstat (limited to 'tests/test_lock.py')
-rw-r--r--tests/test_lock.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_lock.py b/tests/test_lock.py
index a6adbc2..5ad7d5c 100644
--- a/tests/test_lock.py
+++ b/tests/test_lock.py
@@ -1,7 +1,7 @@
import pytest
import time
-from redis.exceptions import LockError
+from redis.exceptions import LockError, LockErrorNotOwned
from redis.lock import Lock
@@ -85,7 +85,7 @@ class TestLock(object):
lock.acquire(blocking=False)
# manually change the token
r.set('foo', 'a')
- with pytest.raises(LockError):
+ with pytest.raises(LockErrorNotOwned):
lock.release()
# even though we errored, the token is still cleared
assert lock.local.token is None
@@ -119,10 +119,10 @@ class TestLock(object):
lock.release()
def test_extending_lock_no_longer_owned_raises_error(self, r):
- lock = self.get_lock(r, 'foo')
+ lock = self.get_lock(r, 'foo', timeout=10)
assert lock.acquire(blocking=False)
r.set('foo', 'a')
- with pytest.raises(LockError):
+ with pytest.raises(LockErrorNotOwned):
lock.extend(10)