From e80ffb7f9be04226d2a6ea9566612b06df85e580 Mon Sep 17 00:00:00 2001 From: zhaoqingang <zhaoqg0118@163.com> Date: 星期三, 13 十一月 2024 17:58:14 +0800 Subject: [PATCH] 参数修改 --- 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