Skip to content

Commit

Permalink
Enforce DNS resolution timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
redapple committed Jan 31, 2017
1 parent 4ca191e commit d2e9ea0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scrapy/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ def __init__(self, reactor, cache_size, timeout):
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
Expand Down

0 comments on commit d2e9ea0

Please sign in to comment.