module:: dns.asyncbackend .. _async-backend:

Asynchronous Backend Functions

Dnspython has “backends” for Trio and asyncio which implement the library-specific functionality needed by the generic asynchronous DNS code.

Dnspython attempts to determine which backend is in use by “sniffing” for it with the sniffio module if it is installed. If sniffio is not available, dnspython will try to detect asyncio directly.

class dns.asyncbackend.Backend[source]
class dns.asyncbackend.DatagramSocket(family: int, type: int)[source]
class dns.asyncbackend.StreamSocket(family: int, type: int)[source]
dns.asyncbackend.get_default_backend() Backend[source]

Get the default backend, initializing it if necessary.

dns.asyncbackend.set_default_backend(name: str) Backend[source]

Set the default backend.

It’s not normally necessary to call this method, as get_default_backend() will initialize the backend appropriately in many cases. If sniffio is not installed, or in testing situations, this function allows the backend to be set explicitly.

dns.asyncbackend.sniff() str[source]

Attempt to determine the in-use asynchronous I/O library by using the sniffio module if it is available.

Returns the name of the library, or raises AsyncLibraryNotFoundError if the library cannot be determined.

dns.asyncbackend.get_backend(name: str) Backend[source]

Get the specified asynchronous backend.

Parameters:

name (str) – The name of the backend. Currently "trio" and "asyncio" are available.

Raises:

NotImplementedError – If an unknown backend name is specified.