File: //usr/local/CyberCP/lib/python3.10/site-packages/tornado/__pycache__/tcpclient.cpython-310.pyc
o
�hx/ � @ s� d Z ddlZddlZddlZddlZddlZddlZddlmZm Z ddl
mZ ddlm
Z
ddlmZ ddlmZ ddlmZ dd lmZmZmZmZmZmZmZmZ ejr]dd
lmZ dZG dd
� d
e�Z G dd� de�Z!dS )z'A non-blocking TCP connection factory.
� N)�Future�future_add_done_callback)�IOLoop)�IOStream)�gen)�Resolver)�TimeoutError)�Any�Union�Dict�Tuple�List�Callable�Iterator�Optional)�Setg333333�?c
@ sV e Zd ZdZdee deejegee df f ddfdd�Z
edee deeeejef eeejef f fd d
��Ze
dfdedeeeejf dd
fdd�Zdeeejef ddfdd�Zdeeejef dejdeddddf
dd�Zdeddfdd�Zd&dd�Zd&dd�Zdeeejf ddfdd�Zd&d d!�Zd&d"d#�Zd&d$d%�ZdS )'�
_Connectora� A stateless implementation of the "Happy Eyeballs" algorithm.
"Happy Eyeballs" is documented in RFC6555 as the recommended practice
for when both IPv4 and IPv6 addresses are available.
In this implementation, we partition the addresses by family, and
make the first connection attempt to whichever address was
returned first by ``getaddrinfo``. If that connection fails or
times out, we begin a connection in parallel to the first address
of the other family. If there are additional failures we retry
with other addresses, keeping one connection attempt per family
in flight at a time.
http://tools.ietf.org/html/rfc6555
�addrinfo�connect�Future[IOStream]�returnNc C sR t �� | _|| _t� | _d | _d | _d | _t |�| _
| �|�\| _| _
t� | _d S �N)r �current�io_loopr r �future�timeout�connect_timeout�
last_error�len� remaining�split�
primary_addrs�secondary_addrs�set�streams)�selfr r � r&