def enable_dns_cache():
 om.out.debug('Enabling _dns_cache()')
 if (not hasattr(socket, 'already_configured')):
  socket._getaddrinfo = socket.getaddrinfo
 _dns_cache = SynchronizedLRUDict(200)
 def _caching_getaddrinfo(*args, **kwargs):
  query = args
  try:
   res = _dns_cache[query]
   return res
  except KeyError:
   res = socket._getaddrinfo(*args, **kwargs)
   _dns_cache[args] = res
   msg = 'DNS response from DNS server for domain: %s'
   om.out.debug((msg % query[0]))
   return res
 if (not hasattr(socket, 'already_configured')):
  socket.getaddrinfo = _caching_getaddrinfo
  socket.already_configured = True

def enable_dns_cache ( ) : om . out . debug ( 'Enabling _dns_cache()' ) if ( not hasattr ( socket , 'already_configured' ) ) : socket . _getaddrinfo = socket . getaddrinfo _dns_cache = SynchronizedLRUDict ( 200 ) def _caching_getaddrinfo ( * args , ** kwargs ) : query = args try : res = _dns_cache [ query ] return res except KeyError : res = socket . _getaddrinfo ( * args , ** kwargs ) _dns_cache [ args ] = res msg = 'DNS response from DNS server for domain: %s' om . out . debug ( ( msg % query [ 0 ] ) ) return res if ( not hasattr ( socket , 'already_configured' ) ) : socket . getaddrinfo = _caching_getaddrinfo socket . already_configured = True
dns cache trick this will speed up all the test! before this dns cache voodoo magic every request to the http server required a dns query .