oai.rate_limiters
TimeRateLimiter
class TimeRateLimiter()
A class to implement a time-based rate limiter.
This rate limiter ensures that a certain operation does not exceed a specified frequency. It can be used to limit the rate of requests sent to a server or the rate of any repeated action.
__init__
def __init__(rate: float)
Arguments:
rate
int - The frequency of the time-based rate limiter (NOT time interval).
sleep
def sleep(*args, **kwargs)
Synchronously waits until enough time has passed to allow the next operation.
If the elapsed time since the last operation is less than the required time interval, this method will block the execution by sleeping for the remaining time.