Wait for both streams to end.
authorScott <[email protected]>
Fri, 21 Jan 2022 18:19:34 +0000 (10:19 -0800)
committerScott <[email protected]>
Fri, 21 Jan 2022 18:19:34 +0000 (10:19 -0800)
exec_utils.py

index a52e206ad95496ebf4de9eb08f19df8073339d4a..b4e88bda36361064591d2c336f787e4fb234ae37 100644 (file)
@@ -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: