From 866900e4831b118645b98ce92268cd5c6b879079 Mon Sep 17 00:00:00 2001 From: sgrtye Date: Fri, 11 Oct 2024 01:20:09 +0100 Subject: [PATCH] health check only fails when no ticker responses --- apiserver/main.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apiserver/main.py b/apiserver/main.py index 5aea700..9e3c770 100644 --- a/apiserver/main.py +++ b/apiserver/main.py @@ -202,20 +202,19 @@ def get_info_by_ticker(tickers): info = dict() tickers = tickers.split(" ") - try: - for ticker in tickers: + for ticker in tickers: + try: price, old_price = get_ticker_prices(ticker) trend = ((price - old_price) / old_price) * 100 info[ticker] = format_number(price) info[ticker + "_TREND"] = format_number(trend) + except Exception as e: + print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), repr(e)) + + if info: global last_updated_time last_updated_time = time.time() - except Exception as e: - print( - datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), - "Error occurred when fetching information", - ) return info