HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/aiohappyeyeballs/__pycache__/impl.cpython-310.pyc
o

���g�
@s
dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
ddlmZddl
mZddddd�de	ed	ee	ed
eedeedeejd
ejfdd�Z	ddejdeee
eefded	ee	ed
ejf
dd�Z	dde	eded
eefdd�ZdS)zBase implementation.�N)�List�Optional�Sequence�Union�)�
_staggered)�AddrInfoType)�local_addr_infos�happy_eyeballs_delay�
interleave�loop�
addr_infosr	r
rr�returnc
�s��|�s	t���t|�dk}|dur|durd}|r"|s"t||�}d}g�|dus,|rJ|D]}z
t��|��IdH}WnttfyHYq.wnt����fdd�|D�|�IdH\}}}|dur�dd��D�}	z\|	d}
t|	�dkrw|
�t	|
��t
�fdd�|	D��r�|
�d	�d
�dd�|	D���}t
|
t�r�|
j�t
�fdd�|	D��r�t�|��t|��t
|
t�r�t
d
d�|	D��r�t|��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, ...)
    rNc3s"�|]}t�t��|��VqdS�N)�	functools�partial�
_connect_sock)�.0�addrinfo)�current_loop�
exceptionsr	��@/usr/local/lib/python3.10/dist-packages/aiohappyeyeballs/impl.py�	<genexpr>Os��
�
�z#start_connection.<locals>.<genexpr>cSsg|]	}|D]}|�qqSrr)r�sub�excrrr�
<listcomp>Ysz$start_connection.<locals>.<listcomp>rc3s�|]	}t|��kVqdSr��str�rr)�modelrrras�zMultiple exceptions: {}z, css�|]}t|�VqdSrrrrrrrfs�c3s$�|]
}t|t�o
|j�kVqdSr)�
isinstance�OSError�errnor)�first_errnorrrls
��
�css�|]}t|t�VqdSr)r!�RuntimeErrorrrrrrqs�

�)�asyncio�get_running_loop�len�_interleave_addrinfosrr%r"r�staggered_racer�all�format�joinr!r#)r
r	r
rr�single_addr_info�sockr�_�all_exceptions�first_exception�msgr)rrr$r	r r�start_connectionsl�&

�����
�
�
��r4r�	addr_infoc
�s��g}|�|�|\}}}}}	d}
z�zqtj|||d�}
|
�d�|durs|D]>\}}}}}||kr2q&z|
�|�Wn8tyd}
zd|�d|
jpJd����}t|
j|�}
|�|
�WYd}
~
q&d}
~
ww|rk|���td|�d���|�	|
|	�IdH|
WWd}}St
tfy�}
z#|�|
�|
dur�z|
��W�ty�}z|�|��d}~ww�d}
~
w|
dur�z|
��W�ty�}z|�|��d}~ww�d}}w)	z$Create, bind and connect one socket.N)�family�type�protoFz*error while attempting to bind on address z: �z&no matching local address with family=z found)�append�socket�setblocking�bindr"�strerror�lowerr#�pop�sock_connectr%�close)rrr5r	�
my_exceptionsr6�type_r8r0�addressr/�lfamily�laddrrr3�errrr�sr�


�����	
�

�
���
�
��
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)rIrJ�addrinfos_by_family�addrr6�addrinfos_lists�	reorderedrrrr)�s �
�r)r)r)�__doc__r&rLrrQr;�typingrrrrr9r�typesr�float�int�AbstractEventLoopr4r"r%rr)rrrr�<module>s\��
����
�v����
�
�;����