From d60c48153df139c197301ed370407851475c12e0 Mon Sep 17 00:00:00 2001 From: Philip Lorenz Date: Mon, 30 Dec 2024 13:35:47 +0100 Subject: bitbake: asyncrpc: Handle websockets exceptions The websockets library throws a number of exceptions which are currently not caught leading to unhandled exceptions in the idle loop. Fix this by catching them and reexposing them as a `ConnectionError` which is the exception expected by users of `asyncrpc`. (Bitbake rev: 41d62911a480283287265fe063696d2acd5904aa) Signed-off-by: Philip Lorenz Signed-off-by: Richard Purdie --- bitbake/lib/bb/asyncrpc/client.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py index 9be49261c0..17b72033b9 100644 --- a/bitbake/lib/bb/asyncrpc/client.py +++ b/bitbake/lib/bb/asyncrpc/client.py @@ -112,11 +112,16 @@ class AsyncClient(object): ) async def connect_sock(): - websocket = await websockets.connect( - uri, - ping_interval=None, - open_timeout=self.timeout, - ) + try: + websocket = await websockets.connect( + uri, + ping_interval=None, + open_timeout=self.timeout, + ) + except asyncio.exceptions.TimeoutError: + raise ConnectionError("Timeout while connecting to websocket") + except (OSError, websockets.InvalidHandshake, websockets.InvalidURI) as exc: + raise ConnectionError(f"Could not connect to websocket: {exc}") from exc return WebsocketConnection(websocket, self.timeout) self._connect_sock = connect_sock -- cgit v1.2.3-54-g00ecf