Skip to content

Commit

Permalink
ExceptionCachingResolver: Avoid NoMetaqueries
Browse files Browse the repository at this point in the history
NoMetaqueries do not use sockets, and caching them could
replace other cache entries which are more important.
  • Loading branch information
jayvdb committed Sep 1, 2020
1 parent 002c13e commit 5f571ef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion dns_cache/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from dns.name import from_text
from dns.rdataclass import IN
from dns.rdatatype import A
from dns.resolver import NXDOMAIN, Answer, Resolver
from dns.resolver import NXDOMAIN, Answer, NoMetaqueries, Resolver
from dns.version import MAJOR as _MAJOR, MINOR as _MINOR

import dns_cache.expiration
Expand Down Expand Up @@ -102,6 +102,8 @@ def resolve(self, qname, rdtype=A, rdclass=IN,
qname, rdtype, rdclass, tcp, source,
raise_on_no_answer, source_port, lifetime,
)
except NoMetaqueries:
raise
except DNSException as e:
self._cache_exception(e, qname, rdtype, rdclass)
raise
Expand Down Expand Up @@ -131,6 +133,8 @@ def query(self, qname, rdtype=A, rdclass=IN, **kwargs):
return super(ExceptionCachingResolver, self).query(
qname, rdtype, rdclass, **kwargs
)
except NoMetaqueries:
raise
except DNSException as e:
self._cache_exception(e, qname, rdtype, rdclass)
raise
Expand Down

0 comments on commit 5f571ef

Please sign in to comment.