Force line buffering when output is stdout

For some reason, I had decided that non-stdout output needed to be line buffered, but not stdout? Python will only line buffer stdout by default if it is a TTY, and there are lots of use cases where it is not. And since I started re-opening the output FD, the python executable command line option (-u) no longer works to force it to be unbuffered.

Fix #44
This commit is contained in:
sparky8512 2022-04-13 08:54:25 -07:00
parent 35150803ef
commit f08682af30

View file

@ -110,7 +110,7 @@ def parse_args():
def open_out_file(opts, mode): def open_out_file(opts, mode):
if opts.out_file == "-": if opts.out_file == "-":
# open new file, so it can be closed later without affecting sys.stdout # open new file, so it can be closed later without affecting sys.stdout
return os.fdopen(sys.stdout.fileno(), "w", closefd=False) return os.fdopen(sys.stdout.fileno(), "w", buffering=1, closefd=False)
return open(opts.out_file, mode, buffering=1) return open(opts.out_file, mode, buffering=1)