base
Rate Limit Protocols for Synchronous and Asynchronous Context Managers
AsyncRateLimit
Bases: Protocol
Asynchronous Rate Limit Protocol
Source code in limitor/base.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
__aenter__()
Enter the context manager, acquiring resources if necessary
This method should return an instance of AsyncRateLimit
Returns:
Type | Description |
---|---|
AsyncRateLimit
|
An instance of the rate limit context manager |
Source code in limitor/base.py
47 48 49 50 51 52 53 54 |
|
__aexit__(exc_type, exc_val, exc_tb)
Exit the context manager, releasing any resources if necessary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc_type
|
type[BaseException]
|
The type of the exception raised, if any |
required |
exc_val
|
BaseException
|
The value of the exception raised, if any |
required |
exc_tb
|
TracebackType
|
The traceback object, if any |
required |
Source code in limitor/base.py
56 57 58 59 60 61 62 63 |
|
acquire()
Acquire an item from the rate limit. This method should block until a token is available
Source code in limitor/base.py
44 45 |
|
SyncRateLimit
Bases: Protocol
Synchronous Rate Limit Protocol
Source code in limitor/base.py
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 |
|
__enter__()
Enter the context manager, acquiring resources if necessary
This method should return an instance of SyncRateLimit
Returns:
Type | Description |
---|---|
SyncRateLimit
|
An instance of the rate limit context manager |
Source code in limitor/base.py
18 19 20 21 22 23 24 25 26 |
|
__exit__(exc_type, exc_val, exc_tb)
Exit the context manager, releasing any resources if necessary
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc_type
|
type[BaseException]
|
The type of the exception raised, if any |
required |
exc_val
|
BaseException
|
The value of the exception raised, if any |
required |
exc_tb
|
TracebackType
|
The traceback object, if any |
required |
Source code in limitor/base.py
28 29 30 31 32 33 34 35 |
|
acquire()
Acquire an item from the rate limit. This method should block until a token is available
Source code in limitor/base.py
15 16 |
|