Catch exceptions when updating gauge values

This commit is contained in:
Kumi 2022-10-24 14:28:01 +00:00
parent 2ddefe1154
commit b59707d3a7
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -153,6 +153,7 @@ start_http_server(8090)
while True: while True:
for gauge, aks in gauges: for gauge, aks in gauges:
try:
offers: List[dict] = aks.get_offers() offers: List[dict] = aks.get_offers()
available_offers: List[dict] = filter( available_offers: List[dict] = filter(
lambda x: x["stock"] == "InStock", offers) lambda x: x["stock"] == "InStock", offers)
@ -165,5 +166,7 @@ while True:
best_offer: dict = min( best_offer: dict = min(
available_offers, key=lambda x: x["price"][currency]["price"]) available_offers, key=lambda x: x["price"][currency]["price"])
gauge.set(best_offer["price"][currency]["price"]) gauge.set(best_offer["price"][currency]["price"])
except Exception as e:
print(f"Error updating gauge value for {gauge._name}: {e}")
time.sleep(60) time.sleep(60)