Select hangs after some reads

Grant Edwards grante at
Thu Jun 8 15:19:27 CEST 2006

On 2006-06-08, alsmeirelles at <alsmeirelles at> 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...

More information about the Python-list mailing list