diff --git a/src/python/jw/pkg/lib/util.py b/src/python/jw/pkg/lib/util.py index 119ece1b..6d97fdb1 100644 --- a/src/python/jw/pkg/lib/util.py +++ b/src/python/jw/pkg/lib/util.py @@ -172,13 +172,20 @@ async def run_cmd( stderr_log_enc = output_encoding async def read_stream(stream, prio, collector: list[bytes], log_enc: str): + buf = b"" while True: - line = await stream.readline() - if not line: + chunk = await stream.read(4096) + if not chunk: break - collector.append(line) + collector.append(chunk) if verbose: - __log(prio, line.decode(log_enc, errors="replace").rstrip("\n")) + buf += chunk + while b"\n" in buf: + line, buf = buf.split(b"\n", 1) + __log(prio, line.decode(log_enc, errors="replace")) + if verbose and buf: + # flush trailing partial line (no newline) + __log(prio, buf.decode(log_enc, errors="replace")) tasks = [ asyncio.create_task(