diff options
Diffstat (limited to 'bitbake/lib')
| -rw-r--r-- | bitbake/lib/bb/asyncrpc/__init__.py | 1 | ||||
| -rw-r--r-- | bitbake/lib/bb/asyncrpc/client.py | 10 | ||||
| -rw-r--r-- | bitbake/lib/bb/asyncrpc/exceptions.py | 4 | ||||
| -rw-r--r-- | bitbake/lib/bb/asyncrpc/serv.py | 11 |
4 files changed, 22 insertions, 4 deletions
diff --git a/bitbake/lib/bb/asyncrpc/__init__.py b/bitbake/lib/bb/asyncrpc/__init__.py index 9f677eac4c..a4371643d7 100644 --- a/bitbake/lib/bb/asyncrpc/__init__.py +++ b/bitbake/lib/bb/asyncrpc/__init__.py | |||
| @@ -12,4 +12,5 @@ from .exceptions import ( | |||
| 12 | ClientError, | 12 | ClientError, |
| 13 | ServerError, | 13 | ServerError, |
| 14 | ConnectionClosedError, | 14 | ConnectionClosedError, |
| 15 | InvokeError, | ||
| 15 | ) | 16 | ) |
diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py index 009085c306..d27dbf7121 100644 --- a/bitbake/lib/bb/asyncrpc/client.py +++ b/bitbake/lib/bb/asyncrpc/client.py | |||
| @@ -11,7 +11,7 @@ import os | |||
| 11 | import socket | 11 | import socket |
| 12 | import sys | 12 | import sys |
| 13 | from .connection import StreamConnection, WebsocketConnection, DEFAULT_MAX_CHUNK | 13 | from .connection import StreamConnection, WebsocketConnection, DEFAULT_MAX_CHUNK |
| 14 | from .exceptions import ConnectionClosedError | 14 | from .exceptions import ConnectionClosedError, InvokeError |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | class AsyncClient(object): | 17 | class AsyncClient(object): |
| @@ -93,12 +93,18 @@ class AsyncClient(object): | |||
| 93 | await self.close() | 93 | await self.close() |
| 94 | count += 1 | 94 | count += 1 |
| 95 | 95 | ||
| 96 | def check_invoke_error(self, msg): | ||
| 97 | if isinstance(msg, dict) and "invoke-error" in msg: | ||
| 98 | raise InvokeError(msg["invoke-error"]["message"]) | ||
| 99 | |||
| 96 | async def invoke(self, msg): | 100 | async def invoke(self, msg): |
| 97 | async def proc(): | 101 | async def proc(): |
| 98 | await self.socket.send_message(msg) | 102 | await self.socket.send_message(msg) |
| 99 | return await self.socket.recv_message() | 103 | return await self.socket.recv_message() |
| 100 | 104 | ||
| 101 | return await self._send_wrapper(proc) | 105 | result = await self._send_wrapper(proc) |
| 106 | self.check_invoke_error(result) | ||
| 107 | return result | ||
| 102 | 108 | ||
| 103 | async def ping(self): | 109 | async def ping(self): |
| 104 | return await self.invoke({"ping": {}}) | 110 | return await self.invoke({"ping": {}}) |
diff --git a/bitbake/lib/bb/asyncrpc/exceptions.py b/bitbake/lib/bb/asyncrpc/exceptions.py index a8942b4f0c..ae1043a38b 100644 --- a/bitbake/lib/bb/asyncrpc/exceptions.py +++ b/bitbake/lib/bb/asyncrpc/exceptions.py | |||
| @@ -9,6 +9,10 @@ class ClientError(Exception): | |||
| 9 | pass | 9 | pass |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | class InvokeError(Exception): | ||
| 13 | pass | ||
| 14 | |||
| 15 | |||
| 12 | class ServerError(Exception): | 16 | class ServerError(Exception): |
| 13 | pass | 17 | pass |
| 14 | 18 | ||
diff --git a/bitbake/lib/bb/asyncrpc/serv.py b/bitbake/lib/bb/asyncrpc/serv.py index c99add4dd1..5fed1730df 100644 --- a/bitbake/lib/bb/asyncrpc/serv.py +++ b/bitbake/lib/bb/asyncrpc/serv.py | |||
| @@ -14,7 +14,7 @@ import sys | |||
| 14 | import multiprocessing | 14 | import multiprocessing |
| 15 | import logging | 15 | import logging |
| 16 | from .connection import StreamConnection, WebsocketConnection | 16 | from .connection import StreamConnection, WebsocketConnection |
| 17 | from .exceptions import ClientError, ServerError, ConnectionClosedError | 17 | from .exceptions import ClientError, ServerError, ConnectionClosedError, InvokeError |
| 18 | 18 | ||
| 19 | 19 | ||
| 20 | class ClientLoggerAdapter(logging.LoggerAdapter): | 20 | class ClientLoggerAdapter(logging.LoggerAdapter): |
| @@ -76,7 +76,14 @@ class AsyncServerConnection(object): | |||
| 76 | d = await self.socket.recv_message() | 76 | d = await self.socket.recv_message() |
| 77 | if d is None: | 77 | if d is None: |
| 78 | break | 78 | break |
| 79 | response = await self.dispatch_message(d) | 79 | try: |
| 80 | response = await self.dispatch_message(d) | ||
| 81 | except InvokeError as e: | ||
| 82 | await self.socket.send_message( | ||
| 83 | {"invoke-error": {"message": str(e)}} | ||
| 84 | ) | ||
| 85 | break | ||
| 86 | |||
| 80 | if response is not self.NO_RESPONSE: | 87 | if response is not self.NO_RESPONSE: |
| 81 | await self.socket.send_message(response) | 88 | await self.socket.send_message(response) |
| 82 | 89 | ||
