Add socket.setdefaulttimeout example to Resolver doctest.
authorW. Trevor King <wking@drexel.edu>
Sat, 18 Feb 2012 19:31:42 +0000 (14:31 -0500)
committerW. Trevor King <wking@drexel.edu>
Sat, 18 Feb 2012 19:31:42 +0000 (14:31 -0500)
apachelog/resolve.py

index db17f6bc20459a47a9689b380a2656c4a74eb05a..9d8b66c61830911d2dd8810acfdae672dbd328cb 100644 (file)
@@ -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'