mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-10 23:49:02 +08:00
Fix: improve task cancel lag (#7765)
### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/7761 but it may be difficult to achieve 0 delay (which need to pass the cancel token to all parts) Another solution is just 0 delay effect at UI. And task will stop latter ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
ac2643700b
commit
ce816edb5f
@ -368,6 +368,10 @@ async def build_chunks(task, progress_callback):
|
|||||||
|
|
||||||
docs_to_tag = []
|
docs_to_tag = []
|
||||||
for d in docs:
|
for d in docs:
|
||||||
|
task_canceled = TaskService.do_cancel(task["id"])
|
||||||
|
if task_canceled:
|
||||||
|
progress_callback(-1, msg="Task has been canceled.")
|
||||||
|
return
|
||||||
if settings.retrievaler.tag_content(tenant_id, kb_ids, d, all_tags, topn_tags=topn_tags, S=S) and len(d[TAG_FLD]) > 0:
|
if settings.retrievaler.tag_content(tenant_id, kb_ids, d, all_tags, topn_tags=topn_tags, S=S) and len(d[TAG_FLD]) > 0:
|
||||||
examples.append({"content": d["content_with_weight"], TAG_FLD: d[TAG_FLD]})
|
examples.append({"content": d["content_with_weight"], TAG_FLD: d[TAG_FLD]})
|
||||||
else:
|
else:
|
||||||
@ -589,6 +593,10 @@ async def do_handle_task(task):
|
|||||||
|
|
||||||
for b in range(0, len(chunks), es_bulk_size):
|
for b in range(0, len(chunks), es_bulk_size):
|
||||||
doc_store_result = await trio.to_thread.run_sync(lambda: settings.docStoreConn.insert(chunks[b:b + es_bulk_size], search.index_name(task_tenant_id), task_dataset_id))
|
doc_store_result = await trio.to_thread.run_sync(lambda: settings.docStoreConn.insert(chunks[b:b + es_bulk_size], search.index_name(task_tenant_id), task_dataset_id))
|
||||||
|
task_canceled = TaskService.do_cancel(task_id)
|
||||||
|
if task_canceled:
|
||||||
|
progress_callback(-1, msg="Task has been canceled.")
|
||||||
|
return
|
||||||
if b % 128 == 0:
|
if b % 128 == 0:
|
||||||
progress_callback(prog=0.8 + 0.1 * (b + 1) / len(chunks), msg="")
|
progress_callback(prog=0.8 + 0.1 * (b + 1) / len(chunks), msg="")
|
||||||
if doc_store_result:
|
if doc_store_result:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user