gethostbyname_ex(hostname) extremely slow (crossposted from stackoverflow)

anntzer.lee at gmail.com anntzer.lee at gmail.com
Sun Sep 1 13:13:36 EDT 2013


On Saturday, August 31, 2013 10:06:43 PM UTC-7, Michael Torrie wrote:
> On 08/31/2013 10:51 PM, anntzer.lee at gmail.com wrote:
> 
> > It is the call to gethostbyname_ex that is very slow.  The call to
> > gethostname is quick (and returns the same string as
> > /usr/bin/hostname).
> 
> What gethostbyname_ex and /usr/bin/hostname do are very different
> things.  gethostbyname_ex does a DNS lookup against a server.
> /usr/bin/hostname just checks a local computer setting.  I don't see why
> you are comparing the two.  /usr/bin/hostname is not going to help you
> find a list of IP addresses that point to a machine.

I was just replying to the previous comment "name = socket.gethostname() see how long that takes and what it returns.  Then, assuming it returns a string containing your hostname (massive handwave about what that actually means)", saying that gethostname resolves my own hostname instantaneously.



More information about the Python-list mailing list