mirror of
https://git.yoctoproject.org/poky
synced 2026-09-19 18:49:32 +02:00
bitbake: 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. (Bitbake rev: 25ccd697ea76f66b813be2296866b2d3405b079c) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
cbb8744735
commit
cba7d8f361
@@ -103,13 +103,18 @@ class AsyncClient(object):
|
|||||||
|
|
||||||
return await self._send_wrapper(proc)
|
return await self._send_wrapper(proc)
|
||||||
|
|
||||||
|
async def ping(self):
|
||||||
|
return await self.send_message(
|
||||||
|
{'ping': {}}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class Client(object):
|
class Client(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.client = self._get_async_client()
|
self.client = self._get_async_client()
|
||||||
self.loop = asyncio.new_event_loop()
|
self.loop = asyncio.new_event_loop()
|
||||||
|
|
||||||
self._add_methods('connect_tcp', 'close')
|
self._add_methods('connect_tcp', 'close', 'ping')
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def _get_async_client(self):
|
def _get_async_client(self):
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class AsyncServerConnection(object):
|
|||||||
self.max_chunk = DEFAULT_MAX_CHUNK
|
self.max_chunk = DEFAULT_MAX_CHUNK
|
||||||
self.handlers = {
|
self.handlers = {
|
||||||
'chunk-stream': self.handle_chunk,
|
'chunk-stream': self.handle_chunk,
|
||||||
|
'ping': self.handle_ping,
|
||||||
}
|
}
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
|
|
||||||
@@ -123,6 +124,10 @@ class AsyncServerConnection(object):
|
|||||||
|
|
||||||
await self.dispatch_message(msg)
|
await self.dispatch_message(msg)
|
||||||
|
|
||||||
|
async def handle_ping(self, request):
|
||||||
|
response = {'alive': True}
|
||||||
|
self.write_message(response)
|
||||||
|
|
||||||
|
|
||||||
class AsyncServer(object):
|
class AsyncServer(object):
|
||||||
def __init__(self, logger, loop=None):
|
def __init__(self, logger, loop=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user