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).
On Saturday, August 31, 2013 6:01:00 PM UTC-7, Roy Smith wrote: > In article <b9f77b6f-3a65-407a-aff5-5677be2ba...@googlegroups.com>, > > anntzer....@gmail.com wrote: > > > > > Hi, > > > > > > At startup, IPython (qtconsole) calls > > > "socket.gethostbyname_ex(socket.gethostname())[2]" to find a list of IP > > > addresses that point to the machine. On 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 information nearly instantaneously. Is > > > there anything I can do to make this faster? Can this be a network > > > configuration issue (I am behind a router)? > > > > It's almost certainly some sort of configuration issue which is causing > > some DNS query to timeout. The first step, is to figure out which part > > is taking so long. Open up a python shell and run: > > > > >>> 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), try > > > > >>> socket.gethostbyname_ex(name) > > > > and see how long that takes and what it returns. At least at that point > > you'll have cut the problem in half. > > > > If I had to guess, you've got a missing PTR record, because that's what > > most people screw up. -- http://mail.python.org/mailman/listinfo/python-list