I noticed some curious behavior with python's socket.getaddrinfo()
.
If I am connected to wifi and call socket.getaddrinfo(), it works (of course it does!):
In [3]: socket.getaddrinfo('charlesleifer.com', 80)
Out[3]:
[...]
If I disconnect, then I will receive an error:
In [4]: socket.getaddrinfo('charlesleifer.com', 80)
---------------------------------------------------------
gaierror Traceback (most
<ipython-input-2-d333ec6c75af> in <module>()
----> 1 socket.getaddrinfo('charlesleifer.com', 80)
Finally, if I reconnect, it will work again.
Now here is the weird part.
If I start by turning off my wifi, open a python terminal, and call socket.getaddrinfo, as expected I will receive the same error as before
In [2]: socket.getaddrinfo('charlesleifer.com', 80)
---------------------------------------------------------
gaierror Traceback (most
<ipython-input-2-d333ec6c75af> in <module>()
----> 1 socket.getaddrinfo('charlesleifer.com', 80)
gaierror: [Errno -2] Name or service not known
But when I turn my wifi on, no matter how many times I try I will continue to receive this same error! I can try other hosts and it will also fail.
If I manually add an entry to my /etc/hosts
file, then it will return whatever I put in the hosts file. Other requests continue to fail, though.
What's going on here? I'm stumped.