From f44fd6ba193bac99fb48ebd7264e7724d269f3d0 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Mon, 18 Sep 2017 04:42:30 +0200 Subject: [PATCH] flush json mode progress stderr output if borg stderr is not connected to a tty, but to ssh (when using borg client/server), sys.stderr is block buffered (tty: line buffered). thus we better flush explicitly after emitting a line as the receiving side can not handle partial json at the end of the block. also, it might solve some delays, when output didn't arrive at receiving side in time. (cherry picked from commit 2b75b278dab59b18a64aeb627bfcfc259804e825) --- src/borg/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/borg/helpers.py b/src/borg/helpers.py index 0432db2f0..77c87228a 100644 --- a/src/borg/helpers.py +++ b/src/borg/helpers.py @@ -1444,7 +1444,7 @@ class ProgressIndicatorBase: finished=finished, time=time.time(), )) - print(json.dumps(kwargs), file=sys.stderr) + print(json.dumps(kwargs), file=sys.stderr, flush=True) def finish(self): if self.json: