from their readthedocs:
API
class aiolimiter.AsyncLimiter(max_rate, time_period=60)
A leaky bucket rate limiter.
This is an asynchronous context manager; when used with async with, entering the context acquires capacity:
limiter = AsyncLimiter(10)
for foo in bar:
async with limiter:
# process foo elements at 10 items per minute
Parameters:
max_rate (float) – Allow up to max_rate / time_period acquisitions before blocking.
time_period (float) – duration, in seconds, of the time period in which to limit the rate. Note that up to max_rate acquisitions are allowed within this time period in a burst.
async acquire(amount=1)
Acquire capacity in the limiter.
If the limit has been reached, blocks until enough capacity has been freed before returning.
Parameters:
amount (float) – How much capacity you need to be available.
Exception:
Raises ValueError if amount is greater than max_rate.
Return type:
None
has_capacity(amount=1)
Check if there is enough capacity remaining in the limiter
Parameters:
amount (float) – How much capacity you need to be available.
Return type:
bool
max_rate: float
The configured max_rate value for this limiter.
time_period: float
The configured time_period value for this limiter.