while True:
    out = process.stdout.read(1)
if out == '' and process.poll() != None:
    break
if out != '':
    sys.stdout.write(out)
sys.stdout.flush()
Is there a way to poll a file handle returned from subprocess.Popen?