Last active
August 29, 2015 14:25
-
-
Save cancan101/ac0dfde33a3909e459f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
"exec" "python" "-u" "--" "$0" "$@" | |
import os | |
import sys | |
import time | |
class ForceIOStream: | |
def __init__(self, stream): | |
self.stream = stream | |
def write(self, data): | |
self.stream.write(data) | |
self.stream.flush() | |
if not self.stream.isatty(): | |
os.fsync(self.stream.fileno()) | |
def __getattr__(self, attr): | |
return getattr(self.stream, attr) | |
sys.stdout = ForceIOStream(sys.stdout) | |
sys.stderr = ForceIOStream(sys.stderr) | |
for i in xrange(20): | |
print i | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment