Skip to content

redis backend should accept/persist a blocking_timeout for locks #271

Description

@jvanasco

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions