This commit is contained in:
hailin 2025-07-27 19:37:58 +08:00
parent 9cb53f50f6
commit 0b24f7e814
1 changed files with 3 additions and 1 deletions

View File

@ -117,13 +117,15 @@ def chat(
# threading.Thread(target=worker).start() # threading.Thread(target=worker).start()
thread = threading.Thread(target=worker, daemon=True) thread = threading.Thread(target=worker, daemon=True)
thread.start()
yield "⏳ 正在生成中...", log_state yield "⏳ 正在生成中...", log_state
while True: while True:
# ⚠️ 线程已结束且队列已空 → 直接 return 让生成器终止 # ⚠️ 线程已结束且队列已空 → 直接 return 让生成器终止
if not thread.is_alive() and result_q.empty(): if not thread.is_alive() and result_q.empty():
return # ← 新增这一行 break
# return # ← 新增这一行
try: try:
result = result_q.get(timeout=0.1) result = result_q.get(timeout=0.1)