From 4c954f1317c73b7d48059c36c58968a2cc48ea31 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 11 Feb 2020 10:36:01 -0800 Subject: [PATCH] Fix output concurrency --- chonker.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/chonker.py b/chonker.py index f8f1a49..ebb7e47 100644 --- a/chonker.py +++ b/chonker.py @@ -35,8 +35,8 @@ def parse_args(): "command invocation") parser.add_argument("--verbose", "-v", action="store_true", help="Verbose " "logging.") - parser.add_argument("--chunk", type=filesize, default=1024, help="Chunk size in bytes.") - parser.add_argument("--bufsize", type=filesize, default=1024, help="Buffer " + parser.add_argument("--chunk", type=filesize, default="1K", help="Chunk size in bytes.") + parser.add_argument("--bufsize", type=filesize, default="1K", help="Buffer " "size for reading from stdin.") parser.add_argument("--exec", required=True, help="Command to pipe chunks to.") # parser.add_argument("--inc", help="Pattern to find/replace with the " @@ -144,7 +144,8 @@ def pipe_chunk_to_command(command, chunk): Executes the given command, passing the chunk to its stdin via buf_size buffers. """ logger = logging.getLogger(__name__) - logger.info(f"Piping chunk | {command}") + sys.stdout.buffer.write(f"Piping chunk | {command}\n".encode('utf8')) + sys.stdout.flush() child = spawn(command) child.logfile_read = sys.stdout.buffer for buf in chunk: