Ausgabe von subprocess welches flushed
Verfasst: Dienstag 15. November 2011, 00:42
Hi Community,
ich versuche, an eine Ausgabe eines Programms zu kommen, welches Stdout regelmäßig flushed. Irgendwie komm ich nicht an die Daten.
output.py
read.py
Er scheint bei mir bei process.stdout.readline() hängen zu bleiben. Gibts da irgendeinen Weg wie ich an die Ausgabe rankomme?
Grüße,
anogayales
ich versuche, an eine Ausgabe eines Programms zu kommen, welches Stdout regelmäßig flushed. Irgendwie komm ich nicht an die Daten.
output.py
Code: Alles auswählen
import sys
import time
for x in range(200):
sys.stdout.write("\r"+str(x))
time.sleep(0.125)
sys.stdout.flush()
Code: Alles auswählen
import subprocess
command_string = "C:\Python26\python.exe output.py"
process = subprocess.Popen(command_string, stdout=subprocess.PIPE)
while True:
buff = process.stdout.readline()
print process, buff
if buff == '' and process.poll() != None:
print "breaking"
break
process.wait()
print "finished"
Grüße,
anogayales