Skip to content

Commit 0109821

Browse files
committedJul 7, 2015
tools: change asyncio_process_wait_timeout to handle cases where process.stdout is None. close #56
1 parent 2d343dd commit 0109821

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

Diff for: ‎artiq/tools.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ def asyncio_process_wait_timeout(process, timeout):
9191
# causes a futures.InvalidStateError inside asyncio if and when the
9292
# process terminates after the timeout.
9393
# Work around this problem.
94-
end_time = time.monotonic() + timeout
95-
r = True
96-
while r:
97-
r = yield from asyncio.wait_for(
98-
process.stdout.read(1024),
99-
timeout=end_time - time.monotonic())
100-
94+
@asyncio.coroutine
95+
def process_wait_returncode_timeout():
96+
while True:
97+
if process.returncode is not None:
98+
break
99+
yield from asyncio.sleep(0.1)
100+
yield from asyncio.wait_for(process_wait_returncode_timeout(),
101+
timeout=timeout)
101102

102103
@asyncio.coroutine
103104
def asyncio_process_wait(process):

0 commit comments

Comments
 (0)
Please sign in to comment.