Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82cd7d2

Browse files
authored
add stubs for redis.lock (#5105)
1 parent 6170697 commit 82cd7d2

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

stubs/redis/redis/lock.pyi

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from types import TracebackType
2+
from typing import Optional, Text, Type, Union
3+
4+
from redis.client import Redis
5+
6+
_TokenValue = Union[bytes, Text]
7+
8+
class Lock:
9+
def __init__(
10+
self,
11+
redis: Redis,
12+
name: str,
13+
timeout: Union[None, int, float] = ...,
14+
sleep: float = ...,
15+
blocking: bool = ...,
16+
blocking_timeout: Optional[bool] = ...,
17+
thread_local: bool = ...,
18+
) -> None: ...
19+
def register_scripts(self) -> None: ...
20+
def __enter__(self) -> Lock: ...
21+
def __exit__(
22+
self,
23+
exc_type: Optional[Type[BaseException]],
24+
exc_value: Optional[BaseException],
25+
traceback: Optional[TracebackType],
26+
) -> Optional[bool]: ...
27+
def acquire(
28+
self,
29+
blocking: Optional[bool] = ...,
30+
blocking_timeout: Union[None, int, float] = ...,
31+
token: Optional[_TokenValue] = ...,
32+
) -> bool: ...
33+
def do_acquire(self, token: _TokenValue) -> bool: ...
34+
def locked(self) -> bool: ...
35+
def owned(self) -> bool: ...
36+
def release(self) -> None: ...
37+
def do_release(self, expected_token: _TokenValue) -> None: ...
38+
def extend(self, additional_time: Union[int, float], replace_ttl: bool = ...) -> bool: ...
39+
def do_extend(self, additional_time: Union[int, float], replace_ttl: bool) -> bool: ...
40+
def reacquire(self) -> bool: ...
41+
def do_reacquire(self) -> bool: ...

0 commit comments

Comments
 (0)