# HG changeset patch # User RhodeCode Admin # Date 2021-07-23 09:23:42 # Node ID 757fecd5eadb86099796dec0c9ae1cf728d79a04 # Parent fbffdae7313a5091eda807028b02e03cf6692fa3 caches: further improvements on the lock implementations diff --git a/vcsserver/lib/rc_cache/backends.py b/vcsserver/lib/rc_cache/backends.py --- a/vcsserver/lib/rc_cache/backends.py +++ b/vcsserver/lib/rc_cache/backends.py @@ -288,11 +288,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, @@ -301,8 +298,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: