redis-py
redis-py copied to clipboard
asyncio (aioredis) lock never being acquired
Thanks for wanting to report an issue you've found in redis-py. Please delete this text and fill in the template below.
It is of course not always possible to reduce your code to a small test case, but it's highly appreciated to have as much data as possible. Thank you!
Version: What redis-py and what redis version is the issue happening on? redis>=4.2.0rc1
Platform: What platform / version? (For example Python 3.5.1 on Windows 7 / Ubuntu 15.10 / Azure) Python 3.8.16 on MacOS Big Sur
Description: Description of your issue, stack traces from errors and code that reproduces the issue
redis lock acquiring not working - stays running and never acquires
this is my code:
pool = aioredis.ConnectionPool.from_url("redis://localhost:6379")
redis = await aioredis.Redis(connection_pool=pool, ssl=False, ssl_cert_reqs="None")
async with redis.lock("hello_lock") as lock:
print("hello")
await redis.hset("hello", "1", "2")
the Context Manager never gets entered and it seems like the lock is not being acquired at all. The program stays running/stuck on this line:
async with redis.lock("hello_lock") as lock:
Acquiring the lock should be a very quick thing so i'm confused whats happening here. Any help would be appreciated.
hi @3awny have you tried using a different version of python and redis-py? I'm currently looking into using async redis lock with fastapi, but could not find any example online. Not sure if it will work...
This issue is marked stale. It will be closed in 30 days if it is not updated.