From 8b89935eb3b01dbc1b1c06376f3a737d6fa329ee Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 30 Dec 2020 00:58:49 +0100 Subject: [PATCH] [fix] in case the db is totally empty, index is buggy --- run.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 33701d5..27bab89 100644 --- a/run.py +++ b/run.py @@ -580,9 +580,15 @@ async def ws_index(request, websocket): map(model_to_dict, Job.select().where(Job.state == "running").iterator()), map(model_to_dict, latest_done_jobs.iterator())), 30) + try: + first_chunck = next(data) + except StopIteration: + # in case data is empty + first_chunck = [] + await websocket.send(ujson.dumps({ "action": "init_jobs", - "data": next(data), # send first chunk + "data": first_chunck, # send first chunk })) for chunk in data: