summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/asyncrpc/client.py
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-06-07 16:03:33 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-07-29 23:21:24 +0100
commit445c5b9324a6243a0a3941c5f00e369d7749efde (patch)
tree35bd69ece70784d0b4675bf2e6f99a016924b9c5 /bitbake/lib/bb/asyncrpc/client.py
parent57ec655accca89f0e8d1756cf7b2e73741240e11 (diff)
downloadpoky-445c5b9324a6243a0a3941c5f00e369d7749efde.tar.gz
bitbake: asyncrpc: Set timeout when waiting for reply from server
(Bitbake rev: b31f1853d7fcb8b8f8885ca513a0021a5d0301e6) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/asyncrpc/client.py')
-rw-r--r--bitbake/lib/bb/asyncrpc/client.py9
1 files changed, 7 insertions, 2 deletions
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
11 11
12 12
13class AsyncClient(object): 13class AsyncClient(object):
14 def __init__(self, proto_name, proto_version, logger): 14 def __init__(self, proto_name, proto_version, logger, timeout=30):
15 self.reader = None 15 self.reader = None
16 self.writer = None 16 self.writer = None
17 self.max_chunk = DEFAULT_MAX_CHUNK 17 self.max_chunk = DEFAULT_MAX_CHUNK
18 self.proto_name = proto_name 18 self.proto_name = proto_name
19 self.proto_version = proto_version 19 self.proto_version = proto_version
20 self.logger = logger 20 self.logger = logger
21 self.timeout = timeout
21 22
22 async def connect_tcp(self, address, port): 23 async def connect_tcp(self, address, port):
23 async def connect_sock(): 24 async def connect_sock():
@@ -70,7 +71,11 @@ class AsyncClient(object):
70 71
71 async def send_message(self, msg): 72 async def send_message(self, msg):
72 async def get_line(): 73 async def get_line():
73 line = await self.reader.readline() 74 try:
75 line = await asyncio.wait_for(self.reader.readline(), self.timeout)
76 except asyncio.TimeoutError:
77 raise ConnectionError("Timed out waiting for server")
78
74 if not line: 79 if not line:
75 raise ConnectionError("Connection closed") 80 raise ConnectionError("Connection closed")
76 81