[Python-Dev] socket.create_connection slow
Kristján Valur Jónsson
kristjan at ccpgames.com
Wed Jan 14 12:23:46 CET 2009
I spent the morning trying to find out why the disabled tests in test_xmlrpc.py ran so slowly on my vista box.
After much digging, I found that it boiled down to socket.create_connection() trying to connect to "localhost", port.
You see, it does a getaddrinfo() and then tries to connect using all the various addresses it finds until it succeeds.
On Vista, it will return an AF_INET6 entry before the AF_INET one and try connection to that. This connect() attemt fails after approximately one second, after which we proceed to do an immediately successful connect() call to the AF_INET address.
Now, I did fix this in test_xmlrpc.py by just speficying the loopback address, but I wonder if this might not be a problem in general?
I can think of two things to make this better:
1) Make sure that AF_INET addresses are tried first in socket.create_connection()
2) Have the SocketServer create a listening socket for each address family by default.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev