/history/ return 503 when influxdb isn't ready
This commit is contained in:
@@ -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)
|
||||||
|
try:
|
||||||
|
await asyncio.wait_for(asyncio.to_thread(influx_probe.ping), timeout=2)
|
||||||
history = list(client.query(q).get_points())
|
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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user