Select hangs after some reads

Grant Edwards grante at visi.com
Thu Jun 8 09:19:27 EDT 2006


On 2006-06-08, alsmeirelles at gmail.com <alsmeirelles at gmail.com> wrote:

> Well, actually I´m using a very simple protocol wich sends only
> strings ended by newline. I need to send 3 chunks of information and a
> newline after them. On the reader side I make 3 readline(), this way I
> wouldn´t have to care about this problem, but maybe that´s where I´m
> falling. If that´s the case, I´ll have to use a more complex
> protocol.

You can't use readline() with select().  Select tells you
whether recv() called on the underlying socket will block or
not.  What's probably happening is that all of the data has
been read from the underlying socket and is being held in a
buffer waiting to be read by readline().   

The Select call has no way of knowing about that buffered data.
As far as it's concerned there's no more data left to read, so
it block until the socket is closed.

-- 
Grant Edwards                   grante             Yow!  My mind is a potato
                                  at               field...
                               visi.com            



More information about the Python-list mailing list