diff options
| -rw-r--r-- | bitbake/lib/bb/asyncrpc/client.py | 9 |
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 | ||
| 13 | class AsyncClient(object): | 13 | class 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 | ||
