Skip to content

Instantly share code, notes, and snippets.

@fsword
Created June 26, 2014 10:35
Show Gist options
  • Save fsword/36a9395d8c11a4a72361 to your computer and use it in GitHub Desktop.
Save fsword/36a9395d8c11a4a72361 to your computer and use it in GitHub Desktop.
python stdout auto flush
import time,sys,os
# usage:
# ssh localhost 'python <this_file>'
def test():
j = True
while j:
time.sleep(1)
print("Hello:"+str(j))
print "Bye"
if __name__ == "__main__":
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
test()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment