a
    sd_T  ã                   @   sd   d dl Zd dlmZmZmZmZ dai ZdZ	G dd„ dej
jƒZdd„ Zdd	„ Zd
d„ Zdd„ ZdS )é    N)ÚSocketÚDatagramSocketÚStreamSocketÚBackendFc                   @   s   e Zd ZdS )ÚAsyncLibraryNotFoundErrorN)Ú__name__Ú
__module__Ú__qualname__© r
   r
   ú2/usr/lib/python3/dist-packages/dns/asyncbackend.pyr      s   r   c                 C   s€   t  | ¡}|r|S | dkr.ddl}|j ¡ }nF| dkrJddl}|j ¡ }n*| dkrfddl}|j ¡ }nt	d| › ƒ‚|t | < |S )zíGet the specified asychronous backend.

    *name*, a ``str``, the name of the backend.  Currently the "trio",
    "curio", and "asyncio" backends are available.

    Raises NotImplementError if an unknown backend name is specified.
    Ztrior   NZcurioÚasynciozunimplemented async backend )
Ú	_backendsÚgetZdns._trio_backendZ_trio_backendr   Zdns._curio_backendZ_curio_backendZdns._asyncio_backendZ_asyncio_backendÚNotImplementedError)ÚnameZbackendÚdnsr
   r
   r   Úget_backend   s    
r   c                  C   s°   z>t r
t‚ddl} z|  ¡ W W S  | jy:   tdƒ‚Y n0 W nl tyª   ddl}z| ¡  W Y dS  ty~   tdƒ‚Y n( ty¤   |j	 
¡ sœtdƒ‚Y Y dS 0 Y n0 dS )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ÚsniffioZcurrent_async_libraryr   r   Zget_running_loopÚRuntimeErrorÚAttributeErrorZTaskZcurrent_task)r   r   r
   r
   r   Úsniff.   s&    
r   c                   C   s   t rt S ttƒ ƒS )z;Get the default backend, initializing it if necessary.
    )Ú_default_backendÚset_default_backendr   r
   r
   r
   r   Úget_default_backendL   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   U   s    
r   )Zdns.exceptionr   Zdns._asyncbackendr   r   r   r   r   r   r   Z	exceptionZDNSExceptionr   r   r   r   r   r
   r
   r
   r   Ú<module>   s   	