From 8bec79289a2565760aeecf044177da6876877b38 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 17 Dec 2016 17:20:45 -0400 Subject: [PATCH 1/2] 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() From 57c0894774fc76e2a54ad2902a4229c56c3ed50b Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Sat, 17 Dec 2016 17:32:12 -0800 Subject: [PATCH 2/2] cmd_send: flush args.stdout, in case it's different --- src/wormhole/cli/cmd_send.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wormhole/cli/cmd_send.py b/src/wormhole/cli/cmd_send.py index 24d9b1c..958f794 100644 --- a/src/wormhole/cli/cmd_send.py +++ b/src/wormhole/cli/cmd_send.py @@ -85,7 +85,7 @@ 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() + args.stdout.flush() print(u"", file=args.stdout) yield w.establish_key()