From 445c5b9324a6243a0a3941c5f00e369d7749efde Mon Sep 17 00:00:00 2001 From: Paul Barker Date: Mon, 7 Jun 2021 16:03:33 +0100 Subject: bitbake: asyncrpc: Set timeout when waiting for reply from server (Bitbake rev: b31f1853d7fcb8b8f8885ca513a0021a5d0301e6) Signed-off-by: Paul Barker Signed-off-by: Richard Purdie --- bitbake/lib/bb/asyncrpc/client.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py index d917ab597c..3eb4fdde8a 100644 --- a/bitbake/lib/bb/asyncrpc/client.py +++ b/bitbake/lib/bb/asyncrpc/client.py @@ -11,13 +11,14 @@ from . import chunkify, DEFAULT_MAX_CHUNK class AsyncClient(object): - def __init__(self, proto_name, proto_version, logger): + def __init__(self, proto_name, proto_version, logger, timeout=30): self.reader = None self.writer = None self.max_chunk = DEFAULT_MAX_CHUNK self.proto_name = proto_name self.proto_version = proto_version self.logger = logger + self.timeout = timeout async def connect_tcp(self, address, port): async def connect_sock(): @@ -70,7 +71,11 @@ class AsyncClient(object): async def send_message(self, msg): async def get_line(): - line = await self.reader.readline() + try: + line = await asyncio.wait_for(self.reader.readline(), self.timeout) + except asyncio.TimeoutError: + raise ConnectionError("Timed out waiting for server") + if not line: raise ConnectionError("Connection closed") -- cgit v1.2.3-54-g00ecf