added ratelimiting
This commit is contained in:
parent
efdcc84ae7
commit
d08fbe887f
|
|
@ -1,3 +1,5 @@
|
|||
pytest
|
||||
click
|
||||
psycopg2
|
||||
psycopg2-binary
|
||||
ratelimit
|
||||
backoff
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
from ratelimit.decorators import sleep_and_retry
|
||||
import requests
|
||||
from ratelimit import limits, RateLimitException
|
||||
from backoff import expo, on_exception
|
||||
|
||||
|
||||
class Leetify:
|
||||
|
|
@ -6,6 +9,8 @@ class Leetify:
|
|||
profile_base_url = f"{api_base_url}/profile"
|
||||
match_base_url = f"{api_base_url}/games"
|
||||
|
||||
@sleep_and_retry
|
||||
@limits(1, 5)
|
||||
def __get_page(self, url: str) -> dict:
|
||||
resp = requests.get(url)
|
||||
return resp.json()
|
||||
|
|
|
|||
Loading…
Reference in New Issue