Files
FeatureOrientedSkeleton/typings/aioredlock/__init__.pyi
2026-07-08 23:01:55 +04:00

96 lines
2.4 KiB
Python

from typing import Any, TypeAlias
import ssl
_RedisAddress: TypeAlias = tuple[str, int] | list[tuple[str, int]]
_RedisConnection: TypeAlias = dict[str, Any] | str | _RedisAddress | Any
class AioredlockError(Exception): ...
class LockError(AioredlockError): ...
class LockAcquiringError(LockError): ...
class LockRuntimeError(LockError): ...
class SentinelConfigError(Exception): ...
class Sentinel:
master: str
connection: list[tuple[str, int]]
redis_kwargs: dict[str, Any]
def __init__(
self,
connection: dict[str, Any] | str | _RedisAddress,
master: str | None = ...,
password: str | None = ...,
db: int | None = ...,
ssl_context: ssl.SSLContext | bool | None = ...,
) -> None: ...
async def get_sentinel(self) -> Any: ...
async def get_master(self) -> Any: ...
class Lock:
lock_manager: Aioredlock
resource: str
id: str
lock_timeout: float | None
valid: bool
def __init__(
self,
lock_manager: Aioredlock,
resource: str,
id: str,
lock_timeout: float | None = ...,
valid: bool = ...,
) -> None: ...
async def __aenter__(self) -> Lock: ...
async def __aexit__(self, exc_type: type[BaseException] | None, exc: BaseException | None, tb: Any) -> None: ...
async def extend(self) -> None: ...
async def release(self) -> None: ...
async def is_locked(self) -> bool: ...
class Aioredlock:
redis_connections: list[_RedisConnection]
retry_count: int
retry_delay_min: float
retry_delay_max: float
internal_lock_timeout: float
def __init__(
self,
redis_connections: list[_RedisConnection] = ...,
retry_count: int = ...,
retry_delay_min: float = ...,
retry_delay_max: float = ...,
internal_lock_timeout: float = ...,
) -> None: ...
async def lock(
self,
resource: str,
lock_timeout: float | None = ...,
lock_identifier: str | None = ...,
) -> Lock: ...
async def extend(self, lock: Lock, lock_timeout: float | None = ...) -> None: ...
async def unlock(self, lock: Lock) -> None: ...
async def is_locked(self, resource_or_lock: str | Lock) -> bool: ...
async def destroy(self) -> None: ...
async def get_active_locks(self) -> list[Lock]: ...
async def get_lock(self, resource: str, lock_identifier: str) -> Lock: ...
__all__: tuple[str, ...]