3 nf\ @sddlZddlmZddlZddlZyddlmZWn ek rTddlmZYnXdddgZGddde Z ej dkrd d Z nd d Z dddZ dddZddZddZddadddZdddZdS) N)partial) monotonic)timeNoWayToWaitForSocketError wait_for_readwait_for_writec@s eZdZdS)rN)__name__ __module__ __qualname__r r /usr/lib/python3.6/wait.pyr scCs||S)Nr )fntimeoutr r r _retry_on_intr)srcCs|dkrtd}n t|}xry||Sttjfk r}zB|jdtjkrRn(|t}|dkrhd}|tdkrxd}wWYdd}~XqXqWdS)Ninfr)floatrOSErrorselecterrorargserrnoZEINTR)rrZdeadlineer r r r-s    Fc Csh| r| rtdg}g}|r*|j||r8|j|ttj|||}t||\}}} t|pd|pd| S)Nz2must specify at least one of read=True, write=True) RuntimeErrorappendrrrbool) sockreadwriterZrcheckZwcheckrZrreadyZwreadyZxreadyr r r select_wait_for_socketDs   r csb| r| rtdd}|r&|tjO}|r4|tjO}tjj||fdd}tt||S)Nz2must specify at least one of read=True, write=Truercs|dk r|d9}j|S)Ni)poll)t)poll_objr r do_pollcsz%poll_wait_for_socket..do_poll)rrZPOLLINZPOLLOUTr!registerrr)rrrrmaskr$r )r#r poll_wait_for_socketWs     r'cOs tddS)Nzno select-equivalent available)r)rkwargsr r r null_wait_for_socketksr)c Cs:ytj}t|jdWnttfk r0dSXdSdS)NrFT)rr!rAttributeErrorr)r#r r r _have_working_pollos r+cOs*tr tanttdrtantat||S)Nr)r+r'wait_for_sockethasattrrr r))rr(r r r r,|s  r,cCst|d|dS)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,)rrr r r rscCst|d|dS)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)rr)r,)rrr r r rs)r r)FFN)FFN)N)N)r functoolsrrsysrr ImportError__all__ Exceptionr version_inforr r'r)r+r,rrr r r r s&