From 1c5ed98430cc18edad2e81873370b9c0f0ad9175 Mon Sep 17 00:00:00 2001 From: Dan Bungert Date: Thu, 7 Oct 2021 13:12:40 -0600 Subject: [PATCH] test/api: fix hang on server shutdown If the server was fully hung, then these shutdown steps were also stuck. --- subiquity/tests/api/test_api.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/subiquity/tests/api/test_api.py b/subiquity/tests/api/test_api.py index 4d45def7..0042b4e8 100755 --- a/subiquity/tests/api/test_api.py +++ b/subiquity/tests/api/test_api.py @@ -107,12 +107,14 @@ class Server(Client): self.server_task = asyncio.create_task(self.proc.communicate()) async def close(self): - await self.server_shutdown() - await self.server_task try: - self.proc.kill() - except ProcessLookupError: - pass + await asyncio.wait_for(self.server_shutdown(), timeout=2.0) + await asyncio.wait_for(self.server_task, timeout=1.0) + finally: + try: + self.proc.kill() + except ProcessLookupError: + pass class TestAPI(unittest.IsolatedAsyncioTestCase):