add stubs for redis.lock (#5105)

This commit is contained in:
Árni Már Jónsson
2021-03-23 02:08:12 +00:00
committed by GitHub
parent 6170697b25
commit 82cd7d22c6

View File

@@ -0,0 +1,41 @@
from types import TracebackType
from typing import Optional, Text, Type, Union
from redis.client import Redis
_TokenValue = Union[bytes, Text]
class Lock:
def __init__(
self,
redis: Redis,
name: str,
timeout: Union[None, int, float] = ...,
sleep: float = ...,
blocking: bool = ...,
blocking_timeout: Optional[bool] = ...,
thread_local: bool = ...,
) -> None: ...
def register_scripts(self) -> None: ...
def __enter__(self) -> Lock: ...
def __exit__(
self,
exc_type: Optional[Type[BaseException]],
exc_value: Optional[BaseException],
traceback: Optional[TracebackType],
) -> Optional[bool]: ...
def acquire(
self,
blocking: Optional[bool] = ...,
blocking_timeout: Union[None, int, float] = ...,
token: Optional[_TokenValue] = ...,
) -> bool: ...
def do_acquire(self, token: _TokenValue) -> bool: ...
def locked(self) -> bool: ...
def owned(self) -> bool: ...
def release(self) -> None: ...
def do_release(self, expected_token: _TokenValue) -> None: ...
def extend(self, additional_time: Union[int, float], replace_ttl: bool = ...) -> bool: ...
def do_extend(self, additional_time: Union[int, float], replace_ttl: bool) -> bool: ...
def reacquire(self) -> bool: ...
def do_reacquire(self) -> bool: ...