Do not cache DNS responses when cache size is 0

This commit is contained in:
Paul Tremberth 2017-07-04 23:18:15 +02:00
parent 1f08d9a648
commit f0ded6b775
1 changed files with 2 additions and 1 deletions

View File

@ -22,7 +22,8 @@ class CachingThreadedResolver(ThreadedResolver):
# 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)
if dnscache.limit:
d.addCallback(self._cache_result, name)
return d
def _cache_result(self, result, name):