mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-26 00:38:10 +00:00
Use wait_for for waiting a process with python 3.5
This commit is contained in:
parent
a14ad2fc99
commit
dcff51eb75
@ -77,12 +77,15 @@ def wait_for_process_termination(process, timeout=10):
|
|||||||
:param timeout: Timeout in seconds
|
:param timeout: Timeout in seconds
|
||||||
"""
|
"""
|
||||||
|
|
||||||
while timeout > 0:
|
if sys.version_info >= (3,5):
|
||||||
if process.returncode is not None:
|
yield from asyncio.wait_for(process.wait(), timeout=timeout)
|
||||||
return
|
else:
|
||||||
yield from asyncio.sleep(0.1)
|
while timeout > 0:
|
||||||
timeout -= 0.1
|
if process.returncode is not None:
|
||||||
raise asyncio.TimeoutError()
|
return
|
||||||
|
yield from asyncio.sleep(0.1)
|
||||||
|
timeout -= 0.1
|
||||||
|
raise asyncio.TimeoutError()
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
Loading…
Reference in New Issue
Block a user