From 63f427b0b8be2102bcc8251d7548e0f51b81f00e Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 4 Jul 2021 01:02:57 +0100 Subject: [PATCH] flush {stderr,stdout} on init - (re) fixes #1177 --- tqdm/std.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tqdm/std.py b/tqdm/std.py index 08cd00d3..fb4aa6ad 100644 --- a/tqdm/std.py +++ b/tqdm/std.py @@ -336,7 +336,9 @@ class tqdm(Comparable): """ fp = file fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover - fp_flush() + if fp in (sys.stderr, sys.stdout): + sys.stderr.flush() + sys.stdout.flush() def fp_write(s): fp.write(_unicode(s))