From e2b9a88ef45aa1a66cf7de47ab6214a48847afe0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 21 Jan 2023 17:56:27 +0100 Subject: [PATCH] fix: when websockets are disconnected, the exception is now WebsocketClosed --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index ba489a4..c9fa9c0 100644 --- a/run.py +++ b/run.py @@ -29,7 +29,7 @@ from websockets.exceptions import ConnectionClosed from websockets import WebSocketCommonProtocol from sanic import Sanic, response -from sanic.exceptions import NotFound +from sanic.exceptions import NotFound, WebsocketClosed from sanic.log import LOGGING_CONFIG_DEFAULTS from jinja2 import FileSystemLoader @@ -525,7 +525,7 @@ async def broadcast(message, channels): for ws in ws_list: try: await ws.send(my_json_dumps(message)) - except ConnectionClosed: + except (ConnectionClosed, WebsocketClosed): dead_ws.append(ws) for to_remove in dead_ws: