diff options
author | Paul Barker <pbarker@konsulko.com> | 2021-05-28 09:42:06 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-06 23:18:26 +0100 |
commit | cba7d8f361bbb49021055fc820a68a8198b85f1d (patch) | |
tree | bf028bc14dc7e7b111ae53eac4c2bdde423cdcc3 /bitbake/lib | |
parent | cbb87447356578c439c2ac636bd619c868afad63 (diff) | |
download | poky-cba7d8f361bbb49021055fc820a68a8198b85f1d.tar.gz |
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>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/asyncrpc/client.py | 7 | ||||
-rw-r--r-- | bitbake/lib/bb/asyncrpc/serv.py | 5 |
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 | ||
107 | class Client(object): | 112 | class 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 | ||
127 | class AsyncServer(object): | 132 | class AsyncServer(object): |
128 | def __init__(self, logger, loop=None): | 133 | def __init__(self, logger, loop=None): |