aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/asyncrpc/client.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-11-03 08:26:28 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-09 17:21:15 +0000
commit50ee68175e7cf20a32bfbb176db2c47d7859da04 (patch)
tree769cb97410b6475000270c41f27acd5904f59ca8 /lib/bb/asyncrpc/client.py
parentd0bbb98553f5f3451606bd5f089b36cfe4219dc2 (diff)
downloadbitbake-contrib-50ee68175e7cf20a32bfbb176db2c47d7859da04.tar.gz
asyncrpc: Add InvokeError
Adds support for Invocation Errors (that is, errors raised by the actual RPC call instead of at the protocol level) to propagate across the connection. If a server RPC call raises an InvokeError, it will be sent across the connection and then raised on the client side also. The connection is still terminated on this error. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/asyncrpc/client.py')
-rw-r--r--lib/bb/asyncrpc/client.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index 009085c30..d27dbf712 100644
--- a/lib/bb/asyncrpc/client.py
+++ b/lib/bb/asyncrpc/client.py
@@ -11,7 +11,7 @@ import os
import socket
import sys
from .connection import StreamConnection, WebsocketConnection, DEFAULT_MAX_CHUNK
-from .exceptions import ConnectionClosedError
+from .exceptions import ConnectionClosedError, InvokeError
class AsyncClient(object):
@@ -93,12 +93,18 @@ class AsyncClient(object):
await self.close()
count += 1
+ def check_invoke_error(self, msg):
+ if isinstance(msg, dict) and "invoke-error" in msg:
+ raise InvokeError(msg["invoke-error"]["message"])
+
async def invoke(self, msg):
async def proc():
await self.socket.send_message(msg)
return await self.socket.recv_message()
- return await self._send_wrapper(proc)
+ result = await self._send_wrapper(proc)
+ self.check_invoke_error(result)
+ return result
async def ping(self):
return await self.invoke({"ping": {}})