summaryrefslogtreecommitdiff
path: root/poky/bitbake/lib/bb/asyncrpc/client.py
diff options
context:
space:
mode:
authorjmbills <jason.m.bills@intel.com>2021-10-04 22:42:48 +0300
committerGitHub <noreply@github.com>2021-10-04 22:42:48 +0300
commit0c9e31989c615598b5d042ffab385606660c93c0 (patch)
tree8019999b0ca042482e5193d6cabc06220c71d776 /poky/bitbake/lib/bb/asyncrpc/client.py
parent04cd92067d2481643df5010cb39b2134b648cf4d (diff)
parentffe6d597d9e3d4407cf8062b5d6505a80ce08f41 (diff)
downloadopenbmc-0c9e31989c615598b5d042ffab385606660c93c0.tar.xz
Merge pull request #72 from Intel-BMC/update2021-0.751-0.75
Update
Diffstat (limited to 'poky/bitbake/lib/bb/asyncrpc/client.py')
-rw-r--r--poky/bitbake/lib/bb/asyncrpc/client.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/poky/bitbake/lib/bb/asyncrpc/client.py b/poky/bitbake/lib/bb/asyncrpc/client.py
index 79919c5be..50e60d5c3 100644
--- a/poky/bitbake/lib/bb/asyncrpc/client.py
+++ b/poky/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,14 +71,18 @@ 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")
line = line.decode("utf-8")
if not line.endswith("\n"):
- raise ConnectionError("Bad message %r" % msg)
+ raise ConnectionError("Bad message %r" % (line))
return line
@@ -114,6 +119,16 @@ class Client(object):
self.client = self._get_async_client()
self.loop = asyncio.new_event_loop()
+ # Override any pre-existing loop.
+ # Without this, the PR server export selftest triggers a hang
+ # when running with Python 3.7. The drawback is that there is
+ # potential for issues if the PR and hash equiv (or some new)
+ # clients need to both be instantiated in the same process.
+ # This should be revisited if/when Python 3.9 becomes the
+ # minimum required version for BitBake, as it seems not
+ # required (but harmless) with it.
+ asyncio.set_event_loop(self.loop)
+
self._add_methods('connect_tcp', 'close', 'ping')
@abc.abstractmethod