From fa1898bc8b9bb5bcfed0ede086455c2089b5357a Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 18 Feb 2012 14:31:42 -0500 Subject: [PATCH] Add socket.setdefaulttimeout example to Resolver doctest. --- apachelog/resolve.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apachelog/resolve.py b/apachelog/resolve.py index db17f6b..9d8b66c 100644 --- a/apachelog/resolve.py +++ b/apachelog/resolve.py @@ -8,6 +8,12 @@ class Resolver (object): Maintains a class-level cache of resolved IPs to avoid repeated lookups on the same IP address. + Avoid hanging if we can't resolve a name. + + >>> import socket + >>> if hasattr(_socket, 'setdefaulttimeout'): + >>> socket.setdefaulttimeout(5) # set 5 second timeout + >>> r = Resolver() >>> r.resolve('198.41.0.4') 'a.root-servers.net' -- 2.26.2