Re: os.select misbehavior with pipe

Sjoerd Mullender (Sjoerd.Mullender@cwi.nl)
Tue, 10 Jan 1995 16:39:40 +0100

On Tue, Jan 10 1995 Ken Manheimer wrote:

> On Tue, 10 Jan 1995, Sjoerd Mullender wrote:
> > This is not what *ought* to happen. Select works on file descriptors
> > and returns any descriptors that have unread data. The readline
> > method uses stdio for its implementation, and stdio buffers. So after
> > the first readline all data has been read from the pipe and is stored
> > in an internal buffer from which the second and third line are
>
> Ah. So, how does one determine whether there are buffered contents in the
> stdio buffers, from within python? Or does something like that need to be
> added. (This assumes, to further reveal my ignorance, that there *is*
> some standard handle for identifying the buffered contents. ?)

By now you have probably also read Guido's reply to my reply.
Unfortunately there is no portable way to check whether there is any
buffered input in stdio. The alternatives are to not buffer the input
(needs a patch to the fdopen implementation which will be in Python
1.2) or to not use stdio at all (and thus no file objects) but to use
os.read instead.

Sjoerd Mullender, CWI, P.O. Box 94079, 1090 GB Amsterdam, The Netherlands
E-Mail: Sjoerd.Mullender@cwi.nl; Phone: +31 20 592 4127; Fax: +31 20 592 4199
URL: http://www.cwi.nl/cwi/people/Sjoerd.Mullender.html