From b1ee7ac1f2ef694d63629750bb325d3d714501cf Mon Sep 17 00:00:00 2001 From: Shroominic Date: Sat, 3 May 2025 04:20:00 +0800 Subject: [PATCH] add error handling --- router/models.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/router/models.py b/router/models.py index a4d36f21..ee125808 100644 --- a/router/models.py +++ b/router/models.py @@ -42,9 +42,12 @@ with open("models.json", "r") as f: async def update_sats_pricing() -> None: while True: - sats_to_usd = await sats_usd_ask_price() - for model in MODELS: - model.sats_pricing = Pricing( - **{k: v / sats_to_usd for k, v in model.pricing.dict().items()} - ) + try: + sats_to_usd = await sats_usd_ask_price() + for model in MODELS: + model.sats_pricing = Pricing( + **{k: v / sats_to_usd for k, v in model.pricing.dict().items()} + ) + except Exception as e: + print(e) await asyncio.sleep(10)