3

Z'ícã@sÐddlZddlZddlZddlmZyddlmZWn ek
rTddlmZYnXdddgZGdd„de	ƒZ
ejdkr„dd„Znd
d„Zddd„Z
ddd„Zdd„Zdd„Zdd„addd„Zddd„ZdS) éN)Úpartial)Ú	monotonic)ÚtimeÚNoWayToWaitForSocketErrorÚ
wait_for_readÚwait_for_writec@seZdZdS)rN)Ú__name__Ú
__module__Ú__qualname__©rrú4/tmp/pip-build-gk9425m9/urllib3/urllib3/util/wait.pyrséécCs||ƒS)Nr)ÚfnÚtimeoutrrrÚ_retry_on_intr*srcCs”|dkrtdƒ}n
tƒ|}xry||ƒSttjfk
rŠ}zB|jdtjkrR‚n(|tƒ}|dkrhd}|tdƒkrxd}wWYdd}~XqXqWdS)NÚinfr)ÚfloatrÚOSErrorÚselectÚerrorÚargsÚerrnoZEINTR)rrÚdeadlineÚerrrr/s


Fc
Csh|r|rtdƒ‚g}g}|r*|j|ƒ|r8|j|ƒttj|||ƒ}t||ƒ\}}}	t|pd|pd|	ƒS)Nz2must specify at least one of read=True, write=True)ÚRuntimeErrorÚappendrrrÚbool)
ÚsockÚreadÚwriterZrcheckZwcheckrZrreadyZwreadyZxreadyrrrÚselect_wait_for_socketFs

r!csb|r|rtdƒ‚d}|r&|tjO}|r4|tjO}tjƒ‰ˆj||ƒ‡fdd„}tt||ƒƒS)Nz2must specify at least one of read=True, write=Truercs|dk	r|d9}ˆj|ƒS)Niè)Úpoll)Út)Úpoll_objrrÚdo_pollesz%poll_wait_for_socket.<locals>.do_poll)rrÚPOLLINÚPOLLOUTr"Úregisterrr)rrr rÚmaskr%r)r$rÚpoll_wait_for_socketYs

r*cOstdƒ‚dS)Nzno select-equivalent available)r)rÚkwargsrrrÚnull_wait_for_socketmsr,cCs:ytjƒ}t|jdƒWnttfk
r0dSXdSdS)NrFT)rr"rÚAttributeErrorr)r$rrrÚ_have_working_pollqsr.cOs*tƒrtanttdƒrtantat||ŽS)Nr)r.r*Úwait_for_socketÚhasattrrr!r,)rr+rrrr/~s
r/cCst|d|dS)z†Waits for reading to be available on a given socket.
    Returns True if the socket is readable, or False if the timeout expired.
    T)rr)r/)rrrrrrscCst|d|dS)z†Waits for writing to be available on a given socket.
    Returns True if the socket is readable, or False if the timeout expired.
    T)r r)r/)rrrrrr”s)r
r)FFN)FFN)N)N)rrÚsysÚ	functoolsrrrÚImportErrorÚ__all__Ú	ExceptionrÚversion_inforr!r*r,r.r/rrrrrrÚ<module>s&