mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 07:16:40 +00:00
Merge branch '114-fix-coingecko-too-many-requests-error' into 'master'
Resolve "Fix coingecko too many requests error" Closes #114 See merge request simple-stock-bots/simple-stock-bot!62
This commit is contained in:
commit
6229a5d4b6
@ -9,6 +9,8 @@ from markdownify import markdownify
|
|||||||
from common.Symbol import Coin
|
from common.Symbol import Coin
|
||||||
from common.utilities import rate_limited
|
from common.utilities import rate_limited
|
||||||
|
|
||||||
|
import time
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -34,6 +36,12 @@ class cg_Crypto:
|
|||||||
url = "https://api.coingecko.com/api/v3" + endpoint
|
url = "https://api.coingecko.com/api/v3" + endpoint
|
||||||
resp = r.get(url, params=params, timeout=timeout)
|
resp = r.get(url, params=params, timeout=timeout)
|
||||||
# Make sure API returned a proper status code
|
# Make sure API returned a proper status code
|
||||||
|
|
||||||
|
if resp.status_code == 429:
|
||||||
|
log.warning(f"CoinGecko returned 429 - Too Many Requests for endpoint: {endpoint}. Sleeping and trying again.")
|
||||||
|
time.sleep(10)
|
||||||
|
return self.get(endpoint=endpoint, params=params, timeout=timeout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
except r.exceptions.HTTPError as e:
|
except r.exceptions.HTTPError as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user