From f08682af30101c4d75f4074be980d9e33960e226 Mon Sep 17 00:00:00 2001 From: sparky8512 <76499194+sparky8512@users.noreply.github.com> Date: Wed, 13 Apr 2022 08:54:25 -0700 Subject: [PATCH] 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 --- dish_grpc_text.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dish_grpc_text.py b/dish_grpc_text.py index 29b844e..db5c03a 100644 --- a/dish_grpc_text.py +++ b/dish_grpc_text.py @@ -110,7 +110,7 @@ def parse_args(): def open_out_file(opts, mode): if opts.out_file == "-": # 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)