AlkantarClanX12

Your IP : 18.217.246.148


Current Path : /proc/thread-self/root/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/
Upload File :
Current File : //proc/thread-self/root/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyo

�
��abc@sddlZddlZddlZddlZddlZddlZddlmZmZy
ej	Z	Wn e
efk
r�ejZ	nXd#Zd$Z
eZe�Zdadefd��YZd�Zejd%kr�d
�Zn	d�Zedd
dddg�Zdefd��YZdefd��YZeed�radefd��YZneed�r�defd��YZneed�r�defd��YZneed�r�defd ��YZ need�s�e!Znd!�Z"d"�Z#dS(&i����N(t
namedtupletMappingiit
SelectorErrorcBs#eZd�Zd�Zd�ZRS(cCs tt|�j�||_dS(N(tsuperRt__init__terrno(tselfterrcode((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRscCsdj|j�S(Ns<SelectorError errno={0}>(tformatR(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__repr__"scCs
|j�S(N(R	(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__str__%s(t__name__t
__module__RR	R
(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRs		cCs�t|t�r|}nHyt|j��}Wn/tttfk
r_tdj|���nX|dkr�tdj|���n|S(sl Return a file descriptor from a file object. If
    given an integer will simply return that integer back. sInvalid file object: {0!r}isInvalid file descriptor: {0}(t
isinstancetinttfilenotAttributeErrort	TypeErrort
ValueErrorR(tfileobjtfd((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt_fileobj_to_fd)s	iicOsdy|||�SWnLtttjfk
r_}d}t|d�rP|j}nt|��nXdS(s� This is the short-circuit version of the below logic
        because in Python 3.5+ all system calls automatically restart
        and recalculate their timeouts. RN(tOSErrortIOErrortselectterrortNonethasattrRR(tfunct_targstkwargsteR((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt_syscall_wrapper;scOs�|jdd�}|dkr-d}t}n.t|�}|dkrNd}n
t�|}t|�}|r�d|kr�td��nt}x5|tkr�y|||�}Wq�tt	t
jfk
r�}d}t|d�r�|j
}nt|d�r|jd}n|t
jkp8tt
d�o8|t
jk}	|	r�|dk	r�t�}
|
|krwtdt
j��n|r�d|kr�||
|d<q�q�q�q�n|r�t|��q��q�Xq�W|S(	s� Wrapper function for syscalls that could fail due to EINTR.
        All functions should be retried if there is time left in the timeout
        in accordance with PEP 475. ttimeoutgs4Timeout must be in args or kwargs to be recalculatedRRitWSAEINTRN(tgetRtFalsetfloatt	monotonictlistRt_SYSCALL_SENTINELRRRRRRRtEINTRR#t	ETIMEDOUTR(Rtrecalc_timeoutRRR"texpirestresultR Rtis_interrupttcurrent_time((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR!GsJ		
	tSelectorKeyRRteventstdatat_SelectorMappingcBs2eZdZd�Zd�Zd�Zd�ZRS(s* Mapping of file objects to selector keys cCs
||_dS(N(t	_selector(Rtselector((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCst|jj�S(N(tlenR5t
_fd_to_key(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__len__�scCsQy$|jj|�}|jj|SWn&tk
rLtdj|���nXdS(Ns{0!r} is not registered.(R5t_fileobj_lookupR8tKeyErrorR(RRR((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__getitem__�s

cCst|jj�S(N(titerR5R8(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__iter__�s(RRt__doc__RR9R<R>(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR4�s
			tBaseSelectorcBs�eZdZd�Zd�Zd
d�Zd�Zd
d�Zd
d�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�ZRS(s/ Abstract Selector class

    A selector supports registering file objects to be monitored
    for specific I/O events.

    A file object is a file descriptor or any object with a
    `fileno()` method. An arbitrary object can be attached to the
    file object which can be used for example to store context info,
    a callback, etc.

    A selector can use various implementations (select(), poll(), epoll(),
    and kqueue()) depending on the platform. The 'DefaultSelector' class uses
    the most efficient implementation for the current platform.
    cCsi|_t|�|_dS(N(R8R4t_map(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�s	cCsYyt|�SWnDtk
rTx-|jj�D]}|j|kr.|jSq.W�nXdS(sa Return a file descriptor from a file object.
        This wraps _fileobj_to_fd() to do an exhaustive
        search in case the object is invalid but we still
        have it in our map. Used by unregister() so we can
        unregister an object that was previously registered
        even if it is closed. It is also used by _SelectorMapping
        N(RRR8tvaluesRR(RRtkey((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR:�s
cCs�|s|ttB@r.tdj|���nt||j|�||�}|j|jkr|tdj||j���n||j|j<|S(s8 Register a file object for a set of events to monitor. sInvalid events: {0!r}s${0!r} (FD {1}) is already registered(	t
EVENT_READtEVENT_WRITERRR1R:RR8R;(RRR2R3RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pytregister�s	cCs�y|jj|j|��}Wn�tk
rGtdj|���n�tjk
r�}|jtjkrq�q�xV|jj	�D],}|j
|kr�|jj|j�Pq�q�Wtdj|���nX|S(s0 Unregister a file object from being monitored. s{0!r} is not registered(R8tpopR:R;RtsocketRRtEBADFRBRR(RRRCR ((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt
unregister�s
cCs�y|j|j|�}Wn&tk
rBtdj|���nX||jkrw|j|�|j|||�}n4||jkr�|jd|�}||j|j	<n|S(s< Change a registered file object monitored events and data. s{0!r} is not registeredR3(
R8R:R;RR2RJRFR3t_replaceR(RRR2R3RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pytmodify�s

cCs
t��dS(sj Perform the actual selection until some monitored file objects
        are ready or the timeout expires. N(tNotImplementedError(RR"((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCs|jj�d|_dS(sd Close the selector. This must be called to ensure that all
        underlying resources are freed. N(R8tclearRRA(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pytclose�s
cCs`|j�}|dkr'td��ny||SWn&tk
r[tdj|���nXdS(s: Return the key associated with a registered file object. sSelector is closeds{0!r} is not registeredN(tget_mapRtRuntimeErrorR;R(RRtmapping((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pytget_keys
cCs|jS(s3 Return a mapping of file objects to selector keys (RA(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRP
scCs(y|j|SWntk
r#dSXdS(s_ Return the key associated to a given file descriptor
         Return None if it is not found. N(R8R;R(RR((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt_key_from_fds
cCs|S(N((R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt	__enter__scGs|j�dS(N(RO(RR((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt__exit__sN(RRR?RR:RRFRJRLRRORSRPRTRURV(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR@�s					
			RtSelectSelectorcBsDeZdZd�Zdd�Zd�Zdd�Zdd�ZRS(s Select-based selector. cCs/tt|�j�t�|_t�|_dS(N(RRWRtsett_readerst_writers(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR!scCsbtt|�j|||�}|t@r>|jj|j�n|t@r^|jj|j�n|S(N(	RRWRFRDRYtaddRRERZ(RRR2R3RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRF&s

cCsBtt|�j|�}|jj|j�|jj|j�|S(N(RRWRJRYtdiscardRRZ(RRRC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRJ.scCstj||g|�S(s? Wrapper for select.select because timeout is a positional arg (R(RtrtwR"((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt_select4sc	Cst|j�r$t|j�r$gS|dkr6dnt|d�}g}t|jt|j|j|�\}}}t|�}t|�}x|||BD]p}d}||kr�|t	O}n||kr�|t
O}n|j|�}|r�|j|||j
@f�q�q�W|S(Ngi(R7RYRZRtmaxR!R_tTrueRXRDRERTtappendR2(	RR"treadyR]R^RRR2RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR8s$ !

!N(	RRR?RRRFRJR_R(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRWs		tpolltPollSelectorcBsDeZdZd�Zdd�Zd�Zdd�Zdd�ZRS(s Poll-based selector cCs&tt|�j�tj�|_dS(N(RReRRRdt_poll(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRSscCsrtt|�j|||�}d}|t@r>|tjO}n|t@rX|tjO}n|jj|j	|�|S(Ni(
RReRFRDRtPOLLINREtPOLLOUTRfR(RRR2R3RCt
event_mask((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRFWs

cCs/tt|�j|�}|jj|j�|S(N(RReRJRfR(RRRC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRJascCsM|dk	r7|dkr!d}q7tj|d�}n|jj|�}|S(sj Wrapper function for select.poll.poll() so that
            _syscall_wrapper can work with only seconds. ig@�@N(RtmathtceilRfRd(RR"R.((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt
_wrap_pollfs	cCs�g}t|jtd|�}x�|D]z\}}d}|tj@rR|tO}n|tj@rm|tO}n|j|�}|r%|j	|||j
@f�q%q%W|S(NR"i(R!RlRaRRgRERhRDRTRbR2(RR"Rct	fd_eventsRRiR2RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRts

!N(	RRR?RRRFRJRlR(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyReQs	
	tepollt
EpollSelectorcBsJeZdZd�Zd�Zdd�Zd�Zdd�Zd�Z	RS(s Epoll-based selector cCs&tt|�j�tj�|_dS(N(RRoRRRnt_epoll(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCs
|jj�S(N(RpR(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCsxtt|�j|||�}d}|t@r>|tjO}n|t@rX|tjO}nt|j	jt
|j|�|S(Ni(RRoRFRDRtEPOLLINREtEPOLLOUTR!RpR%R(RRR2R3RCtevents_mask((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRF�s

cCsMtt|�j|�}yt|jjt|j�Wntk
rHnX|S(N(RRoRJR!RpR%RR(RRRC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRJ�s
c	Cs|dk	rG|dkr!d}ntj|d�d}t|�}nd}tt|j�d�}g}t|jj	t
d|d|�}x�|D]z\}}d}|tj@r�|t
O}n|tj@r�|tO}n|j|�}|r�|j|||j@f�q�q�W|S(	Nigg@�@g����MbP?g�iR"t	maxevents(RRjRkR&R`R7R8R!RpRdRaRRqRERrRDRTRbR2(	RR"t
max_eventsRcRmRRiR2RC((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�s*		

!cCs$|jj�tt|�j�dS(N(RpRORRo(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRO�s
N(
RRR?RRRRFRJRRO(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRo�s		
		!tkqueuetKqueueSelectorcBsJeZdZd�Zd�Zdd�Zd�Zdd�Zd�Z	RS(s  Kqueue / Kevent-based selector cCs&tt|�j�tj�|_dS(N(RRwRRRvt_kqueue(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCs
|jj�S(N(RxR(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�scCs�tt|�j|||�}|t@rhtj|jtjtj�}t	|j
jt|gdd�n|t
@r�tj|jtjtj�}t	|j
jt|gdd�n|S(Ni(RRwRFRDRtkeventRtKQ_FILTER_READt	KQ_EV_ADDR!RxtcontrolR%REtKQ_FILTER_WRITE(RRR2R3RCRy((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRF�s
"
"cCs�tt|�j|�}|jt@r}tj|jtjtj	�}y#t
|jjt
|gdd�Wq}tk
ryq}Xn|jt@r�tj|jtjtj	�}y#t
|jjt
|gdd�Wq�tk
r�q�Xn|S(Ni(RRwRJR2RDRRyRRztKQ_EV_DELETER!RxR|R%RRER}(RRRCRy((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRJ�s$
#

#
cCs9|dk	rt|d�}nt|j�d}i}t|jjtd||�}x�|D]�}|j}|j	}d}|t
jkr�|tO}n|t
j
kr�|tO}n|j|�}	|	r\|	j|kr�|	||	j@f||	j<q%||	jd}
|	||
B|	j@f||	j<q\q\Wt|j��S(Niii(RR`R7R8R!RxR|RatidenttfilterRRzRDR}RERTRR2R(RB(RR"Rut	ready_fdstkevent_listRyRRiR2RCt
old_events((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyR�s*
		

%cCs$|jj�tt|�j�dS(N(RxRORRw(R((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyROs
N(
RRR?RRRRFRJRRO(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyRw�s			cCsgyF|dkr+tj�}|jd�ntt|��j�tSWnttfk
rb}tSXdS(s
 Checks that select structs can be allocated by the underlying
    operating system, not just advertised by the select module. We don't
    check select() because we'll be hopeful that most platforms that
    don't have it available will not advertise it. (ie: GAE) RdiN(RRdtgetattrRORaRRR%(tstructtpR ((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt
_can_allocatescCsytdkrrtd�r!taqrtd�r6taqrtd�rKtaqrttd�rctaqrt	d��nt�S(s� This function serves as a first call for DefaultSelector to
    detect if the select module is being monkey-patched incorrectly
    by eventlet, greenlet, and preserve proper behavior. RvRnRdRs!Platform does not have a selectorN(
t_DEFAULT_SELECTORRR�RwRoReRRRWR(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pytDefaultSelector5s				ii(ii($RRjRRHtsysttimetcollectionsRRR'RtImportErrorRDRERat
HAS_SELECTtobjectR)RR�t	ExceptionRRtversion_infoR!R1R4R@RRWReRoRwR%R�R�(((sF/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/util/selectors.pyt<module>sF

			8�14BR