Skip to content

Instantly share code, notes, and snippets.

@cancan101

cancan101/slow.py

Last active Aug 29, 2015
Embed
What would you like to do?
#!/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