/history/ return 503 when influxdb isn't ready

This commit is contained in:
Tanner
2026-11-03 16:19:17 +00:00
parent 98f5705224
commit 518b422915
+6 -1
View File
@@ -184,7 +184,12 @@ async def history(request):
end = int(end.timestamp()) end = int(end.timestamp())
q = 'select * from ecu where time >= {}s and time < {}s'.format(start, end) 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) return web.json_response(history)