Seite 1 von 1

Ausgabe von subprocess welches flushed

Verfasst: Dienstag 15. November 2011, 00:42
von anogayales
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

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()
read.py

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"
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

Re: Ausgabe von subprocess welches flushed

Verfasst: Dienstag 15. November 2011, 00:46
von deets
Dann benutz doch read, nicht readlin. das warte auf ein line-feed, was du nicht hast.

Re: Ausgabe von subprocess welches flushed

Verfasst: Dienstag 15. November 2011, 00:52
von anogayales
deets hat geschrieben:Dann benutz doch read, nicht readlin. das warte auf ein line-feed, was du nicht hast.
Problem bleibt leider immer noch.

Platform: Win7 64, Python 2.6.6 32

Edit: Keiner eine Idee oder einen Anreiz? Bei einer ähnlichen Frage ist das select modul aufgetaucht. Scheint wohl unter Linux zu funktionieren unter Windows nicht.