Catch exceptions when updating gauge values
This commit is contained in:
parent
2ddefe1154
commit
b59707d3a7
1 changed files with 13 additions and 10 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue