forked from M-Labs/artiq
tools: change asyncio_process_wait_timeout to handle cases where process.stdout is None. close #56
This commit is contained in:
parent
2d343dd95d
commit
0109821078
|
@ -91,13 +91,14 @@ def asyncio_process_wait_timeout(process, timeout):
|
||||||
# causes a futures.InvalidStateError inside asyncio if and when the
|
# causes a futures.InvalidStateError inside asyncio if and when the
|
||||||
# process terminates after the timeout.
|
# process terminates after the timeout.
|
||||||
# Work around this problem.
|
# Work around this problem.
|
||||||
end_time = time.monotonic() + timeout
|
@asyncio.coroutine
|
||||||
r = True
|
def process_wait_returncode_timeout():
|
||||||
while r:
|
while True:
|
||||||
r = yield from asyncio.wait_for(
|
if process.returncode is not None:
|
||||||
process.stdout.read(1024),
|
break
|
||||||
timeout=end_time - time.monotonic())
|
yield from asyncio.sleep(0.1)
|
||||||
|
yield from asyncio.wait_for(process_wait_returncode_timeout(),
|
||||||
|
timeout=timeout)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def asyncio_process_wait(process):
|
def asyncio_process_wait(process):
|
||||||
|
|
Loading…
Reference in New Issue