readline() blocks after select() says there's data??

Grant Edwards grante at visi.com
Fri Mar 15 09:50:28 EST 2002


In article <mailman.1016168907.4720.python-list at python.org>, Skip Montanaro wrote:
> 
>     >>    selectables = [theProcess.childerr, theProcess.fromchild]
>     >>    (input, output, exc) = select.select([],selectables, selectables)
>     ...
> 
>     >> It blocks forever waiting for theProcess.childerr.readline(bufsize)
>     >> to return.  I expect it to block waiting for select.select(); that
>     >> would not be a problem.  The problem is that select is claiming
>     >> there's stuff to be read, then when I try to read it, it's not there!
>     >> How can that be?
> 
> Based upon the attribute names you are using, I suspect you instantiated
> os.Popen3 to create theProcess.  These are file objects, not sockets.

Under Unix (and Linux) those "file objects" would be pipes, and
select will work fine.  Under Windows, things are probably more
complicated.

> I believe select only blocks on sockets.

That is true under Win32 -- Just one of the problems when using
an OS where the networking was pasted on (badly) as an
afterthought.

Under Unix, select works on all file descriptors (sockets,
pipes, serial ports, etc.).  That demonstrates the _right_ way
to paste on networking as an afterthought.

> See the comments about asynchronous file i/o near the bottom of
> asyncore.py.


-- 
Grant Edwards                   grante             Yow!  Fold, fold,
                                  at               FOLD!! FOLDING many items!!
                               visi.com            



More information about the Python-list mailing list