<span style="font-family:comic sans ms,sans-serif">my /etc/resolv.conf says:<br><br></span><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex" class="gmail_quote">
<span style="font-family:courier new,monospace"># Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">nameserver 127.0.0.1</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">search Dynex</span><br style="font-family:courier new,monospace">

</blockquote><br style="font-family: comic sans ms,sans-serif;"><span style="font-family: comic sans ms,sans-serif;">But getaddrinfo still takes a lot of time for repeated queries. After installing BIND9 and starting it, getaddrinfo is almost instantaneous for repeated queries.</span><br style="font-family: comic sans ms,sans-serif;">
<br style="font-family: comic sans ms,sans-serif;"><span style="font-family: comic sans ms,sans-serif;">Thanks!</span><br><br><br><b>Chris Angelico</b> 
    <a href="mailto:python-list%40python.org?Subject=Re%3A%20making%20socket.getaddrinfo%20use%20cached%20dns&In-Reply-To=%3CCAPTjJmpJaa-M4z7kWbHwROpA6CjxtYeYrQPusdpnPqgCUktWDA%40mail.gmail.com%3E" title="making socket.getaddrinfo use cached dns" target="_blank">rosuav at gmail.com  </a>wrote:<br>

<pre style="margin-left:40px">On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth <<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">widebandwidth at gmail.com</a>> wrote:
><i> I use cached dns lookups with pdnsd on my ubuntu machine to speed up web
</i>><i> access as regular lookups can take 15-30 seconds. However, python's
</i>><i> mechanize and urllib etc use socket.getaddrinfo, which seems not to be using
</i>><i> dns cacheing or taking a long time because of ipv6 lookups. In either case,
</i>><i> I subsequent access to the same site to be fast and not require lengthy
</i>><i> calls to getaddrinfo. How can I get python to correctly use cached dns
</i>><i> lookups and ipv4 only (at least in those cases where it is appropriate).
</i>
One solution would be to do your own DNS lookups and then pass urllib
an IP address. Is pdnsd set up to be your computer's primary resolver?
(Is /etc/resolv.conf pointing to localhost?) If not, that might help.
I've generally done my DNS caching using BIND, so I can't help with
pdnsd specifically.

ChrisA</pre><br>