a
    ´iSg  ã                   @   sj  d Z ddlZddlZddlZddlZddlZddlZddlmZ G dd„ dƒZ	G dd„ de	ƒZ
G d	d
„ d
ƒZG dd„ dƒZG dd„ dƒZG dd„ deƒZdae ¡ ZG dd„ dejƒZeƒ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ ZeZ eZ!eZ"eZ#zdd)l$mZmZmZmZ W n e%�yT   Y n0 eZ&eZ'eZ(eZ)dS )*)ÚAbstractEventLoopPolicyÚAbstractEventLoopÚAbstractServerÚHandleÚTimerHandleÚget_event_loop_policyÚset_event_loop_policyÚget_event_loopÚset_event_loopÚnew_event_loopÚget_child_watcherÚset_child_watcherÚ_set_running_loopÚget_running_loopÚ_get_running_loopé    Né   )Úformat_helpersc                   @   sB   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )r   )Ú	_callbackÚ_argsÚ
_cancelledÚ_loopÚ_source_tracebackÚ_reprÚ__weakref__Ú_contextNc                 C   s\   |d u rt  ¡ }|| _|| _|| _|| _d| _d | _| j ¡ rRt	 
t d¡¡| _nd | _d S )NFr   )ÚcontextvarsZcopy_contextr   r   r   r   r   r   Ú	get_debugr   Úextract_stackÚsysÚ	_getframer   )ÚselfÚcallbackÚargsÚloopÚcontext© r%   ú&/usr/lib64/python3.9/asyncio/events.pyÚ__init__   s    
ÿzHandle.__init__c                 C   sl   | j jg}| jr| d¡ | jd ur:| t | j| j¡¡ | jrh| jd }| d|d › d|d › �¡ |S )NÚ	cancelledéÿÿÿÿzcreated at r   ú:r   )	Ú	__class__Ú__name__r   Úappendr   r   Ú_format_callback_sourcer   r   )r    ÚinfoÚframer%   r%   r&   Ú
_repr_info.   s    


ÿ
zHandle._repr_infoc                 C   s(   | j d ur| j S |  ¡ }d d |¡¡S )Nz<{}>ú )r   r1   ÚformatÚjoin)r    r/   r%   r%   r&   Ú__repr__:   s    
zHandle.__repr__c                 C   s0   | j s,d| _ | j ¡ r t| ƒ| _d | _d | _d S ©NT)r   r   r   Úreprr   r   r   ©r    r%   r%   r&   Úcancel@   s    

zHandle.cancelc                 C   s   | j S ©N)r   r8   r%   r%   r&   r(   K   s    zHandle.cancelledc              
   C   s¢   z| j j| jg| j¢R Ž  W n| ttfy4   ‚ Y nf ty˜ } zNt | j| j¡}d|› �}||| dœ}| j	rx| j	|d< | j
 |¡ W Y d }~n
d }~0 0 d } d S )NzException in callback )ÚmessageÚ	exceptionÚhandleZsource_traceback)r   Úrunr   r   Ú
SystemExitÚKeyboardInterruptÚBaseExceptionr   r.   r   r   Úcall_exception_handler)r    ÚexcÚcbÚmsgr$   r%   r%   r&   Ú_runN   s"    ÿ
ý
"zHandle._run)N)
r,   Ú
__module__Ú__qualname__Ú	__slots__r'   r1   r5   r9   r(   rF   r%   r%   r%   r&   r      s   
r   c                       sv   e Zd ZddgZd‡ fdd„	Z‡ fdd„Zdd	„ Zd
d„ Zdd„ Zdd„ Z	dd„ Z
dd„ Z‡ fdd„Zdd„ Z‡  ZS )r   Ú
_scheduledÚ_whenNc                    s0   t ƒ  ||||¡ | jr | jd= || _d| _d S )Nr)   F)Úsuperr'   r   rK   rJ   )r    Úwhenr!   r"   r#   r$   ©r+   r%   r&   r'   g   s
    zTimerHandle.__init__c                    s0   t ƒ  ¡ }| jrdnd}| |d| j› �¡ |S )Né   r   zwhen=)rL   r1   r   ÚinsertrK   )r    r/   ÚposrN   r%   r&   r1   o   s    
zTimerHandle._repr_infoc                 C   s
   t | jƒS r:   )ÚhashrK   r8   r%   r%   r&   Ú__hash__u   s    zTimerHandle.__hash__c                 C   s   t |tƒr| j|jk S tS r:   ©Ú
