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.
This commit is contained in:
Joey Hess 2016-12-17 17:20:45 -04:00
parent ec3599ff09
commit 8bec79289a

View File

@ -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()