HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/aiohappyeyeballs/__pycache__/impl.cpython-310.pyc
o

;j�%�@s>dZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZddl
mZddlmZmZdddddd�de
ed	e	e
ed
e	ede	ede	ejd
e	edejfdd�Z			ddejdeeeeefded	e	e
ede	eejd
e	edejfdd�Z	dde
ededeefdd�ZdS)zBase implementation.�N)�List�Optional�Sequence�Set�Union�)�
_staggered)�AddrInfoType�SocketFactoryType)�local_addr_infos�happy_eyeballs_delay�
interleave�loop�socket_factory�
addr_infosrrr
rr�returnc�sL�|�s	t���t|�dk}|dur|durd}|r"|s"t||�}d}g�|dus,|rL|D]}zt��|�d��IdH}WnttfyJYq.wnft��z=t�	�����fdd�|D�|�IdH\}}	}	W�D]}
|
|ur�t
�t��|
��Wd�n1s�wYqjd�n%�D]}
|
|ur�t
�t��|
��Wd�n1s�wYq�d�w|du�r$dd��D�}z`|d}t|�dkr�|�t
|��t�fdd�|D��r�|�d	�d
�dd�|D���}
t|t��r|j�t�fdd�|D���rt�|
��t|
��t|t��rtd
d�|D���rt|
��t|
��d}d�w|S)aM
    Connect to a TCP server.

    Create a socket connection to a specified destination.  The
    destination is specified as a list of AddrInfoType tuples as
    returned from getaddrinfo().

    The arguments are, in order:

    * ``family``: the address family, e.g. ``socket.AF_INET`` or
        ``socket.AF_INET6``.
    * ``type``: the socket type, e.g. ``socket.SOCK_STREAM`` or
        ``socket.SOCK_DGRAM``.
    * ``proto``: the protocol, e.g. ``socket.IPPROTO_TCP`` or
        ``socket.IPPROTO_UDP``.
    * ``canonname``: the canonical name of the address, e.g.
        ``"www.python.org"``.
    * ``sockaddr``: the socket address

    This method is a coroutine which will try to establish the connection
    in the background. When successful, the coroutine returns a
    socket.

    The expected use case is to use this method in conjunction with
    loop.create_connection() to establish a connection to a server::

            socket = await start_connection(addr_infos)
            transport, protocol = await loop.create_connection(
                MyProtocol, sock=socket, ...)
    rNc
3s&�|]}t�t��|����VqdS�N)�	functools�partial�
_connect_sock)�.0�addrinfo)�current_loop�
exceptionsr�open_socketsr��I/opt/saltstack/salt/lib/python3.10/site-packages/aiohappyeyeballs/impl.py�	<genexpr>Xs�
��
�z#start_connection.<locals>.<genexpr>cSsg|]	}|D]}|�qqSrr)r�sub�excrrr�
<listcomp>vsz$start_connection.<locals>.<listcomp>rc3s�|]	}t|��kVqdSr��str�rr)�modelrrr~s�zMultiple exceptions: {}z, css�|]}t|�VqdSrr!r#rrrr�s�c3s$�|]
}t|t�o
|j�kVqdSr)�
isinstance�OSError�errnor#)�first_errnorrr�s
��
�css�|]}t|t�VqdSr)r%�RuntimeErrorr#rrrr�s�

�)�asyncioZget_running_loop�len�_interleave_addrinfosrr)r&�setrZstaggered_race�
contextlib�suppress�closer"�all�format�joinr%r')rrrr
rrZsingle_addr_info�sockr�_�sZall_exceptionsZfirst_exception�msgr)rrr(rr$rrr�start_connections��'

���
��
���
��
�
�
�
�r8r�	addr_inforc
�s��g}|�|�|\}}}	}
}d}z�z�|dur||�}ntj|||	d�}|dur-|�|�|�d�|dur�|D]>\}
}
}
}
}|
|krDq8z|�|�Wn8tyv}zd|�d|jp\d����}t|j|�}|�|�WYd}~q8d}~ww|r}|�	��td|�d���|�
||�IdH|WWd}}Sttfy�}z,|�|�|dur�|dur�|�|�z|�
�W�ty�}z|�|��d}~ww�d}~w|dur�|dur�|�|�z|�
�W�ty�}z|�|��d}~ww�d}}w)	aq
    Create, bind and connect one socket.

    If open_sockets is passed, add the socket to the set of open sockets.
    Any failure caught here will remove the socket from the set and close it.

    Callers can use this set to close any sockets that are not the winner
    of all staggered tasks in the result there are runner up sockets aka
    multiple winners.
    N)�family�type�protoFz*error while attempting to bind on address z: �z&no matching local address with family=z found)�append�socket�add�setblocking�bindr&�strerror�lowerr'�popZsock_connectr)�remover0)rrr9rrrZ
my_exceptionsr:�type_r<r5�addressr4Zlfamily�laddrrr7�errrr�s��




�����	
�


�
���

�
��
r�	addrinfos�first_address_family_countcCs�t��}|D]}|d}||vrg||<||�|�qt|���}g}|dkr>|�|dd|d��|dd|d�=|�dd�tj�tj	|��D��|S)z-Interleave list of addrinfo tuples by family.rrNcss�|]	}|dur|VqdSrr)r�arrrr�s���z(_interleave_addrinfos.<locals>.<genexpr>)
�collections�OrderedDictr>�list�values�extend�	itertools�chain�
from_iterable�zip_longest)rKrLZaddrinfos_by_family�addrr:Zaddrinfos_listsZ	reorderedrrrr,�s �
�r,)NNN)r)�__doc__r*rNr.rrSr?�typingrrrrrr=r�typesr	r
�float�intZAbstractEventLoopr8r&r)rr,rrrr�<module>sr��
�����
�����
���
�O����