Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #9048

Re: making socket.getaddrinfo use cached dns

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '(at': 0.03; 'ubuntu': 0.04; 'cached': 0.07; 'mechanize': 0.07; 'subject:making': 0.07; 'python': 0.08; 'am,': 0.13; 'received:209.85.214.174': 0.13; 'received:mail-iw0-f174.google.com': 0.13; 'wrote:': 0.15; '(is': 0.16; 'caching': 0.16; "computer's": 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'ipv6': 0.16; 'lookups': 0.16; 'subject:use': 0.16; 'subsequent': 0.16; 'subject:skip:s 10': 0.19; 'help.': 0.19; 'seems': 0.20; 'header:In-Reply-To:1': 0.22; "python's": 0.25; 'pass': 0.28; 'fri,': 0.28; 'received:209.85.214': 0.28; 'message-id:@mail.gmail.com': 0.28; 'least': 0.31; 'cases': 0.32; 'pointing': 0.32; 'generally': 0.33; 'done': 0.33; "i've": 0.33; 'to:addr:python-list': 0.34; 'however,': 0.34; "can't": 0.34; 'dns': 0.35; 'machine': 0.35; 'regular': 0.36; 'primary': 0.36; 'using': 0.37; 'received:google.com': 0.38; 'not,': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.38; 'case,': 0.38; 'correctly': 0.39; 'help': 0.39; 'either': 0.39; 'to:addr:python.org': 0.39; 'might': 0.39; 'received:209': 0.40; 'where': 0.40; 'your': 0.60; 'taking': 0.65; 'high': 0.68; 'lengthy': 0.84; 'bandwidth': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Zx/9xz54qr9ijQapEQXnSyrP2NBeewJqDqHzJ+x41ds=; b=ICrp6RO8q7wLKBMQxwt+Kl9kXiAgG6XYqyxcRUMM7pVRwGMFini16zWNmJh+Q8CrSv hKNaYWm+06T1559duTpuwYvJJ3YNhtita0UzmIVHkRKQjXGj68zDSyDO4Gn3aYwxENn3 8lww8I/MzX0HNLL5tOldbSic4aNERI6NktZgI=
MIME-Version 1.0
In-Reply-To <CALxN-yc8ajOfca0yoEMxVvv1RmkLuNuGoizSFk1sWG0_5fScig@mail.gmail.com>
References <CALxN-ye+_a1q5P8a2Z7AucHs06qYg6oA9j-2ziAhhDorxuBKOw@mail.gmail.com> <CALxN-yc8ajOfca0yoEMxVvv1RmkLuNuGoizSFk1sWG0_5fScig@mail.gmail.com>
Date Fri, 8 Jul 2011 04:26:37 +1000
Subject Re: making socket.getaddrinfo use cached dns
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.757.1310063200.1164.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1310063200 news.xs4all.nl 21866 [2001:888:2000:d::a6]:54427
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:9048

Show key headers only | View raw


On Fri, Jul 8, 2011 at 4:18 AM, high bandwidth <widebandwidth@gmail.com> wrote:
> I use cached dns lookups with pdnsd on my ubuntu machine to speed up web
> access as regular lookups can take 15-30 seconds. However, python's
> mechanize and urllib etc use socket.getaddrinfo, which seems not to be using
> dns cacheing or taking a long time because of ipv6 lookups. In either case,
> I subsequent access to the same site to be fast and not require lengthy
> calls to getaddrinfo. How can I get python to correctly use cached dns
> lookups and ipv4 only (at least in those cases where it is appropriate).

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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: making socket.getaddrinfo use cached dns Chris Angelico <rosuav@gmail.com> - 2011-07-08 04:26 +1000
  Re: making socket.getaddrinfo use cached dns Nobody <nobody@nowhere.com> - 2011-07-08 07:18 +0100

csiph-web