From 8bec79289a2565760aeecf044177da6876877b38 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 17 Dec 2016 17:20:45 -0400 Subject: [PATCH] send: flush stdout after displaying code Fixes https://github.com/warner/magic-wormhole/issues/108 Apparently python defaults to buffering stdout when not outputting to the terminal. It would be better IMHO if every line of stdout were autoflushed, but based on http://stackoverflow.com/questions/107705/disable-output-buffering there's not a really good way to accomplish that in python. --- src/wormhole/cli/cmd_send.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 2c46af8..24d9b1c 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -84,6 +84,8 @@ class Sender: if not args.zeromode: print(u"Wormhole code is: %s" % code, file=args.stdout) + # flush stdout so the code is displayed immediately + sys.stdout.flush() print(u"", file=args.stdout) yield w.establish_key()