summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Lorenz <philip.lorenz@bmw.de>2024-12-30 13:35:47 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-01-11 18:35:01 +0000
commitd60c48153df139c197301ed370407851475c12e0 (patch)
tree51701da80b1e281c1e3f5a6ba5e4b3d217ae359c
parentf003bd9bda395a70f65da8335ef488f25a3bbb50 (diff)
downloadpoky-d60c48153df139c197301ed370407851475c12e0.tar.gz
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 <philip.lorenz@bmw.de> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/asyncrpc/client.py15
1 files 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):
112 ) 112 )
113 113
114 async def connect_sock(): 114 async def connect_sock():
115 websocket = await websockets.connect( 115 try:
116 uri, 116 websocket = await websockets.connect(
117 ping_interval=None, 117 uri,
118 open_timeout=self.timeout, 118 ping_interval=None,
119 ) 119 open_timeout=self.timeout,
120 )
121 except asyncio.exceptions.TimeoutError:
122 raise ConnectionError("Timeout while connecting to websocket")
123 except (OSError, websockets.InvalidHandshake, websockets.InvalidURI) as exc:
124 raise ConnectionError(f"Could not connect to websocket: {exc}") from exc
120 return WebsocketConnection(websocket, self.timeout) 125 return WebsocketConnection(websocket, self.timeout)
121 126
122 self._connect_sock = connect_sock 127 self._connect_sock = connect_sock