def release_lock(lock_name, token):
"""
Release a lock
Args:
lock_name (str): The lock key in redis
token (bytes): The unique id used
Returns:
bool: True if the lock was successfully released
"""
# this is a StrictRedis instance, we need this for the script installation that LuaLock uses
redis = caches['redis'].client.get_client()
lock = LuaLock(redis, lock_name)
try:
lock.do_release(token)
except LockError:
# If the lock is expired we don't want to raise an error
pass
评论列表
文章目录