Grupy dyskusyjne Google nie obsługują już nowych postów ani subskrypcji z Usenetu. Treści historyczne nadal będą dostępne.

unbuffered stdout?

577 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Aaron Watters

nieprzeczytany,
5 sie 1996, 03:00:005.08.1996
do

Quicky: how do you do unbuffered stdout?
I don't see any setbuf anywhere and I don't wanna
hafta flush() everywhere. fcntl? (unix/solaris)
thanks,
aaron watters.

Guido van Rossum

nieprzeczytany,
5 sie 1996, 03:00:005.08.1996
do

> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)

Use 0 for the optional 3rd arg to open() (and most other things that
return a standard file object). For stdout/stderr, use "python -u".
It is done this way because stdio crashes spectacularly (on some
systems) if you call set*buf() after doing any I/O, and there's no
portable way to test whether it is still allowed to call it, so I would
have to maintain my own state variable just to implement a safe
setbuf() method... Adding it to open made a lot more sense.

--Guido van Rossum (home page: http://www.python.org/~guido/)

Dave Mitchell

nieprzeczytany,
5 sie 1996, 03:00:005.08.1996
do


On Mon, 5 Aug 1996, Aaron Watters wrote:

> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)

> thanks,
> aaron watters.
>


Not sure the right way to do this, but open() and fdopen() both
take a third argument that is the buffersize.

Dave

tri...@speedy.supelec.fr

nieprzeczytany,
5 sie 1996, 03:00:005.08.1996
do

Aaron Watters (a...@big.att.com) wrote:
: Quicky: how do you do unbuffered stdout?
: I don't see any setbuf anywhere and I don't wanna
: hafta flush() everywhere. fcntl? (unix/solaris)
: thanks,
: aaron watters.

you can use the -u switch or setenv PYTHONUNBUFFERED 1, or even modify
main.c, or sysinit() in sysmodule.c so that it creates unbuffered sys.stdout
and sys.stderr, or add setbuf and setvbuf methods to the Python file type.
My guess is you'll prefer the 2 first ways :-)

Benoit

Robin Friedrich

nieprzeczytany,
6 sie 1996, 03:00:006.08.1996
do

Aaron Watters <a...@big.att.com> writes:

>
> Quicky: how do you do unbuffered stdout?
> I don't see any setbuf anywhere and I don't wanna
> hafta flush() everywhere. fcntl? (unix/solaris)
> thanks,
> aaron watters.

How about

python -u

Nowe wiadomości: 0