[Python-Dev] 2.4 asyncore headache

Tim Peters tim.peters at gmail.com
Sat Aug 14 18:15:35 CEST 2004


[Tim]
>> Which OS?  asyncore isn't involved in that test, so the patch could
>> not have affected it.  SocketServer.py has its own, separate code
>> using SO_REUSEADDR in some cases.

[Nick Coghlan]
> Ah, OK, it was just a thought. I'm on Windows XP SP1,

Same here.

> and it's consistently choking on the second attempt to test the UDP Server:

Not here, but there are many ways to run the tests, and how you run
them may also be important.  I don't know of a way that "should" fail
in this test, but I'll show you one way that works on my SP1 box:

C:\Code\python\PCbuild>python ../lib/test/test_socketserver.py
ADDR = ('localhost', 16401)
CLASS = SocketServer.TCPServer
server created
server running
thread: creating server
thread: serving three times
test client 0
test client 1
test client 2
thread: done
waiting for server
done
ADDR = ('localhost', 16402)
CLASS = SocketServer.ThreadingTCPServer
server created
server running
thread: creating server
thread: serving three times
test client 0
test client 1
test client 2
thread: done
waiting for server
done
ADDR = ('localhost', 16403)
CLASS = SocketServer.UDPServer
server created
server running
thread: creating server
thread: serving three times
test client 0
test client 1
test client 2
thread: done
waiting for server
done
ADDR = ('localhost', 16404)
CLASS = SocketServer.ThreadingUDPServer
server created
server running
thread: creating server
thread: serving three times
test client 0
test client 1
test client 2
thread: done
waiting for server
done

C:\Code\python\PCbuild>

> ...
> I plan to do some more poking to try and narrow down a bit further what
> is going on before going to SF with it. (There are 5 different network
> connections on this laptop, including a virtual one to the Linux
> install, so I wouldn't be surprised if there is something odd going on
> with the network interface)

Neither would I <wink>.

...
> Indeed. I think it suggests that continuing to use SO_REUSEADDR normally
> on Windows is the best option for ayncore, though.

"normally" is loaded:  *normally* (by default), asyncore doesn't use
SO_REUSEADDR at all, on any box.  You have to call
asyncore.dispatcher.set_reuse_addr() explicitly if you *want* to get
into the reuse game (and, e.g., ZEO does).  The only asyncore client
in the Python core that does this is smtpd.SMTPServer.

> Windows users just need to be aware that it doesn't mean quite the same
> thing as it does on a Unix-like system

In general, they aren't aware of such subtle distinctions -- and most
would simply be annoyed if you insisted that they should be <0.7
wink>.

> (actually, some of the other Google hits made me wonder if it really means
> the same thing in all the different Unix variants in the first place. . .)

Alas, portability across Unix variants is often spelled #ifdef.


More information about the Python-Dev mailing list