isinstancer   rK   ÚNotImplemented©r    Úotherr%   r%   r&   Ú__lt__x   s    
zTimerHandle.__lt__c                 C   s$   t |tƒr | j|jk p|  |¡S tS r:   ©rU   r   rK   Ú__eq__rV   rW   r%   r%   r&   Ú__le__}   s    
zTimerHandle.__le__c                 C   s   t |tƒr| j|jkS tS r:   rT   rW   r%   r%   r&   Ú__gt__‚   s    
zTimerHandle.__gt__c                 C   s$   t |tƒr | j|jkp|  |¡S tS r:   rZ   rW   r%   r%   r&   Ú__ge__‡   s    
zTimerHandle.__ge__c                 C   s>   t |tƒr:| j|jko8| j|jko8| j|jko8| j|jkS tS r:   )rU   r   rK   r   r   r   rV   rW   r%   r%   r&   r[   Œ   s    

ÿ
þ
ýzTimerHandle.__eq__c                    s    | j s| j | ¡ tƒ  ¡  d S r:   )r   r   Ú_timer_handle_cancelledrL   r9   r8   rN   r%   r&   r9   ”   s    zTimerHandle.cancelc                 C   s   | j S r:   )rK   r8   r%   r%   r&   rM   ™   s    zTimerHandle.when)N)r,   rG   rH   rI   r'   r1   rS   rY   r\   r]   r^   r[   r9   rM   Ú__classcell__r%   r%   rN   r&   r   b   s   r   c                   @   sL   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dS )r   c                 C   s   t ‚d S r:   ©ÚNotImplementedErrorr8   r%   r%   r&   Úclose¥   s    zAbstractServer.closec                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Úget_loop©   s    zAbstractServer.get_loopc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Ú
is_serving­   s    zAbstractServer.is_servingc                 Ã   s   t ‚d S r:   ra   r8   r%   r%   r&   Ústart_serving±   s    zAbstractServer.start_servingc                 Ã   s   t ‚d S r:   ra   r8   r%   r%   r&   Úserve_forever¹   s    zAbstractServer.serve_foreverc                 Ã   s   t ‚d S r:   ra   r8   r%   r%   r&   Úwait_closedÀ   s    zAbstractServer.wait_closedc                 Ã   s   | S r:   r%   r8   r%   r%   r&   Ú
__aenter__Ä   s    zAbstractServer.__aenter__c                 Ç   s   |   ¡  |  ¡ I d H  d S r:   )rc   rh   )r    rC   r%   r%   r&   Ú	__aexit__Ç   s    zAbstractServer.__aexit__N)r,   rG   rH   rc   rd   re   rf   rg   rh   ri   rj   r%   r%   r%   r&   r   ¢   s   r   c                   @   sr  e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zddœdd„Zddœdd„Zddœdd„Zdd„ Zdd„ Zddœd d!„Zddœd"d#„Zd$d%„ Zd&d'„ Zd(d(d(d(d)œd*d+„Zdwd,d-„Zdxdd(d(d(ddddddd.œ
d/d0„Zdyejejdd1ddddd2d3œ	d4d5„Zdzd2d6œd7d8„Zd9ddd:œd;d<„Zd{ddddd=œd>d?„Zd|dd1ddd2d@œdAdB„Zd}d(d(d(dddddCœdDdE„Z dFdG„ Z!dHdI„ Z"e#j$e#j$e#j$dJœdKdL„Z%e#j$e#j$e#j$dJœdMdN„Z&dOdP„ Z'dQdR„ Z(dSdT„ Z)dUdV„ Z*dWdX„ Z+dYdZ„ Z,d[d\„ Z-d]d^„ Z.d_d`„ Z/d~dd6œdadb„Z0dcdd„ Z1dedf„ Z2dgdh„ Z3didj„ Z4dkdl„ Z5dmdn„ Z6dodp„ Z7dqdr„ Z8dsdt„ Z9dudv„ Z:dS )r   c                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Úrun_foreverÑ   s    zAbstractEventLoop.run_foreverc                 C   s   t ‚d S r:   ra   )r    Úfuturer%   r%   r&   Úrun_until_completeÕ   s    z$AbstractEventLoop.run_until_completec                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   ÚstopÜ   s    zAbstractEventLoop.stopc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Ú
is_runningä   s    zAbstractEventLoop.is_runningc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Ú	is_closedè   s    zAbstractEventLoop.is_closedc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   rc   ì   s    	zAbstractEventLoop.closec                 Ã   s   t ‚d S r:   ra   r8   r%   r%   r&   Úshutdown_asyncgens÷   s    z$AbstractEventLoop.shutdown_asyncgensc                 Ã   s   t ‚d S r:   ra   r8   r%   r%   r&   Úshutdown_default_executorû   s    z+AbstractEventLoop.shutdown_default_executorc                 C   s   t ‚d S r:   ra   )r    r=   r%   r%   r&   r_     s    z)AbstractEventLoop._timer_handle_cancelledN)r$   c                G   s   | j d|g|¢R d|iŽS )Nr   r$   )Ú
call_later©r    r!   r$   r"   r%   r%   r&   Ú	call_soon  s    zAbstractEventLoop.call_soonc                G   s   t ‚d S r:   ra   )r    Údelayr!   r$   r"   r%   r%   r&   rs     s    zAbstractEventLoop.call_laterc                G   s   t ‚d S r:   ra   )r    rM   r!   r$   r"   r%   r%   r&   Úcall_at  s    zAbstractEventLoop.call_atc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Útime  s    zAbstractEventLoop.timec                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Úcreate_future  s    zAbstractEventLoop.create_future)Únamec                C   s   t ‚d S r:   ra   )r    Úcororz   r%   r%   r&   Úcreate_task  s    zAbstractEventLoop.create_taskc                G   s   t ‚d S r:   ra   rt   r%   r%   r&   Úcall_soon_threadsafe  s    z&AbstractEventLoop.call_soon_threadsafec                 G   s   t ‚d S r:   ra   )r    ÚexecutorÚfuncr"   r%   r%   r&   Úrun_in_executor  s    z!AbstractEventLoop.run_in_executorc                 C   s   t ‚d S r:   ra   )r    r~   r%   r%   r&   Úset_default_executor!  s    z&AbstractEventLoop.set_default_executorr   )ÚfamilyÚtypeÚprotoÚflagsc                Ã   s   t ‚d S r:   ra   )r    ÚhostÚportr‚   rƒ   r„   r…   r%   r%   r&   Úgetaddrinfo&  s    zAbstractEventLoop.getaddrinfoc                 Ã   s   t ‚d S r:   ra   )r    Zsockaddrr…   r%   r%   r&   Úgetnameinfo*  s    zAbstractEventLoop.getnameinfo)
Ússlr‚   r„   r…   ÚsockÚ
local_addrÚserver_hostnameÚssl_handshake_timeoutÚhappy_eyeballs_delayÚ
interleavec       
         Ã   s   t ‚d S r:   ra   )r    Úprotocol_factoryr†   r‡   rŠ   r‚   r„   r…   r‹   rŒ   r�   rŽ   r�   r�   r%   r%   r&   Úcreate_connection-  s    z#AbstractEventLoop.create_connectionéd   T)	r‚   r…   r‹   ÚbacklogrŠ   Úreuse_addressÚ
