mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-30 22:42:00 +08:00
Added time to progress message (#4185)
### What problem does this PR solve? Added time to progress message ### Type of change - [x] Refactoring
This commit is contained in:
parent
b635002666
commit
8d73cf6f02
@ -17,6 +17,7 @@ import os
|
||||
import random
|
||||
import xxhash
|
||||
import bisect
|
||||
from datetime import datetime
|
||||
|
||||
from api.db.db_utils import bulk_insert_into_db
|
||||
from deepdoc.parser import PdfParser
|
||||
@ -84,7 +85,7 @@ class TaskService(CommonService):
|
||||
if not docs:
|
||||
return None
|
||||
|
||||
msg = "\nTask has been received."
|
||||
msg = f"\n{datetime.now().strftime('%H:%M:%S.%f')} Task has been received."
|
||||
prog = random.random() / 10.0
|
||||
if docs[0]["retry_count"] >= 3:
|
||||
msg = "\nERROR: Task is abandoned after 3 times attempts."
|
||||
|
@ -83,7 +83,7 @@ FACTORY = {
|
||||
|
||||
CONSUMER_NAME = "task_consumer_" + CONSUMER_NO
|
||||
PAYLOAD: Payload | None = None
|
||||
BOOT_AT = datetime.now().isoformat()
|
||||
BOOT_AT = datetime.now().astimezone().isoformat(timespec="milliseconds")
|
||||
PENDING_TASKS = 0
|
||||
LAG_TASKS = 0
|
||||
|
||||
@ -116,6 +116,8 @@ def set_progress(task_id, from_page=0, to_page=-1, prog=None, msg="Processing...
|
||||
if to_page > 0:
|
||||
if msg:
|
||||
msg = f"Page({from_page + 1}~{to_page + 1}): " + msg
|
||||
if msg:
|
||||
msg = datetime.now().strftime("%H:%M:%S.%f") + " " + msg
|
||||
d = {"progress_msg": msg}
|
||||
if prog is not None:
|
||||
d["progress"] = prog
|
||||
@ -550,7 +552,7 @@ def report_status():
|
||||
with mt_lock:
|
||||
heartbeat = json.dumps({
|
||||
"name": CONSUMER_NAME,
|
||||
"now": now.isoformat(),
|
||||
"now": now.astimezone().isoformat(timespec="milliseconds"),
|
||||
"boot_at": BOOT_AT,
|
||||
"pending": PENDING_TASKS,
|
||||
"lag": LAG_TASKS,
|
||||
|
Loading…
x
Reference in New Issue
Block a user