From 518b4229153f1dc538196e5b0c1b72eba4f80e9b Mon Sep 17 00:00:00 2001 From: Tanner Date: Tue, 3 Nov 2026 16:19:17 +0000 Subject: [PATCH] /history/ return 503 when influxdb isn't ready --- server/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/main.py b/server/main.py index 550db40..c2198c6 100644 --- a/server/main.py +++ b/server/main.py @@ -184,7 +184,12 @@ async def history(request): end = int(end.timestamp()) q = 'select * from ecu where time >= {}s and time < {}s'.format(start, end) - history = list(client.query(q).get_points()) + try: + await asyncio.wait_for(asyncio.to_thread(influx_probe.ping), timeout=2) + history = list(client.query(q).get_points()) + except Exception as err: + logging.warning('InfluxDB unavailable for history request: %s', err) + raise web.HTTPServiceUnavailable(text='InfluxDB is not ready') from err return web.json_response(history)