Problem using SocketServer.ThreadingTCPServer on Windows?

xtian xtian at paradise.net.nz
Thu May 31 17:39:43 EDT 2001


On Thu, 31 May 2001 16:12:32 +0200, Michael =?iso-8859-1?Q?Str=F6der?=
<michael at stroeder.com> wrote:

>Robert Amesz wrote:
>> 
>> Xtian wrote:
>> 
>> > AttributeError: 'int' object has no attribute 'send'
>> >
>> > It seems that after the second print, for no (obvious to me)
>> > reason, the conn object (which has reported it is a socket twice)
>> > is suddenly an int.
>> 
>> Using a closed socket will raise that cryptic exception. As I've not
>> used SocketServer before it's hard for me to tell *why* the socket 
>> has been closed.
>
>If it's Python 2.1 it could be this one:
>http://sourceforge.net/tracker/index.php?func=detail&aid=417845&group_id=5470&atid=105470
>
>Ciao, Michael.

Thanks Michael - I'm sure that's it. The main thread creates the
socket, creates the handler (in another thread), and then closes the
socket - without waiting for the handler thread to do it's stuff. Then
at some unpredictable time in the future, the thread tries to send or
receive something from the socket, and it's suddenly an int.

So is the solution to have the child thread call
server.close_request() after the loop, and modifiy the server class to
only call close_request if there's been an exception?

Thanks, 
Xtian



More information about the Python-list mailing list