On Sun, Sep 1, 2013 at 10:03 AM,  <anntzer....@gmail.com> wrote:
> 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)?

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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to