summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/lib/bb/asyncrpc/client.py7
-rw-r--r--bitbake/lib/bb/asyncrpc/serv.py5
2 files changed, 11 insertions, 1 deletions
diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py
index 4cdad9ac3c..79919c5be6 100644
--- a/bitbake/lib/bb/asyncrpc/client.py
+++ b/bitbake/lib/bb/asyncrpc/client.py
@@ -103,13 +103,18 @@ class AsyncClient(object):
103 103
104 return await self._send_wrapper(proc) 104 return await self._send_wrapper(proc)
105 105
106 async def ping(self):
107 return await self.send_message(
108 {'ping': {}}
109 )
110
106 111
107class Client(object): 112class Client(object):
108 def __init__(self): 113 def __init__(self):
109 self.client = self._get_async_client() 114 self.client = self._get_async_client()
110 self.loop = asyncio.new_event_loop() 115 self.loop = asyncio.new_event_loop()
111 116
112 self._add_methods('connect_tcp', 'close') 117 self._add_methods('connect_tcp', 'close', 'ping')
113 118
114 @abc.abstractmethod 119 @abc.abstractmethod
115 def _get_async_client(self): 120 def _get_async_client(self):
diff --git a/bitbake/lib/bb/asyncrpc/serv.py b/bitbake/lib/bb/asyncrpc/serv.py
index cb3384639d..fd91aa71a2 100644
--- a/bitbake/lib/bb/asyncrpc/serv.py
+++ b/bitbake/lib/bb/asyncrpc/serv.py
@@ -28,6 +28,7 @@ class AsyncServerConnection(object):
28 self.max_chunk = DEFAULT_MAX_CHUNK 28 self.max_chunk = DEFAULT_MAX_CHUNK
29 self.handlers = { 29 self.handlers = {
30 'chunk-stream': self.handle_chunk, 30 'chunk-stream': self.handle_chunk,
31 'ping': self.handle_ping,
31 } 32 }
32 self.logger = logger 33 self.logger = logger
33 34
@@ -123,6 +124,10 @@ class AsyncServerConnection(object):
123 124
124 await self.dispatch_message(msg) 125 await self.dispatch_message(msg)
125 126
127 async def handle_ping(self, request):
128 response = {'alive': True}
129 self.write_message(response)
130
126 131
127class AsyncServer(object): 132class AsyncServer(object):
128 def __init__(self, logger, loop=None): 133 def __init__(self, logger, loop=None):