timeout in socket.gethostbyname()?

Fortepianissimo fortepianissimo at yahoo.com.tw
Sun Dec 7 20:42:00 EST 2003


Ok so for now I use a separate thread to run gethostbyname, and stop
waiting for the result if time is running up. But would be interested
in knowing a simpler way doing this. Thanks!

fortepianissimo at yahoo.com.tw (Fortepianissimo) wrote in message news:<ef08387c.0312071133.56db2a88 at posting.google.com>...
> I've tried using
> 
> socket.setdefaulttimeout(timeout)
> 
> to set the default timeout to 'timeout' for all sockets. The part
> that's not clear to me, is that if this will affect
> socket.gethostbyname(). In my observation the timeout setting did not
> affect the DNS lookup.
> 
> It might be my misunderstanding of the semantics here: would
> setdefaulttimeout() only applies to any socket object newly created?
> So gethostbyname() doesn't create a new socket (explicitly at least)
> so timeout doesn't apply there? What should I do to get the intended
> behavior?
> 
> Thanks a bunch!




More information about the Python-list mailing list