The Redis client blocks by default when creating and acquiring a lock:
https://github.com/redis/redis-py/blob/master/redis/lock.py#L85-L86
https://github.com/redis/redis-py/blob/master/redis/lock.py#L190-L195
If the Redis client is unable to acquire a lock, this will cause an indefinite hang.
I hoped to address this in Redis itself (redis/redis-py#3728), however my solution was shortsighted as that can't be done without violating the existing API/documentation.
I propose the following to the redis (and valkey) backends:
- add a
lock_blocking_timeout: Optional[int] = None kwarg
- add a
lock_blocking: bool = True kwarg
This follows the lock_sleep naming convention for lock( arguments.
these would be used to create the locks, but not during acquire (which will default to the init args).
I'm not sure if its worth doing the bool argument (I can't imagine when it wouldn't be done)
The Redis client blocks by default when creating and acquiring a lock:
https://github.com/redis/redis-py/blob/master/redis/lock.py#L85-L86
https://github.com/redis/redis-py/blob/master/redis/lock.py#L190-L195
If the Redis client is unable to acquire a lock, this will cause an indefinite hang.
I hoped to address this in Redis itself (redis/redis-py#3728), however my solution was shortsighted as that can't be done without violating the existing API/documentation.
I propose the following to the redis (and valkey) backends:
lock_blocking_timeout: Optional[int] = Nonekwarglock_blocking: bool = TruekwargThis follows the
lock_sleepnaming convention forlock(arguments.these would be used to create the locks, but not during acquire (which will default to the init args).
I'm not sure if its worth doing the bool argument (I can't imagine when it wouldn't be done)