Hello,

I'm having this script here:
----
import sys, tempfile, subprocess
if len(sys.argv) > 1:
        i = 0
        while i < 1000:
                print "Hello World" * 500
                i = i + 1
        exit( 1 )

h,fp = tempfile.mkstemp()
print "out: " + fp
out = open(fp, "r")
proc = subprocess.Popen( [sys.argv[0], "1"], stdout = h )
while proc.poll() is None:
        o = out.read()
        if o:
                print o
print out.read()
print "The end"
----

This scripts work wonders on Windows (and I've heard Linux is doing well too tyvm - although if one of you could check, I don't have a linux ready), but on OSX it outputs nothing. If I change the stdout of the subprocess for a pipe, it works well.

I cannot confirm that the bug comes from Python, but I'm pretty sure this should work normally. Does anyone know of this problem? Is there a workaround? A fix, maybe?

We're using temporary files because a pipe hangs out with large output, such as this one.

Thanks a lot,
Hans Larsen
--
My definition of an expert in any field is a person who knows enough about what's really going on to be scared.
P. J. Plauger
Computer Language, March 1983

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to