gevent.resolver.dnspython
– Pure Python hostname resolver¶
- class Resolver(hub=None)[source]¶
Bases:
AbstractResolver
An experimental resolver that uses dnspython.
This is typically slower than the default threaded resolver (unless there’s a cache hit, in which case it can be much faster). It is usually much faster than the c-ares resolver. It tends to scale well as more concurrent resolutions are attempted.
Under Python 2, if the
idna
package is installed, this resolver can resolve Unicode host names that the system resolver cannot.Note
This does not use dnspython’s default resolver object, or share any classes with
import dns
. A separate copy of the objects is imported to be able to function in a non monkey-patched process. The documentation for the resolver object still applies.The resolver that we use is available as the
resolver
attribute of this object (typicallygevent.get_hub().resolver.resolver
).Caution
Many of the same caveats about DNS results apply here as are documented for
gevent.resolver.ares.Resolver
. In addition, the handling of symbolic scope IDs in IPv6 addresses passed togetaddrinfo
exhibits some differences.On PyPy,
getnameinfo
can produce results when CPython raisessocket.error
, and gevent’s DNSPython resolver also raisessocket.error
.Caution
This resolver is experimental. It may be removed or modified in the future. As always, feedback is welcome.
Added in version 1.3a2.
Changed in version 20.5.0: The errors raised are now much more consistent with those raised by the standard library resolvers.
Handling of localhost and broadcast names is now more consistent.
- close()[source]¶
Release resources held by this object.
Subclasses that define resources should override.
Added in version 22.10.1.
- property resolver¶
The dnspython resolver object we use.
This object has several useful attributes that can be used to adjust the behaviour of the DNS system:
cache
is adns.resolver.LRUCache
. Its maximum size can be configured by callingresolver.cache.set_max_size()
nameservers
controls which nameservers to talk tolifetime
configures a timeout for each individual query.