Advertisement
Guest User

Untitled

a guest
May 26th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. def getHostByName(self, name, timeout=None):
  2. """Get host by name
  3.  
  4. Args:
  5. name: The name of the host.
  6. timeout: The timeout.
  7.  
  8. Return:
  9. Return host by name.
  10.  
  11. """
  12. if name in dnscache:
  13. return defer.succeed(dnscache[name])
  14. # in Twisted<=16.6, getHostByName() is always called with
  15. # a default timeout of 60s (actually passed as (1, 3, 11, 45) tuple),
  16. # so the input argument above is simply overridden
  17. # to enforce Scrapy's DNS_TIMEOUT setting's value
  18. timeout = (self.timeout,)
  19. d = super(CachingThreadedResolver, self).getHostByName(name, timeout)
  20. if dnscache.limit:
  21. d.addCallback(self._cache_result, name)
  22. return d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement