mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 05:55:59 +08:00
add retry count to task (#2152)
### What problem does this PR solve? ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
06abef66ef
commit
212bb8e601
@ -788,6 +788,7 @@ class Task(DataBaseModel):
|
|||||||
null=True,
|
null=True,
|
||||||
help_text="process message",
|
help_text="process message",
|
||||||
default="")
|
default="")
|
||||||
|
retry_count = IntegerField(default=0)
|
||||||
|
|
||||||
|
|
||||||
class Dialog(DataBaseModel):
|
class Dialog(DataBaseModel):
|
||||||
@ -982,3 +983,10 @@ def migrate_db():
|
|||||||
DB.execute_sql('ALTER TABLE llm ADD PRIMARY KEY (llm_name,fid);')
|
DB.execute_sql('ALTER TABLE llm ADD PRIMARY KEY (llm_name,fid);')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
try:
|
||||||
|
migrate(
|
||||||
|
migrator.add_column('task', 'retry_count', IntegerField(default=0))
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
|
|
||||||
|
@ -64,9 +64,20 @@ class TaskService(CommonService):
|
|||||||
docs = list(docs.dicts())
|
docs = list(docs.dicts())
|
||||||
if not docs: return []
|
if not docs: return []
|
||||||
|
|
||||||
cls.model.update(progress_msg=cls.model.progress_msg + "\n" + "Task has been received.",
|
msg = "\nTask has been received."
|
||||||
progress=random.random() / 10.).where(
|
prog = random.random() / 10.
|
||||||
|
if docs[0]["retry_count"] >= 3:
|
||||||
|
msg = "\nERROR: Task is abandoned after 3 times attempts."
|
||||||
|
prog = -1
|
||||||
|
|
||||||
|
cls.model.update(progress_msg=cls.model.progress_msg + msg,
|
||||||
|
progress=prog,
|
||||||
|
retry_count=docs[0]["retry_count"]+1
|
||||||
|
).where(
|
||||||
cls.model.id == docs[0]["id"]).execute()
|
cls.model.id == docs[0]["id"]).execute()
|
||||||
|
|
||||||
|
if docs[0]["retry_count"] >= 3: return []
|
||||||
|
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user