mirror of https://github.com/scrapy/scrapy.git
Enforce DNS resolution timeout
This commit is contained in:
parent
4ca191eaf2
commit
d2e9ea0c88
|
|
@ -16,8 +16,11 @@ class CachingThreadedResolver(ThreadedResolver):
|
|||
def getHostByName(self, name, timeout=None):
|
||||
if name in dnscache:
|
||||
return defer.succeed(dnscache[name])
|
||||
if not timeout:
|
||||
timeout = self.timeout
|
||||
# in Twisted<=16.6, getHostByName() is always called with
|
||||
# a default timeout of 60s (actually passed as (1, 3, 11, 45) tuple),
|
||||
# so the input argument above is simply overridden
|
||||
# to enforce Scrapy's DNS_TIMEOUT setting's value
|
||||
timeout = (self.timeout,)
|
||||
d = super(CachingThreadedResolver, self).getHostByName(name, timeout)
|
||||
d.addCallback(self._cache_result, name)
|
||||
return d
|
||||
|
|
|
|||
Loading…
Reference in New Issue