Set task progress on exception (#4025)
Browse files### What problem does this PR solve?
Set task progress on exception
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- rag/svr/task_executor.py +8 -1
rag/svr/task_executor.py
CHANGED
@@ -502,12 +502,19 @@ def handle_task():
|
|
502 |
with mt_lock:
|
503 |
DONE_TASKS += 1
|
504 |
CURRENT_TASK = None
|
505 |
-
|
|
|
|
|
|
|
506 |
logging.debug("handle_task got TaskCanceledException", exc_info=True)
|
507 |
except Exception:
|
508 |
with mt_lock:
|
509 |
FAILED_TASKS += 1
|
510 |
CURRENT_TASK = None
|
|
|
|
|
|
|
|
|
511 |
logging.exception(f"handle_task got exception for task {json.dumps(task)}")
|
512 |
if PAYLOAD:
|
513 |
PAYLOAD.ack()
|
|
|
502 |
with mt_lock:
|
503 |
DONE_TASKS += 1
|
504 |
CURRENT_TASK = None
|
505 |
+
try:
|
506 |
+
set_progress(task["id"], prog=-1, msg="handle_task got TaskCanceledException")
|
507 |
+
except Exception:
|
508 |
+
pass
|
509 |
logging.debug("handle_task got TaskCanceledException", exc_info=True)
|
510 |
except Exception:
|
511 |
with mt_lock:
|
512 |
FAILED_TASKS += 1
|
513 |
CURRENT_TASK = None
|
514 |
+
try:
|
515 |
+
set_progress(task["id"], prog=-1, msg="handle_task got exception, please check log")
|
516 |
+
except Exception:
|
517 |
+
pass
|
518 |
logging.exception(f"handle_task got exception for task {json.dumps(task)}")
|
519 |
if PAYLOAD:
|
520 |
PAYLOAD.ack()
|