Author Evan.Teran
Recipients Evan.Teran
Date 2010-01-18.22:51:37
SpamBayes Score 5.91749e-14
Marked as misclassified No
Message-id <>
I have encountered an issue where python will do a AAAA request even when built without IPv6. This becomes an issue because on some configurations this seems to cause a 5 second delay on DNS lookups (that is a separate issue of course). Basically here is what I am seeing:

import urllib2
print urllib2.urlopen('').read(100)

results in the following:

0.000000 ->      DNS Standard query A
  0.000023 ->      DNS Standard query AAAA
  0.005369 ->  DNS Standard query response A
  5.004494 ->      DNS Standard query A
  5.010540 ->  DNS Standard query response A
  5.010599 ->      DNS Standard query AAAA
  5.015832 ->  DNS Standard query response AAAA 2001:888:2000:d::a2

looking at in create_connection() (line 500 on my python 2.6.4 stdlib) the code is like this:

    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
        af, socktype, proto, canonname, sa = res
        sock = None
            sock = socket(af, socktype, proto)
            if timeout is not _GLOBAL_DEFAULT_TIMEOUT:
            return sock

        except error, msg:
            if sock is not None:

The 3rd argument is the socket type, which is set to 0 which apparently means unspecified. It seems to me that if python is built without IPv6 support it should instead pass AF_INET since even if it does get an IPv6 response it can't possibly use it.
Date User Action Args
2010-01-18 22:51:39Evan.Teransetrecipients: + Evan.Teran
2010-01-18 22:51:39Evan.Teransetmessageid: <>
2010-01-18 22:51:38Evan.Teranlinkissue7735 messages
2010-01-18 22:51:37Evan.Terancreate