made sure file descriptors are tidied up correctly in tee_output
possibly fixes
@@ -127,7 +127,6 @@ def tee_output(target):
final_output = []
- try:
try:
tee_stdout = subprocess.Popen(
['tee', '-a', '/dev/stderr'],
@@ -147,7 +146,9 @@ def tee_output(target):
os.dup2(tee_stdout.stdin.fileno(), original_stdout_fd)
os.dup2(tee_stderr.stdin.fileno(), original_stderr_fd)
+ try:
yield final_output # let the caller do their printing
+ finally:
flush()
# then redirect stdout back to the saved fd
@@ -172,7 +173,6 @@ def tee_output(target):
finally:
tee_timer.cancel()
- finally:
os.close(saved_stdout_fd)
os.close(saved_stderr_fd)
target.flush()
