refactor: use thread.Timer instead of time.sleep (#33121)

This commit is contained in:
wangxiaolei
2026-03-09 09:38:16 +08:00
committed by GitHub
parent 7dcf94f48f
commit 46098b2be6
2 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import hashlib
import logging
import time
from threading import Thread
from threading import Thread, Timer
from typing import Union
from flask import Flask, current_app
@ -96,9 +95,9 @@ class MessageCycleManager:
if auto_generate_conversation_name and is_first_message:
# start generate thread
# time.sleep not block other logic
time.sleep(1)
thread = Thread(
target=self._generate_conversation_name_worker,
thread = Timer(
1,
self._generate_conversation_name_worker,
kwargs={
"flask_app": current_app._get_current_object(), # type: ignore
"conversation_id": conversation_id,