dico.http.ratelimit module
- class dico.http.ratelimit.RatelimitHandler
Bases:
objectRate limit handler for
async_http.AsyncHTTPRequest.- Variables:
lockers – Dictionary of lockers per buckets.
buckets – Dictionary of buckets to be used for the route.
global_locker – Locker for global rate limit situation.
- static to_locker_key(meth, route)
Merges method and route.
- property utc
Current time as UTC. Used for calculation of rate limit expiration time.
- get_locker(meth, route)
Gets locker based on method and route passed.
- Parameters:
meth – Method of the request.
route – Route of the request.
- Returns:
Format of:
{"lock": LOCKER_INSTANCE, "reset_at": EXPIRATION_TIME, "remaining": REMAINING_COUNT}
- set_bucket(meth, route, bucket, reset_after, reset_at, remaining)
Creates bucket based on rate limit response headers.
- Parameters:
meth – Method of the request.
route – Route of the request.
bucket – Bucket of the request.
reset_after – Second of the reset time left.
reset_at – Timestamp of when the rate limit resets.
remaining – Remaining request count.
- async maybe_global()
Waits until global lock expires.