From e1c1a03ab0e4e8d7a926c9f917f6b6be4dc85306 Mon Sep 17 00:00:00 2001 From: Steve Chan Date: Sun, 27 Oct 2024 13:05:19 -0400 Subject: [PATCH] fix aiohttp disconnect error on websockets aiohttp will throw if the handler doesn't return anything. ```python 14:11:35 aiohttp ERRO Missing return statement on request handler Traceback (most recent call last): File "/Users/steve/conda/envs/port/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 653, in finish_response prepare_meth = resp.prepare ^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'prepare' ``` https://docs.aiohttp.org/en/stable/web_quickstart.html#websockets Signed-off-by: Steve Chan --- rust/perspective-python/perspective/handlers/aiohttp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rust/perspective-python/perspective/handlers/aiohttp.py b/rust/perspective-python/perspective/handlers/aiohttp.py index d1685769e8..421889720d 100644 --- a/rust/perspective-python/perspective/handlers/aiohttp.py +++ b/rust/perspective-python/perspective/handlers/aiohttp.py @@ -39,7 +39,7 @@ def __init__(self, **kwargs): self._request = kwargs.pop("request") super().__init__(**kwargs) - async def run(self) -> None: + async def run(self) -> web.WebSocketResponse: def inner(msg): asyncio.get_running_loop().create_task(self._ws.send_bytes(msg)) @@ -53,3 +53,4 @@ def inner(msg): finally: self.session.close() + return self._ws