# HG changeset patch # User RhodeCode Admin # Date 2021-07-23 09:21:58 # Node ID 55ad1bd880caa94023d5000deee1778ef04e80ef # Parent 2e56987b8e9c5a52ed7b46a74930cbc902f97ab0 caches: use the same lock instance, otherwise we won't release it. Also handle AlreadyAquired so locks skip that case and not throw a 500 error diff --git a/rhodecode/lib/rc_cache/backends.py b/rhodecode/lib/rc_cache/backends.py --- a/rhodecode/lib/rc_cache/backends.py +++ b/rhodecode/lib/rc_cache/backends.py @@ -323,11 +323,8 @@ def get_mutex_lock(client, lock_key, loc class _RedisLockWrapper(object): """LockWrapper for redis_lock""" - def __init__(self): - pass - - @property - def lock(self): + @classmethod + def get_lock(cls): return redis_lock.Lock( redis_client=client, name=lock_key, @@ -336,8 +333,14 @@ def get_mutex_lock(client, lock_key, loc strict=True, ) + def __init__(self): + self.lock = self.get_lock() + def acquire(self, wait=True): - return self.lock.acquire(wait) + try: + return self.lock.acquire(wait) + except redis_lock.AlreadyAquited: + return False def release(self): try: