o
    Þý°jì
  ã                   @   s¢   U d dl mZ d dlZd dlmZmZmZmZ da	i Z
eeef ed< dZG dd„ dejjƒZded	efd
d„Zd	efdd„Zd	efdd„Zded	efdd„ZdS )é    )ÚDictN)ÚBackendÚDatagramSocketÚSocketÚStreamSocketÚ	_backendsFc                   @   s   e Zd ZdS )ÚAsyncLibraryNotFoundErrorN)Ú__name__Ú
__module__Ú__qualname__© r   r   úƒ/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/dns/asyncbackend.pyr      s    r   ÚnameÚreturnc                 C   sd   t  | ¡}|r	|S | dkrddl}|j ¡ }n| dkr%ddl}|j ¡ }ntd| › �ƒ‚|t | < |S )zæGet 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.
    Útrior   NÚasynciozunimplemented async backend )r   ÚgetÚdns._trio_backendÚ_trio_backendr   Údns._asyncio_backendÚ_asyncio_backendÚNotImplementedError)r   ÚbackendÚdnsr   r   r   Úget_backend   s   
	r   c                  C   sv   zt rt‚ddl} z|  ¡ W W S  | jy   tdƒ‚w  ty:   ddl}z| ¡  W Y dS  ty9   tdƒ‚w w )zè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.
    r   Nz&sniffio cannot determine async libraryr   zno async library detected)Ú_no_sniffioÚImportErrorÚsniffioÚcurrent_async_libraryr   r   Úget_running_loopÚRuntimeError)r   r   r   r   r   Úsniff7   s$   ÿÿúr!   c                   C   s   t rt S ttƒ ƒS )z6Get the default backend, initializing it if necessary.)Ú_default_backendÚset_default_backendr!   r   r   r   r   Úget_default_backendR   s   
r$   c                 C   s   t | ƒatS )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.
    )r   r"   )r   r   r   r   r#   Z   s   
r#   )Útypingr   Údns.exceptionr   Údns._asyncbackendr   r   r   r   r"   r   ÚstrÚ__annotations__r   Ú	exceptionÚDNSExceptionr   r   r!   r$   r#   r   r   r   r   Ú<module>   s   	