Best strategy for overcoming excessive gethostbyname timeout.

MrJean1 mrjean1 at gmail.com
Sun Nov 29 23:12:05 EST 2009


Take a look at function timelimited in this recipe

 <http://code.activestate.com/recipes/576780/>

/Jean


On Nov 29, 8:08 am, r0g <aioe.... at technicalbloke.com> wrote:
> r0g wrote:
> > r0g wrote:
> >> Gabriel Genellina wrote:
> >>> En Fri, 27 Nov 2009 22:35:36 -0300, r0g <aioe.... at technicalbloke.com>
> >>> 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( "google.com", 5 )
>
> ""
>
> Phew, that simplifies thing a lot! :)
>
> Roger.




More information about the Python-list mailing list