-
Notifications
You must be signed in to change notification settings - Fork 1
/
self_limiters.pyi
61 lines (50 loc) · 1.75 KB
/
self_limiters.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from types import TracebackType
from typing import Optional
class TokenBucket:
def __init__(
self,
name: str,
capacity: int,
refill_frequency: float,
refill_amount: int,
redis_url: Optional[str] = None, # will be set as "redis://127.0.0.1:6379" if None
max_sleep: Optional[float] = None, # will be set to 0.0 if None. In seconds.
connection_pool_size: Optional[int] = None, # Will be set to 15 if None
) -> None: ...
capacity: int
name: str
refill_frequency: float
refill_amount: int
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class Semaphore:
def __init__(
self,
name: str,
capacity: int,
max_sleep: Optional[float] = None, # Set to 0.0 when None is passed. In seconds.
expiry: Optional[int] = None, # Set to 30 when None is passed. In seconds.
redis_url: Optional[str] = None, # will be set as "redis://127.0.0.1:6379" if None
connection_pool_size: Optional[int] = None, # Will be set to 15 if None
) -> None: ...
capacity: int
name: str
max_sleep: float
expiry: int
async def __aenter__(self) -> None: ...
async def __aexit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
__all__: list[str]
class RedisError(Exception):
"""
Raised when the downstream redis library raises any exception.
"""
pass
class MaxSleepExceededError(Exception):
"""
Raised when we've slept for longer than the `max_sleep` specified limit.
"""
pass