diff --git a/api/apps/system_app.py b/api/apps/system_app.py index 937f83ec9..d6e4a098f 100644 --- a/api/apps/system_app.py +++ b/api/apps/system_app.py @@ -68,7 +68,10 @@ def status(): res["redis"] = {"status": "red", "elapsed": "{:.1f}".format((timer() - st)*1000.), "error": str(e)} try: - obj = json.loads(REDIS_CONN.get("TASKEXE")) + v = REDIS_CONN.get("TASKEXE") + if not v: + raise Exception("No task executor running!") + obj = json.loads(v) color = "green" for id in obj.keys(): arr = obj[id] diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py index f772882d6..9f027faa5 100644 --- a/rag/svr/task_executor.py +++ b/rag/svr/task_executor.py @@ -379,11 +379,12 @@ def report_status(): while True: try: obj = REDIS_CONN.get("TASKEXE") - obj = json.load(obj) + if not obj: obj = {} + else: obj = json.load(obj) if id not in obj: obj[id] = [] obj[id].append(timer()*1000) - obj[id] = obj[id][:-60] - REDIS_CONN.set_obj("TASKEXE", obj) + obj[id] = obj[id][-60:] + REDIS_CONN.set_obj("TASKEXE", obj, 60*2) except Exception as e: print("[Exception]:", str(e)) time.sleep(60)