Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'python.': 0.02; 'third- party': 0.04; 'subject:skip:s 10': 0.07; "'python": 0.09; 'addr': 0.16; '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; 'nearly': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'am,': 0.29; 'subject:) ': 0.29; 'message- id:@mail.gmail.com': 0.30; 'sep': 0.31; 'linux': 0.33; 'addresses': 0.33; 'trouble': 0.34; 'core': 0.34; 'subject:from': 0.34; 'subject: (': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'machine.': 0.36; 'skip:" 50': 0.36; 'shows': 0.36; 'behind': 0.37; 'list': 0.37; 'server': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'anything': 0.39; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'results.': 0.60; 'most': 0.60; 'information': 0.63; 'more': 0.64; '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:content-transfer-encoding; bh=sI1ok0rmvKnBzgZXBt5AYVySXrH8SEmMAHj+d3aiiCk=; b=XJePUHbLX0hMit8g0hncg3H2bE0ScZgMdvk89PJYIriWQXFKIsAGUWo0+CcqFD/QJX tndc/rBij051moJ5H0ajMiQlsWxLJorSqwOf/96Lw1IqLv+77y+oHFWf0NlrS3p3boHv wWeSWP3V9nJe8YL3xjE3loMHaYnxB+BUPp4jMyLymuL4CegLrmlKdrk7jDSABzcps5TG N7LDDxcUkueJxPdIkO/1QOEXmXHUTnHGnm0cM7vTpZjxNOPVfjP9N3rijzkoupWCj79M 2CBLwMDzHQ/7tXzdK0Yy61DE02l2GOcz4YyA3SLcwQnnxzG9/BVMU7bTBFxeMzix90Az bitA== MIME-Version: 1.0 X-Received: by 10.58.19.162 with SMTP id g2mr17932113vee.12.1378035454457; Sun, 01 Sep 2013 04:37:34 -0700 (PDT) In-Reply-To: References: Date: Sun, 1 Sep 2013 21:37:34 +1000 Subject: Re: gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow) From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1378035456 news.xs4all.nl 15899 [2001:888:2000:d::a6]:58252 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53413 On Sun, Sep 1, 2013 at 10:03 AM, wrote: > At startup, IPython (qtconsole) calls "socket.gethostbyname_ex(socket.get= hostname())[2]" to find a list of IP addresses that point to the machine. O= n a Linux server that I manage this call is extremely slow (>20s)... which = I have trouble understanding as "ip addr show" seems to give the same infor= mation nearly instantaneously. Is there anything I can do to make this fast= er? Can this be a network configuration issue (I am behind a router)? 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