Is it possible to set a timeout on a getaddrinfo() call in CPython 2.7?
socket.setdefaulttimeout() does not work. I don't really want a solution that wraps a function using threads or signals. A solution that only uses the standard library is best, but using a third-party package would be acceptable.
For example, I want to do this:
And have it raise a socket.error in 1 second. (Note that when I run this on OS X it times out rapidly anyway, but running on Debian it takes about 60 seconds to fail).