Simply pass wait_timeout=None to RedisLock allowing the worker to keep trying to get a lock for when the leader eventually fails. The main complication here is extending the lock and validating the leader still owns it. from aioredis_lock import RedisLock # if the lock is lost, we still want to be a follower while True : # wait indefinitely to. Example #1. def _create_redis_session(self) -> None: """ Create the Redis connection pool, and then open the redis event gate. If constants.Redis.use_fakeredis is True, we'll set up a fake redis pool instead of attempting to communicate with a real Redis server. This is useful because it means contributors don't necessarily need to get Redis. Issues · mattrasband/ aioredis - lock · GitHub mattrasband / aioredis - lock Public Notifications Star 12 Fork 6 Code Issues 2 Pull requests 1 Actions Security Insights New issue 2 Open 3 Closed Let's postpone to 3.9 I recall at.
Basic usage. import asyncio import aioredis from aioredlock_py import Redisson async def single_thread(redis): for _ in range(10): async with Redisson(redis, key="no1") as lock: if not lock: # If the lock still fails after several attempts, `__aenter__` # will return None to prompt you to cancel the following execution return 'Do something. Implement aioredis-lock with how-to, Q&A, fixes, code snippets. kandi ratings - Low support, No Bugs, 2 Code smells, Permissive License, Build available. aioredis-lock is a Python library typically used in Programming Style. Support for redis-py <4.2 with aioredis. Aioredis is now in redis-py 4.2.0. But support is maintained until fakeredis 2 for older version of redis-py. You can also use fakeredis to mock out aioredis. This is a much newer addition to fakeredis (added in 1.4.0) with less testing, so your mileage may vary.