U mf @sUddlmZddlZddlmZmZmZmZda iZ ee efe d<dZ GdddejjZe edd d Ze d d d Zed ddZe edddZdS))DictN)BackendDatagramSocketSocket StreamSocket _backendsFc@s eZdZdS)AsyncLibraryNotFoundErrorN)__name__ __module__ __qualname__r r >/opt/hc_python/lib/python3.8/site-packages/dns/asyncbackend.pyrsr)namereturncCsdt|}|r|S|dkr.ddl}|j}n*|dkrJddl}|j}ntd||t|<|S)zGet the specified asynchronous backend. *name*, a ``str``, the name of the backend. Currently the "trio" and "asyncio" backends are available. Raises NotImplementedError if an unknown backend name is specified. ZtriorNasynciozunimplemented async backend )rgetZdns._trio_backendZ _trio_backendrZdns._asyncio_backendZ_asyncio_backendNotImplementedError)rbackenddnsr r r get_backends   r)rc Csz@tr tddl}z |WWS|jk r<tdYnXWnJtk rddl}z|WYdStk rtdYnXYnXdS)zAttempt 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. rNz&sniffio cannot determine async libraryrzno async library detected) _no_sniffio ImportErrorsniffioZcurrent_async_libraryrrZget_running_loop RuntimeError)rrr r r sniff7s rcCstrtSttS)z6Get the default backend, initializing it if necessary.)_default_backendset_default_backendrr r r r get_default_backendRsrcCs t|atS)a,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. )rr)rr r r rZs r)typingrZ dns.exceptionrZdns._asyncbackendrrrrrrstr__annotations__r exceptionZ DNSExceptionrrrrrr r r r s