reuse_portrŽ   rf   c       	         Ã   s   t ‚d S r:   ra   )r    r‘   r†   r‡   r‚   r…   r‹   r”   rŠ   r•   r–   rŽ   rf   r%   r%   r&   Úcreate_server6  s    3zAbstractEventLoop.create_server)Úfallbackc                Ã   s   t ‚d S r:   ra   )r    Ú	transportÚfileÚoffsetÚcountr˜   r%   r%   r&   Úsendfilek  s    zAbstractEventLoop.sendfileF)Úserver_sider�   rŽ   c                Ã   s   t ‚d S r:   ra   )r    r™   ÚprotocolZ
sslcontextrž   r�   rŽ   r%   r%   r&   Ú	start_tlss  s    	zAbstractEventLoop.start_tls)rŠ   r‹   r�   rŽ   c                Ã   s   t ‚d S r:   ra   )r    r‘   ÚpathrŠ   r‹   r�   rŽ   r%   r%   r&   Úcreate_unix_connection~  s    z(AbstractEventLoop.create_unix_connection)r‹   r”   rŠ   rŽ   rf   c                Ã   s   t ‚d S r:   ra   )r    r‘   r¡   r‹   r”   rŠ   rŽ   rf   r%   r%   r&   Úcreate_unix_server…  s    z$AbstractEventLoop.create_unix_server)r‚   r„   r…   r•   r–   Úallow_broadcastr‹   c                Ã   s   t ‚d S r:   ra   )r    r‘   rŒ   Zremote_addrr‚   r„   r…   r•   r–   r¤   r‹   r%   r%   r&   Úcreate_datagram_endpoint¥  s    !z*AbstractEventLoop.create_datagram_endpointc                 Ã   s   t ‚d S r:   ra   ©r    r‘   Úpiper%   r%   r&   Úconnect_read_pipeÊ  s    z#AbstractEventLoop.connect_read_pipec                 Ã   s   t ‚d S r:   ra   r¦   r%   r%   r&   Úconnect_write_pipe×  s    z$AbstractEventLoop.connect_write_pipe)ÚstdinÚstdoutÚstderrc                Ë   s   t ‚d S r:   ra   )r    r‘   Úcmdrª   r«   r¬   Úkwargsr%   r%   r&   Úsubprocess_shellä  s    z"AbstractEventLoop.subprocess_shellc                Ï   s   t ‚d S r:   ra   )r    r‘   rª   r«   r¬   r"   r®   r%   r%   r&   Úsubprocess_execë  s    z!AbstractEventLoop.subprocess_execc                 G   s   t ‚d S r:   ra   ©r    Úfdr!   r"   r%   r%   r&   Ú
add_reader÷  s    zAbstractEventLoop.add_readerc                 C   s   t ‚d S r:   ra   ©r    r²   r%   r%   r&   Úremove_readerú  s    zAbstractEventLoop.remove_readerc                 G   s   t ‚d S r:   ra   r±   r%   r%   r&   Ú
add_writerý  s    zAbstractEventLoop.add_writerc                 C   s   t ‚d S r:   ra   r´   r%   r%   r&   Úremove_writer   s    zAbstractEventLoop.remove_writerc                 Ã   s   t ‚d S r:   ra   )r    r‹   Únbytesr%   r%   r&   Ú	sock_recv  s    zAbstractEventLoop.sock_recvc                 Ã   s   t ‚d S r:   ra   )r    r‹   Úbufr%   r%   r&   Úsock_recv_into  s    z AbstractEventLoop.sock_recv_intoc                 Ã   s   t ‚d S r:   ra   )r    r‹   Údatar%   r%   r&   Úsock_sendall  s    zAbstractEventLoop.sock_sendallc                 Ã   s   t ‚d S r:   ra   )r    r‹   Úaddressr%   r%   r&   Úsock_connect  s    zAbstractEventLoop.sock_connectc                 Ã   s   t ‚d S r:   ra   )r    r‹   r%   r%   r&   Úsock_accept  s    zAbstractEventLoop.sock_acceptc                Ã   s   t ‚d S r:   ra   )r    r‹   rš   r›   rœ   r˜   r%   r%   r&   Úsock_sendfile  s    zAbstractEventLoop.sock_sendfilec                 G   s   t ‚d S r:   ra   )r    Úsigr!   r"   r%   r%   r&   Úadd_signal_handler  s    z$AbstractEventLoop.add_signal_handlerc                 C   s   t ‚d S r:   ra   )r    rÂ   r%   r%   r&   Úremove_signal_handler  s    z'AbstractEventLoop.remove_signal_handlerc                 C   s   t ‚d S r:   ra   )r    Úfactoryr%   r%   r&   Úset_task_factory"  s    z"AbstractEventLoop.set_task_factoryc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Úget_task_factory%  s    z"AbstractEventLoop.get_task_factoryc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   Úget_exception_handler*  s    z'AbstractEventLoop.get_exception_handlerc                 C   s   t ‚d S r:   ra   )r    Úhandlerr%   r%   r&   Úset_exception_handler-  s    z'AbstractEventLoop.set_exception_handlerc                 C   s   t ‚d S r:   ra   ©r    r$   r%   r%   r&   Údefault_exception_handler0  s    z+AbstractEventLoop.default_exception_handlerc                 C   s   t ‚d S r:   ra   rË   r%   r%   r&   rB   3  s    z(AbstractEventLoop.call_exception_handlerc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   r   8  s    zAbstractEventLoop.get_debugc                 C   s   t ‚d S r:   ra   )r    Zenabledr%   r%   r&   Ú	set_debug;  s    zAbstractEventLoop.set_debug)r   )NN)NN)r   N)N)N)NN)r   N);r,   rG   rH   rk   rm   rn   ro   rp   rc   rq   rr   r_   ru   rs   rw   rx   ry   r|   r}   r€   r�   rˆ   r‰   r’   ÚsocketÚ	AF_UNSPECÚ
AI_PASSIVEr—   r�   r    r¢   r£   r¥   r¨   r©   Ú
subprocessÚPIPEr¯   r°   r³   rµ   r¶   r·   r¹   r»   r½   r¿   rÀ   rÁ   rÃ   rÄ   rÆ   rÇ   rÈ   rÊ   rÌ   rB   r   rÍ   r%   r%   r%   r&   r   Ì   s¼   ÿ
 ÿú
 ÿú5ÿ	ý ÿü ÿü! ÿü%ýýÿr   c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )r   c                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   r   B  s    z&AbstractEventLoopPolicy.get_event_loopc                 C   s   t ‚d S r:   ra   ©r    r#   r%   r%   r&   r	   L  s    z&AbstractEventLoopPolicy.set_event_loopc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   r
   P  s    z&AbstractEventLoopPolicy.new_event_loopc                 C   s   t ‚d S r:   ra   r8   r%   r%   r&   r   X  s    z)AbstractEventLoopPolicy.get_child_watcherc                 C   s   t ‚d S r:   ra   )r    Úwatcherr%   r%   r&   r   \  s    z)AbstractEventLoopPolicy.set_child_watcherN)r,   rG   rH   r   r	   r
   r   r   r%   r%   r%   r&   r   ?  s
   
