gevent.resolver.dnspython – Pure Python hostname resolver

class Resolver(hub=None)[source]

Bases: gevent.resolver.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.


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 (typically gevent.get_hub().resolver.resolver).


Many of the same caveats about DNS results apply here as are documented for gevent.resolver.ares.Resolver.


This resolver is experimental. It may be removed or modified in the future. As always, feedback is welcome.

New in version 1.3a2.


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 a dns.resolver.LRUCache. Its maximum size can be configured by calling resolver.cache.set_max_size()

  • nameservers controls which nameservers to talk to

  • lifetime configures a timeout for each individual query.

Next page: gevent.resolver.blocking – Non-cooperative resolver