X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;f=exec_utils.py;h=c1dbdcb70cf8917ceeca27c1a3b133168ab72171;hb=eedcbd4f64af13ec2098508c3d839a60f7e9ffce;hp=a52e206ad95496ebf4de9eb08f19df8073339d4a;hpb=f83dffe5e1c358ebfee2583f950a42cf7e909969;p=python_utils.git diff --git a/exec_utils.py b/exec_utils.py index a52e206..c1dbdcb 100644 --- a/exec_utils.py +++ b/exec_utils.py @@ -30,12 +30,13 @@ def cmd_showing_output(command: str, ) -> int: sel = selectors.DefaultSelector() sel.register(p.stdout, selectors.EVENT_READ) sel.register(p.stderr, selectors.EVENT_READ) - should_exit = False - while not should_exit: + stream_ends = 0 + while stream_ends < 2: for key, _ in sel.select(): char = key.fileobj.read(1) if not char: - should_exit = True + stream_ends += 1 + continue if key.fileobj is p.stdout: sys.stdout.buffer.write(char) if char in line_enders: @@ -45,6 +46,8 @@ def cmd_showing_output(command: str, ) -> int: if char in line_enders: sys.stderr.flush() p.wait() + sys.stdout.flush() + sys.stderr.flush() return p.returncode