Viewing File: /opt/alt/python35/lib/python3.5/site-packages/urllib3/util/__pycache__/connection.cpython-35.pyc



R/oV4
ã@s´ddlmZddlZyddlmZmZWnGek
rdZyddlmZWnek
rzdZYnXYnXdd„Zejdddd	„Z	d
d„Z
dS)é)Úabsolute_importN)ÚpollÚPOLLINF)ÚselectcCsÏt|ddƒ}|dkr"dS|dkr2dSts|tsBdSyt|gggdƒdSWntjk
r{dSYnXtƒ}|j|tƒx3|jdƒD]"\}}||jƒkr¥dSq¥WdS)a 
    Returns True if the connection is dropped and should be closed.

    :param conn:
        :class:`httplib.HTTPConnection` object.

    Note: For platforms like AppEngine, this will always return ``False`` to
    let the platform handle connection recycling transparently for us.
    ÚsockFNTgr)ÚgetattrrrÚsocketÚerrorÚregisterrÚfileno)ÚconnrÚpZfnoZev©rú/connection.pyÚis_connection_dropped
s"
		rcCsI|\}}|jdƒr*|jdƒ}d}xñtj||dtjƒD]Ô}|\}}	}
}}d}
yftj||	|
ƒ}
t|
|ƒ|tjk	r®|
j|ƒ|rÁ|
j|ƒ|
j	|ƒ|
SWqLtj
k
r}z'|}|
dk	r
|
jƒd}
WYdd}~XqLXqLW|dk	r6|‚tj
dƒ‚dS)adConnect to *address* and return the socket object.

    Convenience function.  Connect to *address* (a 2-tuple ``(host,
    port)``) and return the socket object.  Passing the optional
    *timeout* parameter will set the timeout on the socket instance
    before attempting to connect.  If no *timeout* is supplied, the
    global default timeout setting returned by :func:`getdefaulttimeout`
    is used.  If *source_address* is set it must be a tuple of (host, port)
    for the socket to bind as a source address before making the connection.
    An host of '' or port 0 tells the OS to use the default.
    ú[z[]Nrz!getaddrinfo returns an empty list)Ú
startswithÚstriprÚgetaddrinfoÚSOCK_STREAMÚ_set_socket_optionsÚ_GLOBAL_DEFAULT_TIMEOUTÚ
settimeoutÚbindÚconnectr	Úclose)ÚaddressÚtimeoutÚsource_addressZsocket_optionsÚhostÚportÚerrÚresÚafÚsocktypeÚprotoÚ	canonnameÚsarÚerrrÚcreate_connection1s0"




r)cCs2|dkrdSx|D]}|j|ŒqWdS)N)Ú
setsockopt)rZoptionsÚoptrrrr`s
r)Z
__future__rrrrrÚImportErrorrrr)rrrrrÚ<module>s

$.
Back to Directory File Manager