redis-py icon indicating copy to clipboard operation
redis-py copied to clipboard

asyncio (aioredis) lock never being acquired

Open 3awny opened this issue 1 year ago • 2 comments

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.

3awny avatar Mar 22 '23 00:03 3awny

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...

MXSH-Dev avatar Apr 24 '23 04:04 MXSH-Dev

This issue is marked stale. It will be closed in 30 days if it is not updated.

github-actions[bot] avatar Apr 24 '24 00:04 github-actions[bot]