Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing "blocking" argument when initializing blocking in asynchronous mode #2453

Closed
Sibuken opened this issue Nov 11, 2022 · 1 comment
Closed

Comments

@Sibuken
Copy link
Contributor

Sibuken commented Nov 11, 2022

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: 4.3.4

Platform: Python 3.11.0 on Mac OS

Description: I am trying use async lock but if you try init lock from Redis class, you will find that you can't use argument blocking from Lock class.

from redis import asyncio as aioredis


r = aioredis.from_url("redis://localhost:6379", decode_responses=True, encoding="utf-8")
async with r.lock("test", blocking=False):
    ...

but I can use next syntax:

from redis import asyncio as aioredis
from redis.asyncio.lock import Lock as AsyncLock


r = aioredis.from_url("redis://localhost:6379", decode_responses=True, encoding="utf-8")
async with AsyncLock("test", blocking=False)

Lock initialization function in a Redis class.

def lock(
        self,
        name: KeyT,
        timeout: Optional[float] = None,
        sleep: float = 0.1,
        blocking_timeout: Optional[float] = None,
        lock_class: Optional[Type[Lock]] = None,
        thread_local: bool = True,
    ) -> Lock:
...

Lock class

def __init__(
        self,
        redis: "Redis",
        name: Union[str, bytes, memoryview],
        timeout: Optional[float] = None,
        sleep: float = 0.1,
        blocking: bool = True,
        blocking_timeout: Optional[float] = None,
        thread_local: bool = True,
    ):
...
@uglide
Copy link
Contributor

uglide commented Feb 8, 2023

Fixed in #2454

@uglide uglide closed this as completed Feb 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants