From 6e67b000efb89c4e3121fd907a47dc7042c07bed Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Fri, 3 Nov 2023 08:26:30 -0600 Subject: [PATCH] bitbake: asyncrpc: client: Add disconnect API Adds an API to explicitly disconnect a client. This can be useful for testing the auto-reconnect behavior of clients (Bitbake rev: cb2fec7eaca20608faf4b8ff11ec8590ac7f2229) Signed-off-by: Joshua Watt Signed-off-by: Richard Purdie --- bitbake/lib/bb/asyncrpc/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py index 628b90ee05..0d7cd85780 100644 --- a/bitbake/lib/bb/asyncrpc/client.py +++ b/bitbake/lib/bb/asyncrpc/client.py @@ -67,11 +67,14 @@ class AsyncClient(object): self.socket = await self._connect_sock() await self.setup_connection() - async def close(self): + async def disconnect(self): if self.socket is not None: await self.socket.close() self.socket = None + async def close(self): + await self.disconnect() + async def _send_wrapper(self, proc): count = 0 while True: @@ -160,6 +163,9 @@ class Client(object): def max_chunk(self, value): self.client.max_chunk = value + def disconnect(self): + self.loop.run_until_complete(self.client.close()) + def close(self): if self.loop: self.loop.run_until_complete(self.client.close())