backup: flush stderr after all writes

This commit is contained in:
Jim Paris 2021-10-18 19:35:39 -04:00
parent 4a30b82e39
commit 4b7802ad5f

View File

@ -122,6 +122,7 @@ class Backup:
c = colors[letter] if letter in colors else 0
b = "" if bold else "\033[22m"
sys.stderr.write(f"\033[1;{c}m{letter}:{b} {msg}\033[0m\n")
sys.stderr.flush()
self.logs.append((letter, msg))
def run(self, outfile: typing.IO[bytes]):
@ -382,6 +383,7 @@ def main(argv: typing.List[str]):
backup.run(borg.stdin)
except BrokenPipeError:
sys.stderr.write(f"broken pipe\n")
sys.stderr.flush()
finally:
try:
borg.stdin.close()