Another socket/thread question

Jon Ribbens jon+usenet at unequivocal.co.uk
Wed Mar 13 20:20:20 EST 2002


In article <7934d084.0203131616.488b4ace at posting.google.com>, Andrae Muys wrote:
>> When you close the socket from another thread or by the server,
>> the pending socket.recv() should terminate with some error condition.
>> It's best to test both situations, however.
> 
> Far cleaner to open a control pipe to the thread and have the thread
> wait on both the socket and the pipe.

Why is that cleaner? Closing the socket from another thread and
expecting that to terminate the recv() should be fine.

On the other hand, I have had problems with that scenario before due
to buggy operating systems. I fixed it by select()ing on that socket
(and only that socket) before reading from it.



More information about the Python-list mailing list