I'm using python module ratelimit
to throttle a function, which calls a rest api, I need to apply throttle based on the method of the requests, e.g. for PUT/POST/DELETE
1 per 10s, for GET
5 per 1s, how can I achieve this without break the function into two?
from ratelimit import limits, sleep_and_retry
@sleep_and_retry
@limits(calls=1 if method != 'GET' else 5), period=10 if method != 'GET' else 1)
def callrest(method, url, data):
...
Is it possible to do this?
from How to apply rate limit based on method parameter
No comments:
Post a Comment