bad httplib latency due to IPv6 use

Ulrich Eckhardt ulrich.eckhardt at dominolaser.com
Wed Oct 17 03:55:13 EDT 2012


Hi!

I noticed yesterday that a single HTTP request to localhost takes 
roughly 1s, regardless of the actually served data, which is way too 
long. After some digging, I found that the problem lies in 
socket.create_connection(), which first tries the IPv6 ::1 and only then 
tries the IPv4 127.0.0.1. The first one times out after 1s, causing the 
long latency.

What I'm wondering is this:
1. The server only serves on IPv4, changing this to IPv6 would probably 
help. However, I wouldn't consider this a bug, or?
2. I don't even have any IPv6 addresses configured and I'm not using 
IPv6 in any way, so why does it try those at all?
3. Of course I can optimize the code for IPv4, but then I would be 
pessimizing IPv6 and vice versa...

Any other suggestions?

Uli


Notes:
  * Using 127.0.0.1 as host works without the delay.
  * I'm using Python 2.7 on win7/64bit



More information about the Python-list mailing list