This may not be possible if Python uses the gethostbyname() . I'm not sure if you really want this because you can get false timeouts.
As soon as I had a similar problem, but from C ++: I had to call a function for a large number of names, so a long timeout was a real pain. The solution was to call it from many threads in parallel, so although some of them were stuck waiting for a timeout, all the others went fine.
source share