From dcff51eb7561da3280ddd36bfccedb244367b9aa Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 17 Nov 2016 18:09:46 +0100 Subject: [PATCH] Use wait_for for waiting a process with python 3.5 --- gns3server/utils/asyncio/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gns3server/utils/asyncio/__init__.py b/gns3server/utils/asyncio/__init__.py index 34eef732..524903ad 100644 --- a/gns3server/utils/asyncio/__init__.py +++ b/gns3server/utils/asyncio/__init__.py @@ -77,12 +77,15 @@ def wait_for_process_termination(process, timeout=10): :param timeout: Timeout in seconds """ - while timeout > 0: - if process.returncode is not None: - return - yield from asyncio.sleep(0.1) - timeout -= 0.1 - raise asyncio.TimeoutError() + if sys.version_info >= (3,5): + yield from asyncio.wait_for(process.wait(), timeout=timeout) + else: + while timeout > 0: + if process.returncode is not None: + return + yield from asyncio.sleep(0.1) + timeout -= 0.1 + raise asyncio.TimeoutError() @asyncio.coroutine