From 24fa3d0b29b31c990c87b680f5b20631b596480a Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 29 Jul 2023 09:08:52 +0200 Subject: [PATCH] Bump websockets to 11.0.3. Fix #1927. Change ws_handler to wait for the transport to be closed before exiting. This prevents a performance optimization in websockets to cause a test failure. Also, it aligns the behavior between wsproto and websockets. --- requirements.txt | 2 +- tests/protocols/test_websocket.py | 2 +- uvicorn/protocols/websockets/websockets_impl.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index a99dc024a..305bd0186 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ h11 @ git+https://github.com/python-hyper/h11.git@master # Explicit optionals a2wsgi==1.7.0 wsproto==1.2.0 -websockets==10.4 +websockets==11.0.3 # Packaging build==0.10.0 diff --git a/tests/protocols/test_websocket.py b/tests/protocols/test_websocket.py index 1dd82bbcb..17f2a92d1 100644 --- a/tests/protocols/test_websocket.py +++ b/tests/protocols/test_websocket.py @@ -577,7 +577,7 @@ async def test_asgi_return_value( unused_tcp_port: int, ): """ - The ASGI callable should return 'None'. If it doesn't make sure that + The ASGI callable should return 'None'. If it doesn't, make sure that the connection is closed with an error condition. """ diff --git a/uvicorn/protocols/websockets/websockets_impl.py b/uvicorn/protocols/websockets/websockets_impl.py index 04d41bad9..089eeb536 100644 --- a/uvicorn/protocols/websockets/websockets_impl.py +++ b/uvicorn/protocols/websockets/websockets_impl.py @@ -236,7 +236,7 @@ async def ws_handler( # type: ignore[override] 'send' and 'receive' events to drive the flow. """ self.handshake_completed_event.set() - await self.closed_event.wait() + await self.wait_closed() async def run_asgi(self) -> None: """