limitor
Main module for rate limiting functionality.
async_rate_limit(capacity=10, seconds=1, max_concurrent=None, bucket_cls=AsyncLeakyBucket)
Decorator to apply an asynchronous leaky bucket rate limit to a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
capacity
|
int
|
Maximum number of requests allowed in the bucket, defaults to 10 |
10
|
seconds
|
float
|
Time period in seconds for the bucket to refill, defaults to 1 |
1
|
max_concurrent
|
int | None
|
Maximum number of concurrent requests allowed, defaults to None (no limit) |
None
|
bucket_cls
|
type[AsyncRateLimit]
|
Bucket class, defaults to AsyncLeakyBucket |
AsyncLeakyBucket
|
Returns:
Type | Description |
---|---|
Callable
|
A decorator that applies the rate limit to the function |
Source code in limitor/__init__.py
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 62 63 |
|
rate_limit(capacity=10, seconds=1, bucket_cls=SyncLeakyBucket)
Decorator to apply a synchronous leaky bucket rate limit to a function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
capacity
|
int
|
Maximum number of requests allowed in the bucket, defaults to 10 |
10
|
seconds
|
float
|
Time period in seconds for the bucket to refill, defaults to 1 |
1
|
bucket_cls
|
type[SyncRateLimit]
|
Bucket class, defaults to SyncLeakyBucket |
SyncLeakyBucket
|
Returns:
Type | Description |
---|---|
Callable
|
A decorator that applies the rate limit to the function |
Source code in limitor/__init__.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|