mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
add taskexecutor status check (#2038)
### What problem does this PR solve? ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -23,6 +23,7 @@ import re
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from functools import partial
|
||||
|
||||
from api.db.services.file2document_service import File2DocumentService
|
||||
@ -373,11 +374,28 @@ def main():
|
||||
r["id"], tk_count, len(cks), timer() - st))
|
||||
|
||||
|
||||
def report_status():
|
||||
id = "0" if len(sys.argv) < 2 else sys.argv[1]
|
||||
while True:
|
||||
try:
|
||||
obj = REDIS_CONN.get("TASKEXE")
|
||||
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)
|
||||
except Exception as e:
|
||||
print("[Exception]:", str(e))
|
||||
time.sleep(60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
peewee_logger = logging.getLogger('peewee')
|
||||
peewee_logger.propagate = False
|
||||
peewee_logger.addHandler(database_logger.handlers[0])
|
||||
peewee_logger.setLevel(database_logger.level)
|
||||
|
||||
exe = ThreadPoolExecutor(max_workers=1)
|
||||
exe.submit(report_status)
|
||||
|
||||
while True:
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user