r   c                   @   sB   e Zd ZdZG dd„ dejƒZdd„ Zdd„ Zdd	„ Z	d
d„ Z
dS )ÚBaseDefaultEventLoopPolicyNc                   @   s   e Zd ZdZdZdS )z!BaseDefaultEventLoopPolicy._LocalNF)r,   rG   rH   r   Ú_set_calledr%   r%   r%   r&   Ú_Localp  s   r×   c                 C   s   |   ¡ | _d S r:   )r×   Ú_localr8   r%   r%   r&   r'   t  s    z#BaseDefaultEventLoopPolicy.__init__c                 C   sX   | j jd u r2| j js2t ¡ t ¡ u r2|  |  ¡ ¡ | j jd u rPtdt ¡ j	 ƒ‚| j jS )Nz,There is no current event loop in thread %r.)
rØ   r   rÖ   Ú	threadingÚcurrent_threadÚmain_threadr	   r
   ÚRuntimeErrorrz   r8   r%   r%   r&   r   w  s    ÿþÿz)BaseDefaultEventLoopPolicy.get_event_loopc                 C   s   d| j _|| j _d S r6   )rØ   rÖ   r   rÓ   r%   r%   r&   r	   ‡  s    z)BaseDefaultEventLoopPolicy.set_event_loopc                 C   s   |   ¡ S r:   )Ú_loop_factoryr8   r%   r%   r&   r
   �  s    z)BaseDefaultEventLoopPolicy.new_event_loop)r,   rG   rH   rÝ   rÙ   Úlocalr×   r'   r   r	   r
   r%   r%   r%   r&   rÕ   a  s   rÕ   c                   @   s   e Zd ZdZdS )Ú_RunningLoop)NNN)r,   rG   rH   Úloop_pidr%   r%   r%   r&   rß   ¡  s   rß   c                  C   s   t ƒ } | d u rtdƒ‚| S )Nzno running event loop)r   rÜ   ©r#   r%   r%   r&   r   ¨  s    r   c                  C   s&   t j\} }| d ur"|t ¡ kr"| S d S r:   )Ú_running_looprà   ÚosÚgetpid)Zrunning_loopÚpidr%   r%   r&   r   ´  s    
