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)?
This issue is independent of IPython:
$ time python -c 'import socket; print(socket.gethostbyname_ex(socket.gethostname())[2])'
['192.168.0.102']
python -c 0.07s user 0.02s system 0% cpu 28.190 total
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…