From 9775416cff368dc8acbf2615f05bb86c7196b009 Mon Sep 17 00:00:00 2001 From: Kyomotoi <0w0@imki.moe> Date: Fri, 4 Nov 2022 20:21:51 +0800 Subject: =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20=E4=BF=AE=E5=A4=8D=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ATRI/plugins/console/driver/api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ATRI/plugins/console/driver/api.py b/ATRI/plugins/console/driver/api.py index 4319954..668a308 100644 --- a/ATRI/plugins/console/driver/api.py +++ b/ATRI/plugins/console/driver/api.py @@ -2,7 +2,7 @@ import asyncio from fastapi import Depends, status from starlette.websockets import WebSocket, WebSocketState -from websockets.exceptions import ConnectionClosedOK +from websockets.exceptions import ConnectionClosedOK, ConnectionClosedError from .depends import * from .data_source import ( @@ -34,6 +34,8 @@ async def runtime_info(websocket: WebSocket, _pass=Depends(websocket_author)): await asyncio.sleep(1) except ConnectionClosedOK: pass + except ConnectionClosedError: + pass finally: await websocket.close() return @@ -50,6 +52,8 @@ async def message_info(websocket: WebSocket, _pass=Depends(websocket_author)): await asyncio.sleep(1) except ConnectionClosedOK: pass + except ConnectionClosedError: + pass finally: await websocket.close() return @@ -79,10 +83,10 @@ def block_list_info(_=Depends(http_author)): return {"status": status.HTTP_200_OK, "data": get_block_list()} -def edit_block_list( +async def edit_block_list( enabled: str, user_id: str = str(), group_id: str = str(), _=Depends(http_author) ): return { "status": status.HTTP_200_OK, - "data": _edit_block_list(bool(int(enabled)), user_id, group_id), + "data": await _edit_block_list(bool(int(enabled)), user_id, group_id), } -- cgit v1.2.3