|
|
|
@ -12,11 +12,13 @@ WORKING_DIR = f"./output"
|
|
|
|
|
# 后台任务,监控是否有新的未训练的文档进行训练
|
|
|
|
|
async def train_document_task():
|
|
|
|
|
print("线程5秒后开始运行【监控是否有新的未训练的文档进行训练】")
|
|
|
|
|
num = 1
|
|
|
|
|
await asyncio.sleep(5) # 使用 asyncio.sleep 而不是 time.sleep
|
|
|
|
|
# 这里放置你的线程逻辑
|
|
|
|
|
while True:
|
|
|
|
|
# 这里可以放置你的线程要执行的代码
|
|
|
|
|
logging.info("开始查询是否有未训练的文档")
|
|
|
|
|
logging.info("开始查询是否有未训练的文档:" + str(num))
|
|
|
|
|
num = num + 1
|
|
|
|
|
no_train_document_sql: str = " SELECT * FROM t_ai_teaching_model_document WHERE is_deleted = 0 and train_flag = 0 ORDER BY create_time DESC"
|
|
|
|
|
no_train_document_result = await find_by_sql(no_train_document_sql, ())
|
|
|
|
|
if not no_train_document_result:
|
|
|
|
@ -49,4 +51,4 @@ async def train_document_task():
|
|
|
|
|
# execute_sql(update_sql)
|
|
|
|
|
|
|
|
|
|
# 添加适当的等待时间,避免频繁查询
|
|
|
|
|
await asyncio.sleep(60) # 每分钟查询一次
|
|
|
|
|
await asyncio.sleep(60) # 每分钟查询一次
|
|
|
|
|