aboutsummaryrefslogtreecommitdiffstats
path: root/python/api_quotes
diff options
context:
space:
mode:
Diffstat (limited to 'python/api_quotes')
-rw-r--r--python/api_quotes/__main__.py11
-rw-r--r--python/api_quotes/api.py2
2 files changed, 11 insertions, 2 deletions
diff --git a/python/api_quotes/__main__.py b/python/api_quotes/__main__.py
index eae330d3..d75f7ca9 100644
--- a/python/api_quotes/__main__.py
+++ b/python/api_quotes/__main__.py
@@ -15,6 +15,7 @@ logger = logging.getLogger(__name__)
def process_asset_class(asset_class, start_from, end):
already_uploaded = MarkitQuoteKind[asset_class].already_uploaded()
+ retry = 0
while True:
try:
if data := MarkitAPI.get_data(asset_class, start_from):
@@ -48,9 +49,15 @@ def process_asset_class(asset_class, start_from, end):
else:
return
except JSONDecodeError:
- print(f"Issue with {asset_class}: {start_from}")
+ logger.error(f"Issue with {asset_class}: {start_from}")
+ return
except AttributeError:
- MarkitAPI.update_api_key()
+ if retry < 3:
+ MarkitAPI.update_api_key()
+ else:
+ logger.error("API failed after 3 tries")
+ return
+ retry += 1
if __name__ == "__main__":
diff --git a/python/api_quotes/api.py b/python/api_quotes/api.py
index 7d6e36bc..3850b0fe 100644
--- a/python/api_quotes/api.py
+++ b/python/api_quotes/api.py
@@ -53,3 +53,5 @@ class MarkitAPI:
@classmethod
def update_api_key(cls):
cls.base_url, cls.api_key = load_api_key()
+ if "APIKEY_LIMIT_EXCEEDED" in cls.api_key:
+ raise ValueError("API Key limit exceeded")