Fix blocking read in Common.run
@@ -294,7 +294,8 @@ class Common(object):
# Capture the output
while process.poll() is None:
# Check which file descriptors are ready for read
- selected = select.select(descriptors, [], [])
+ selected = select.select(descriptors, [], [], timeout)
+
for descriptor in selected[0]:
# Handle stdout
if descriptor == process.stdout.fileno():
@@ -316,11 +317,15 @@ class Common(object):
timer.cancel()
# Check for possible additional output
+ selected = select.select(descriptors, [], [], timeout)
+ for descriptor in selected[0]:
+ if descriptor == process.stdout.fileno():
for line in process.stdout.readlines():
line = line.decode('utf-8', errors='replace')
stdout += line
log('out', line.rstrip('\n'), 'yellow', level=3)
- for line in [] if join else process.stderr.readlines():
+ if not join and descriptor == process.stderr.fileno():
+ for line in process.stderr.readlines():
line = line.decode('utf-8', errors='replace')
stderr += line
log('err', line.rstrip('\n'), 'yellow', level=3)
