From c89fa72d0d2772e52812331024dedf3ded1b0639 Mon Sep 17 00:00:00 2001
From: xuyonghao <898441624@qq.com>
Date: 星期一, 11 十一月 2024 17:32:43 +0800
Subject: [PATCH] fix bug
---
app/api/report.py | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/api/report.py b/app/api/report.py
index 254695d..232c4b0 100644
--- a/app/api/report.py
+++ b/app/api/report.py
@@ -76,13 +76,22 @@
await websocket.send_json(result)
print(f"Forwarded to client, {chat_id}: {result}")
- last_message = "step" if steps else "message"
+ last_message = "message" if msg else "step"
# 鍚姩涓や釜浠诲姟锛屽垎鍒鐞嗗鎴风鍜屾湇鍔$鐨勬秷鎭�
tasks = [
asyncio.create_task(forward_to_service()),
asyncio.create_task(forward_to_client())
]
+ done, pending = await asyncio.wait(tasks, return_when=asyncio.FIRST_COMPLETED)
+
+ # 鍙栨秷鏈畬鎴愮殑浠诲姟
+ for task in pending:
+ task.cancel()
+ try:
+ await task
+ except asyncio.CancelledError:
+ pass
except WebSocketDisconnect as e:
print(f"WebSocket connection closed with code {e.code}: {e.reason}")
@@ -91,7 +100,7 @@
except Exception as e:
print(f"Exception occurred: {e}")
finally:
- print("Cleaning up resources")
+ print("Cleaning up resources of bisheng report")
# 鍙栨秷鎵�鏈変换鍔�
for task in tasks:
if not task.done():
--
Gitblit v1.8.0