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


Groups > comp.lang.python > #53433

Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'python.': 0.02; 'url:pypi': 0.03; 'third-party': 0.04; 'subject:skip:s 10': 0.07; "'python": 0.09; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hostname': 0.16; 'subject:slow': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'seems': 0.21; 'issue.': 0.22; 'config': 0.24; 'mon,': 0.24; 'nearly': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'subject:) ': 0.29; 'message-id:@mail.gmail.com': 0.30; 'sep': 0.31; 'url:python': 0.33; 'core': 0.34; 'subject:from': 0.34; 'subject: (': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; "didn't": 0.36; 'shows': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'address.': 0.39; 'results.': 0.60; 'most': 0.60; 'more': 0.64; '(according': 0.84; 'perfect!': 0.84; 'quicker': 0.84; 'subject:skip:g 10': 0.84; 'you;': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cBhKqPMra0unWFvR1mXSSM1FhyVtkINaqBudmxTDu7U=; b=fHORZuK1YLuiptyYba6tOIohOGc7BjkA2iOt1WK74qPo9l2GCi3gAkOIs6wO7hGzhV I3ptJzmAB957wS7+B3h/TUpaaAsmLoz/ZywD2jT0Fy+KCQTwGTzS07kx4PMBLSQ2oKaP WOiV3drLiXF5CA/QCilZ+i6VwvwodmtAFnbdFzqnx9ajQISNSitdy9nT1J6Gum7VwqKM 0tbA5dhtfv547rHt/25udaCd0jCsErB/dm6hMFVV3MS0bYDXZWVOUDt7kfU2umgzTrgF IXRfrCqwIo/s6EWUMPylZzx4GU3ZMHRq9Sch9W/GxLWS9M1gTiCLXXrcVjXX5iO3UUO+ pLMA==
MIME-Version 1.0
X-Received by 10.58.235.69 with SMTP id uk5mr19690358vec.17.1378069436074; Sun, 01 Sep 2013 14:03:56 -0700 (PDT)
In-Reply-To <9cca25d5-186d-4a92-893c-f7985fad7a55@googlegroups.com>
References <b9f77b6f-3a65-407a-aff5-5677be2ba228@googlegroups.com> <mailman.446.1378035456.19984.python-list@python.org> <9cca25d5-186d-4a92-893c-f7985fad7a55@googlegroups.com>
Date Mon, 2 Sep 2013 07:03:56 +1000
Subject Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)
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.15
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.459.1378069438.19984.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378069438 news.xs4all.nl 15936 [2001:888:2000:d::a6]:58997
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53433

Show key headers only | View raw


On Mon, Sep 2, 2013 at 6:37 AM,  <anntzer.lee@gmail.com> wrote:
> On Sunday, September 1, 2013 4:37:34 AM UTC-7, Chris Angelico wrote:
>
>> Yes, it most definitely CAN be a network config issue. The C function
>> you want to be calling is getifaddrs(), and I don't think there's a
>> way to call that from core Python. But a Google search for 'python
>> getifaddrs' shows up a few third-party modules that might be of use to
>> you; that'd be a lot quicker and more reliable than trying to look up
>> your own hostname and depending on the results.
>>
>> ChrisA
>
> I tried using netifaces (https://pypi.python.org/pypi/netifaces) which seems to rely on getifaddrs (according to the doc, I didn't check the source).  Again, it returns nearly instantaneously the correct IP address.

Perfect!

ChrisA

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


Thread

gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-08-31 17:03 -0700
  Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Roy Smith <roy@panix.com> - 2013-08-31 21:01 -0400
    Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-08-31 21:51 -0700
      Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Michael Torrie <torriem@gmail.com> - 2013-08-31 23:06 -0600
        Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-09-01 10:13 -0700
      Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Roy Smith <roy@panix.com> - 2013-09-01 06:57 -0400
  Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Chris Angelico <rosuav@gmail.com> - 2013-09-01 21:37 +1000
    Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-09-01 13:37 -0700
      Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Chris Angelico <rosuav@gmail.com> - 2013-09-02 07:03 +1000
        Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-09-01 22:28 -0700
          Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Chris Angelico <rosuav@gmail.com> - 2013-09-02 20:42 +1000
          Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Roy Smith <roy@panix.com> - 2013-09-02 08:45 -0400
            Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) anntzer.lee@gmail.com - 2013-09-02 10:52 -0700
              Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) Chris Angelico <rosuav@gmail.com> - 2013-09-03 07:12 +1000

csiph-web