Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion redis/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,13 @@ def release(self) -> None:
"""
expected_token = self.local.token
if expected_token is None:
raise LockError("Cannot release an unlocked lock", lock_name=self.name)
if self.owned():
raise LockError("Cannot release an unlocked lock", lock_name=self.name)
else:
raise LockNotOwnedError(
"Cannot release a lock that's no longer owned",
lock_name=self.name,
)
self.local.token = None
self.do_release(expected_token)

Expand Down