Best strategy for overcoming excessive gethostbyname timeout.

r0g at
Sun Nov 29 17:08:24 CET 2009

r0g wrote:
> r0g wrote:
>> Gabriel Genellina wrote:
>>> En Fri, 27 Nov 2009 22:35:36 -0300, r0g < at>
>>> escribió:
>>>> gethostbyname ignores setdefaulttimeout.
>>>> How big a job is it to use non-blocking sockets to write a DNS lookup
>>>> function with a customisable timeout? A few lines? A few hundred? I'd
> <snip>
> As usual, everything is working beautifully until I try to make it work
> with windows!
> Turns out signals.SIGALRM is Unix only and I want to run on both
> platforms so I have done as the docs suggested and tried to convert the
> code to use threading.Timer to trigger an exception if the DNS lookup is
> taking too long.

Actually none of that was necessary in the end. Digging into the pydns
source to debug the 30 second pause I happened across the timeout parameter!

>>> result = ping.do_one( "", 5 )

Phew, that simplifies thing a lot! :)


More information about the Python-list mailing list