Current File : //lib/python2.7/site-packages/urllib3/util/connection.pyo
�
_X�Tc@s�ddlZyddlmZmZWnEek
rmeZyddlmZWqnek
rieZqnXnXd�Zejddd�Z	d�Z
dS(i����N(tpolltPOLLIN(tselectcCs�t|dt�}|tkr"tS|dkr2tSts{tsBtSyt|gggd�dSWq{tjk
rwtSXnt�}|j|t	�x3|jd�D]"\}}||j
�kr�tSq�WdS(s 
    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.
    tsockgiN(tgetattrtFalsetNonetTrueRRtsocketterrortregisterRtfileno(tconnRtptfnotev((s;/usr/lib/python2.7/site-packages/urllib3/util/connection.pytis_connection_droppeds"
	cCs%|\}}d}x�tj||dtj�D]�}|\}}	}
}}d}
yltj||	|
�}
t|
|�|tjk	r�|
j|�n|r�|
j|�n|
j|�|
SWq.tj	k
r�}|}|
dk	r�|
j
�d}
q�q.Xq.W|dk	r|�ntj	d��dS(sdConnect 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.
    is!getaddrinfo returns an empty listN(RRtgetaddrinfotSOCK_STREAMt_set_socket_optionst_GLOBAL_DEFAULT_TIMEOUTt
settimeouttbindtconnectR	tclose(taddressttimeouttsource_addresstsocket_optionsthosttportterrtrestaftsocktypetprotot	canonnametsaRt_((s;/usr/lib/python2.7/site-packages/urllib3/util/connection.pytcreate_connection0s,"


	cCs2|dkrdSx|D]}|j|�qWdS(N(Rt
setsockopt(Rtoptionstopt((s;/usr/lib/python2.7/site-packages/urllib3/util/connection.pyR]s
(RRRRtImportErrorRRRRR'R(((s;/usr/lib/python2.7/site-packages/urllib3/util/connection.pyt<module>s

	$,