File: //lib64/python3.6/site-packages/tornado/__pycache__/tcpclient.cpython-36.opt-1.pyc
3
��fz/ � @ s� d Z ddlZddlZddlZddlZddlZddlmZmZ ddl m
Z
ddlmZ ddl
mZ ddlmZ ddlmZ dd lmZ ddlZdd
lmZmZmZmZmZmZmZ ejr�ddlmZmZ dZ G d
d� de!�Z"G dd� de!�Z#dS )z'A non-blocking TCP connection factory.
� N)�Future�future_add_done_callback)�IOLoop)�IOStream)�gen)�Resolver)�set_close_exec)�TimeoutError)�Any�Union�Dict�Tuple�List�Callable�Iterator)�Optional�Setg333333�?c @ sN e Zd ZdZee eejegee df f dd�dd�Z
eee eeeejef eeejef f d�dd ��Ze
dfeeeejf d
d�dd
�Zeeejef dd�dd�Zeeejef ejeddd�dd�Zedd�dd�Zdd�dd�Zdd�dd�Zeeejf dd�dd�Zdd�dd �Zdd�d!d"�Zdd�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
zFuture[IOStream]N)�addrinfo�connect�returnc C sR t j� | _|| _t� | _d | _d | _d | _t |�| _
| j|�\| _| _
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% �!/usr/lib64/python3.6/tcpclient.py�__init__<