Best strategy for overcoming excessive gethostbyname timeout.

J Sisson sisson.j at
Sat Nov 28 05:05:30 CET 2009

On Fri, Nov 27, 2009 at 9:20 PM, r0g < at> wrote:

> Ahh so close. I set the alarm for 3 seconds and it raises the exception,
> but only after spending 25 seconds seemingly blocked in gethostbyname.
> Here's a snippet, just in case I'm doing it wrong!...
If you're doing many lookups prior to connecting to the machines or
otherwise processing the information, you can create a very simple thread
class to perform just the lookup, store the threads in a list, and poll the
threads in the list so you can deal with the ones that finish first before
moving on to the remaining ones.  You'll still have a 25 second wait for the
last ones to finish, but you can get the majority of the work done earlier
than you would with a single-thread program.

Computers are like air conditioners...
They quit working when you open Windows.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list