r   c                 C   s   | t  ¡ ft_d S r:   )rã   rä   râ   rà   rá   r%   r%   r&   r   À  s    r   c                  C   sB   t �* td u r ddlm}  | ƒ aW d   ƒ n1 s40    Y  d S )Nr   ©ÚDefaultEventLoopPolicy)Ú_lockÚ_event_loop_policyÚ rç   ræ   r%   r%   r&   Ú_init_event_loop_policyÊ  s    rë   c                   C   s   t d u rtƒ  t S r:   )ré   rë   r%   r%   r%   r&   r   Ò  s    r   c                 C   s   | a d S r:   )ré   )Zpolicyr%   r%   r&   r   Ù  s    r   c                  C   s   t ƒ } | d ur| S tƒ  ¡ S r:   )r   r   r   )Zcurrent_loopr%   r%   r&   r   â  s    
r   c                 C   s   t ƒ  | ¡ d S r:   )r   r	   rá   r%   r%   r&   r	   ò  s    r	   c                   C   s
   t ƒ  ¡ S r:   )r   r
   r%   r%   r%   r&   r
   ÷  s    r
   c                   C   s
   t ƒ  ¡ S r:   )r   r   r%   r%   r%   r&   r   ü  s    r   c                 C   s   t ƒ  | ¡S r:   )r   r   )rÔ   r%   r%   r&   r     s    r   )r   r   r   r   )*Ú__all__r   rã   rÎ   rÑ   r   rÙ   rê   r   r   r   r   r   r   rÕ   ré   ÚLockrè   rÞ   rß   râ   r   r   r   rë   r   r   r   r	   r
   r   r   Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncioÚImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr%   r%   r%   r&   Ú<module>   sT   J@*  u"9
	