提交 d683dbb0 编写于 作者: C Cleber Rosa

avocado.utils.process.SubProcess: use a single select() call

Besides a small optmization, it seems more correct a single I/O
readiness decision in each loop, instead of possible different
results in the two calls.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 00af60e3
......@@ -461,12 +461,12 @@ class SubProcess(object):
bfr = ''
while True:
if self._ignore_bg_processes:
# Exit if there are no new data and the main process finished
if (not select.select([fileno], [], [], 1)[0] and
self.result.exit_status is not None):
has_io = select.select([fileno], [], [], 1)[0]
if (not has_io and self.result.exit_status is not None):
# Exit if no new data and main process has finished
break
# Don't read unless there are new data available:
if not select.select([fileno], [], [], 1)[0]:
if not has_io:
# Don't read unless there are new data available
continue
tmp = os.read(fileno, 8192)
if tmp == '':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册