Unbuffered stdout

leon leonar_n at epita.fr
Mon Nov 29 09:32:25 EST 1999


I use it into a cgi script, with apache, and for my IRC like, I must do
a thing like :
    while 1:
        strLine = self.pRoomFile.readline()
        while strLine:
            sys.stdout.write(strLine)
            sys.stdout.flush()
        strLine = self.pRoomFile.readline()
        time.sleep(1)

And the lines I print don't appear in the browser
Fredrik Lundh <fredrik at pythonware.com> wrote in message
news:046a01bf3a75$80b84d90$f29b12c2 at secret.pythonware.com...
> leon <leonar_n at epita.fr> wrote:
> > I'm developping an IRC like software which must work on the Web. I can't
use
> > Java, and I'm using Python to program the CGI. But, I have a big problem
: I
> > don't know how to make the stdout unbuffered.
> > I tried to make some
> >     sys.stdout.write("test")
> >     sys.stdout.flush()
> > but it don't work.
>
> looks fine to me.  maybe something else
> is wrong?
>
> anyway, you could try running the inter-
> preter with the -u option:
>
> $ python -?
> Unknown option: -?
> usage: python [option] ... [-c cmd | file | -] [arg] ...
> Options and arguments (and corresponding environment variables):
> ...
> -u     : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
> ...
>
> </F>
>
>
>






More information about the Python-list mailing list