aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-05-28 09:42:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-06-06 23:17:30 +0100
commit25ccd697ea76f66b813be2296866b2d3405b079c (patch)
tree2a7f5d8d767ecde1b8f2b49d8e749e1be64286c0
parenta13510d0028e234ea2f4744b0d0c38558395c70f (diff)
downloadbitbake-25ccd697ea76f66b813be2296866b2d3405b079c.tar.gz
asyncrpc: Add ping method
This method is needed to support startup of the prservice. As it is so generic we can add it to the common asyncrpc module. Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/asyncrpc/client.py7
-rw-r--r--lib/bb/asyncrpc/serv.py5
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/bb/asyncrpc/client.py b/lib/bb/asyncrpc/client.py
index 4cdad9ac3..79919c5be 100644
--- a/lib/bb/asyncrpc/client.py
+++ b/lib/bb/asyncrpc/client.py
@@ -103,13 +103,18 @@ class AsyncClient(object):
return await self._send_wrapper(proc)
+ async def ping(self):
+ return await self.send_message(
+ {'ping': {}}
+ )
+
class Client(object):
def __init__(self):
self.client = self._get_async_client()
self.loop = asyncio.new_event_loop()
- self._add_methods('connect_tcp', 'close')
+ self._add_methods('connect_tcp', 'close', 'ping')
@abc.abstractmethod
def _get_async_client(self):
diff --git a/lib/bb/asyncrpc/serv.py b/lib/bb/asyncrpc/serv.py
index cb3384639..fd91aa71a 100644
--- a/lib/bb/asyncrpc/serv.py
+++ b/lib/bb/asyncrpc/serv.py
@@ -28,6 +28,7 @@ class AsyncServerConnection(object):
self.max_chunk = DEFAULT_MAX_CHUNK
self.handlers = {
'chunk-stream': self.handle_chunk,
+ 'ping': self.handle_ping,
}
self.logger = logger
@@ -123,6 +124,10 @@ class AsyncServerConnection(object):
await self.dispatch_message(msg)
+ async def handle_ping(self, request):
+ response = {'alive': True}
+ self.write_message(response)
+
class AsyncServer(object):
def __init__(self, logger, loop=None):