a ´i*Êã@sâddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZdZe jdkrúedƒ‚dd„ZGdd„dejƒZGdd„dejƒZ Gdd„dej!ej"ƒZ#Gdd„dej$ƒZ%Gdd„dƒZ&Gdd„de&ƒZ'dd „Z(Gd!d"„d"e&ƒZ)Gd#d$„d$e)ƒZ*Gd%d&„d&e)ƒZ+Gd'd(„d(e&ƒZ,Gd)d*„d*e&ƒZ-Gd+d,„d,ej.ƒZ/eZ0e/Z1dS)-éNé)Ú base_events)Úbase_subprocess)Ú constants)Ú coroutines)Úevents)Ú exceptions)Úfutures)Úselector_events)Útasks)Ú transports)Úlogger)ÚSelectorEventLoopÚAbstractChildWatcherÚSafeChildWatcherÚFastChildWatcherÚPidfdChildWatcherÚMultiLoopChildWatcherÚThreadedChildWatcherÚDefaultEventLoopPolicyÚwin32z+Signals are not really supported on WindowscCsdS©N©)ÚsignumÚframerrú+/usr/lib64/python3.9/asyncio/unix_events.pyÚ_sighandler_noop*srcsÆeZdZd(‡fdd„ Z‡fdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z d)dd„Z d*dd„Z d+dd„Z dd„Z d,dddddœdd„Zd-ddddddœdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Z‡ZS).Ú_UnixSelectorEventLoopNcstƒ |¡i|_dSr)ÚsuperÚ__init__Ú_signal_handlers)ÚselfÚselector©Ú __class__rrr5s z_UnixSelectorEventLoop.__init__csZtƒ ¡t ¡s.t|jƒD]}| |¡qn(|jrVtjd|›dt |d|j  ¡dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal©Úsource) rÚcloseÚsysÚ is_finalizingÚlistr Úremove_signal_handlerÚwarningsÚwarnÚResourceWarningÚclear©r!Úsigr#rrr'9s üz_UnixSelectorEventLoop.closecCs|D]}|sq| |¡qdSr)Ú_handle_signal)r!ÚdatarrrrÚ_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsRt |¡st |¡rtdƒ‚| |¡| ¡zt |j  ¡¡Wn4t t fyv}zt t |ƒƒ‚WYd}~n d}~00t |||d¡}||j|<zt |t¡t |d¡Wnžt yL}z„|j|=|jszt d¡Wn6t t fy}zt d|¡WYd}~n d}~00|jtjkr6t d|›dƒ‚n‚WYd}~n d}~00dS)Nz3coroutines cannot be used with add_signal_handler()Féÿÿÿÿúset_wakeup_fd(-1) failed: %súsig ú cannot be caught)rZ iscoroutineZiscoroutinefunctionÚ TypeErrorÚ _check_signalÚ _check_closedÚsignalÚ set_wakeup_fdZ_csockÚfilenoÚ ValueErrorÚOSErrorÚ RuntimeErrorÚstrrÚHandler rÚ siginterruptr ÚinfoÚerrnoÚEINVAL)r!r1ÚcallbackÚargsÚexcÚhandleZnexcrrrÚadd_signal_handlerNs2 ÿ "  "z)_UnixSelectorEventLoop.add_signal_handlercCs8|j |¡}|durdS|jr*| |¡n | |¡dSr)r ÚgetZ _cancelledr+Z_add_callback_signalsafe)r!r1rKrrrr2{s   z%_UnixSelectorEventLoop._handle_signalc Csè| |¡z |j|=Wnty*YdS0|tjkr>tj}ntj}zt ||¡WnDty˜}z,|jtj kr‚t d|›dƒ‚n‚WYd}~n d}~00|jsäzt  d¡Wn4t tfyâ}zt  d|¡WYd}~n d}~00dS)NFr7r8r5r6T)r:r ÚKeyErrorr<ÚSIGINTÚdefault_int_handlerÚSIG_DFLr@rFrGrAr=r?r rE)r!r1ÚhandlerrJrrrr+…s(     "z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tƒstd|›ƒ‚|t ¡vr2td|›ƒ‚dS)Nzsig must be an int, not zinvalid signal number )Ú isinstanceÚintr9r<Ú valid_signalsr?r0rrrr:¥s  z$_UnixSelectorEventLoop._check_signalcCst|||||ƒSr)Ú_UnixReadPipeTransport©r!ÚpipeÚprotocolÚwaiterÚextrarrrÚ_make_read_pipe_transport±sz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||ƒSr)Ú_UnixWritePipeTransportrWrrrÚ_make_write_pipe_transportµsz1_UnixSelectorEventLoop._make_write_pipe_transportc ËsÌt ¡°} |  ¡stdƒ‚| ¡} t||||||||f| |dœ| ¤Ž} |  |  ¡|j| ¡z| IdHWn@t t fy€‚Yn*t y¨|   ¡|   ¡IdH‚Yn0Wdƒn1s¾0Y| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rZr[)rÚget_child_watcherÚ is_activerAÚ create_futureÚ_UnixSubprocessTransportÚadd_child_handlerZget_pidÚ_child_watcher_callbackÚ SystemExitÚKeyboardInterruptÚ BaseExceptionr'Ú_wait) r!rYrIÚshellÚstdinÚstdoutÚstderrÚbufsizer[ÚkwargsÚwatcherrZÚtransprrrÚ_make_subprocess_transport¹s.  ÿþý ÿ &z1_UnixSelectorEventLoop._make_subprocess_transportcCs| |j|¡dSr)Úcall_soon_threadsafeZ_process_exited)r!ÚpidÚ returncoderprrrrd×sz._UnixSelectorEventLoop._child_watcher_callback)ÚsslÚsockÚserver_hostnameÚssl_handshake_timeoutc Ãs |r|dur6tdƒ‚n |dur&tdƒ‚|dur6tdƒ‚|dur¤|durNtdƒ‚t |¡}t tjtjd¡}z | d¡| ||¡IdHWqä| ¡‚Yqä0n@|dur´tdƒ‚|j tjksÌ|j tjkrÚtd|›ƒ‚| d¡|j |||||d IdH\}}||fS) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslú1ssl_handshake_timeout is only meaningful with sslú3path and sock can not be specified at the same timerFzno path and sock were specifiedú.A UNIX Domain Stream Socket was expected, got )rx) r?ÚosÚfspathÚsocketÚAF_UNIXÚ SOCK_STREAMÚ setblockingZ sock_connectr'ÚfamilyÚtypeZ_create_connection_transport) r!Úprotocol_factoryÚpathrurvrwrxÚ transportrYrrrÚcreate_unix_connectionÚsLÿÿÿ     ÿÿ þz-_UnixSelectorEventLoop.create_unix_connectionédT)rvÚbacklogrurxÚ start_servingc ÃsÈt|tƒrtdƒ‚|dur&|s&tdƒ‚|durJ|dur@tdƒ‚t |¡}t tjtj¡}|ddvrÊz t   t  |¡j ¡r„t  |¡WnBt y˜Yn2tyÈ}zt d||¡WYd}~n d}~00z| |¡Wnnty2} z@| ¡| jtjkrd|›d} ttj| ƒd‚n‚WYd} ~ nd} ~ 0| ¡‚Yn0n<|dur\td ƒ‚|jtjksx|jtjkr†td |›ƒ‚| d ¡t ||g||||¡} |rÄ|  ¡t d¡IdH| S) Nz*ssl argument must be an SSLContext or Noneryrzr)rúz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedr{F)rSÚboolr9r?r|r}r~rr€ÚstatÚS_ISSOCKÚst_modeÚremoveÚFileNotFoundErrorr@r ÚerrorÚbindr'rFZ EADDRINUSEr‚rƒrrZServerZ_start_servingr Úsleep) r!r„r…rvr‰rurxrŠÚerrrJÚmsgZserverrrrÚcreate_unix_serversh  ÿ ÿ   ÿ   ÿ ÿÿ  ÿz)_UnixSelectorEventLoop.create_unix_serverc ÃsÖz tjWnty&t d¡‚Yn0z | ¡}Wn4ttjfyh}zt d¡‚WYd}~n d}~00zt |¡j }Wnt y–t d¡‚Yn0|r |n|}|s¬dS|  ¡} |  | d|||||d¡| IdHS)Nzos.sendfile() is not availableznot a regular filer) r|ÚsendfileÚAttributeErrorrÚSendfileNotAvailableErrorr>ÚioÚUnsupportedOperationÚfstatÚst_sizer@raÚ_sock_sendfile_native_impl) r!rvÚfileÚoffsetÚcountr>r•ÚfsizeÚ blocksizeÚfutrrrÚ_sock_sendfile_nativeJs,  ÿ      ÿz,_UnixSelectorEventLoop._sock_sendfile_nativec Cs,| ¡} |dur| |¡| ¡r4| |||¡dS|rd||}|dkrd| |||¡| |¡dSzt | |||¡} WnDttfyÄ|dur |  ||¡|  | |j || ||||||¡ Yndt yj} zŽ|dur| j t jkrt| ƒturtdt jƒ} | | _| } |dkr>t d¡} | |||¡| | ¡n| |||¡| | ¡WYd} ~ nÆd} ~ 0ttfy‚‚Yn¦ty¾} z$| |||¡| | ¡WYd} ~ nrd} ~ 00| dkrä| |||¡| |¡nD|| 7}|| 7}|dur |  ||¡|  | |j || ||||||¡ dS)Nrzsocket is not connectedzos.sendfile call failed)r>Ú remove_writerÚ cancelledÚ_sock_sendfile_update_fileposÚ set_resultr|r˜ÚBlockingIOErrorÚInterruptedErrorÚ_sock_add_cancellation_callbackZ add_writerrŸr@rFZENOTCONNrƒÚConnectionErrorÚ __cause__rršÚ set_exceptionrerfrg)r!r¥Z registered_fdrvr>r¡r¢r¤Ú total_sentÚfdÚsentrJÚnew_excr•rrrrŸasp    þ   ÿ þÿ ÿ       þz1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt ||tj¡dS©Nr)r|ÚlseekÚSEEK_SET)r!r>r¡r±rrrr©§sz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcs‡‡fdd„}| |¡dS)Ncs&| ¡r"ˆ ¡}|dkr"ˆ |¡dS)Nr5)r¨r>r§)r¥r²©r!rvrrÚcb¬szB_UnixSelectorEventLoop._sock_add_cancellation_callback..cb)Úadd_done_callback)r!r¥rvr¹rr¸rr­«sz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)Ú__name__Ú __module__Ú __qualname__rr'r4rLr2r+r:r\r^rqrdr‡r—r¦rŸr©r­Ú __classcell__rrr#rr/s@ -   ÿ ÿ þ ÿü .ÿü CFrcsŠeZdZdZd‡fdd„ Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z e jfdd„Zddd„Zdd„Zdd„Z‡ZS) rViNcsÚtƒ |¡||jd<||_||_| ¡|_||_d|_d|_ t   |j¡j }t  |¡s„t  |¡s„t  |¡s„d|_d|_d|_tdƒ‚t  |jd¡|j |jj|¡|j |jj|j|j¡|durÖ|j tj|d¡dS)NrXFz)Pipe transport is for pipes/sockets only.)rrÚ_extraÚ_loopÚ_piper>Ú_filenoÚ _protocolÚ_closingÚ_pausedr|rrrÚS_ISFIFOrŽÚS_ISCHRr?Ú set_blockingÚ call_soonÚconnection_madeÚ _add_readerÚ _read_readyr Ú_set_result_unless_cancelled)r!ÚlooprXrYrZr[Úmoder#rrr¸s6    ÿþ ÿ ÿz_UnixReadPipeTransport.__init__cCsÀ|jjg}|jdur | d¡n|jr0| d¡| d|j›¡t|jddƒ}|jdur|durt  ||jt j ¡}|r„| d¡q°| d¡n |jdur¦| d¡n | d¡d  d   |¡¡S) NÚclosedÚclosingúfd=Ú _selectorÚpollingÚidleÚopenú<{}>ú )r$r»rÁÚappendrÄrÂÚgetattrrÀr Ú_test_selector_eventÚ selectorsÚ EVENT_READÚformatÚjoin)r!rEr"rÔrrrÚ__repr__Ös$     ÿ     z_UnixReadPipeTransport.__repr__c Csºzt |j|j¡}WnDttfy*YnŒtyX}z| |d¡WYd}~nfd}~00|rl|j  |¡nJ|j   ¡r‚t   d|¡d|_|j  |j¡|j  |jj¡|j  |jd¡dS)Nz"Fatal read error on pipe transportú%r was closed by peerT)r|ÚreadrÂÚmax_sizer«r¬r@Ú _fatal_errorrÃZ data_receivedrÀÚ get_debugr rErÄÚ_remove_readerrÉZ eof_receivedÚ_call_connection_lost)r!r3rJrrrrÌës"  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j |j¡|j ¡r:t d|¡dS)NTz%r pauses reading)rÄrÅrÀrærÂrår Údebug©r!rrrÚ pause_readingýs   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j |j|j¡|j ¡r>t d|¡dS)NFz%r resumes reading) rÄrÅrÀrËrÂrÌrår rèrérrrÚresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSr©rér!rYrrrÚ set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrìrérrrÚ get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSr©rÄrérrrÚ is_closingsz!_UnixReadPipeTransport.is_closingcCs|js| d¡dSr)rÄÚ_closerérrrr'sz_UnixReadPipeTransport.closecCs,|jdur(|d|›t|d|j ¡dS©Nzunclosed transport r%©rÁr.r'©r!Ú_warnrrrÚ__del__s z_UnixReadPipeTransport.__del__úFatal error on pipe transportcCsZt|tƒr4|jtjkr4|j ¡rLtjd||ddn|j ||||j dœ¡|  |¡dS©Nz%r: %sT©Úexc_info)ÚmessageÚ exceptionr†rY) rSr@rFZEIOrÀrår rèÚcall_exception_handlerrÃrò©r!rJrürrrräs üz#_UnixReadPipeTransport._fatal_errorcCs(d|_|j |j¡|j |j|¡dS©NT)rÄrÀrærÂrÉrç©r!rJrrrrò-sz_UnixReadPipeTransport._closecCsPz,|j |¡W|j ¡d|_d|_d|_n|j ¡d|_d|_d|_0dSr©rÃZconnection_lostrÁr'rÀrrrrrç2s ý z,_UnixReadPipeTransport._call_connection_lost)NN)rø)r»r¼r½rãrràrÌrêrërîrïrñr'r,r-r÷räròrçr¾rrr#rrV´s rVcs¨eZdZd%‡fdd„ Zdd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zejfdd„Zdd„Zd&dd „Zd'd!d"„Zd#d$„Z‡ZS)(r]Nc sþtƒ ||¡||jd<||_| ¡|_||_tƒ|_d|_ d|_ t   |j¡j }t |¡}t |¡}t |¡} |s”|s”| s”d|_d|_d|_tdƒ‚t  |jd¡|j |jj|¡| sÈ|ràtj d¡sà|j |jj|j|j¡|durú|j tj|d¡dS)NrXrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrr¿rÁr>rÂrÃÚ bytearrayÚ_bufferÚ _conn_lostrÄr|rrrrÇrÆrŽr?rÈrÀrÉrÊr(ÚplatformÚ startswithrËrÌr rÍ) r!rÎrXrYrZr[rÏZis_charÚis_fifoÚ is_socketr#rrr?s6       ÿ ÿz _UnixWritePipeTransport.__init__cCsØ|jjg}|jdur | d¡n|jr0| d¡| d|j›¡t|jddƒ}|jdur¨|dur¨t  ||jt j ¡}|r„| d¡n | d¡|  ¡}| d|›¡n |jdur¾| d¡n | d¡d   d  |¡¡S) NrÐrÑrÒrÓrÔrÕzbufsize=rÖr×rØ)r$r»rÁrÙrÄrÂrÚrÀr rÛrÜÚ EVENT_WRITEÚget_write_buffer_sizerÞrß)r!rEr"rÔrmrrrràds(     ÿ     z _UnixWritePipeTransport.__repr__cCs t|jƒSr)Úlenrrérrrr |sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|j ¡rt d|¡|jr*| tƒ¡n| ¡dS)Nrá)rÀrår rErròÚBrokenPipeErrorrérrrrÌs   z#_UnixWritePipeTransport._read_readyc Cs.t|tƒrt|ƒ}|sdS|js&|jrN|jtjkr|j  ¡|j d7_ |j   |j¡|  |d¡WYd}~nnd}~00|t|jƒkræ|j  ¡|j   |j¡| ¡|jrâ|j  |j¡| d¡dS|dkrú|jd|…=dS)Nrrr)r|rrÂrr«r¬rerfrgr/rrÀÚ_remove_writerrär Z_maybe_resume_protocolrÄrærç)r!rrJrrrr«s* "  z$_UnixWritePipeTransport._write_readycCsdSrrrérrrÚ can_write_eofÇsz%_UnixWritePipeTransport.can_write_eofcCs8|jr dSd|_|js4|j |j¡|j |jd¡dSr)rÄrrÀrærÂrÉrçrérrrÚ write_eofÊs z!_UnixWritePipeTransport.write_eofcCs ||_dSrrìrírrrrîÓsz$_UnixWritePipeTransport.set_protocolcCs|jSrrìrérrrrïÖsz$_UnixWritePipeTransport.get_protocolcCs|jSrrðrérrrrñÙsz"_UnixWritePipeTransport.is_closingcCs|jdur|js| ¡dSr)rÁrÄrrérrrr'Üsz_UnixWritePipeTransport.closecCs,|jdur(|d|›t|d|j ¡dSrórôrõrrrr÷ás z_UnixWritePipeTransport.__del__cCs| d¡dSr)ròrérrrÚabortæsz_UnixWritePipeTransport.abortrøcCsNt|tƒr(|j ¡r@tjd||ddn|j ||||jdœ¡| |¡dSrù) rSr@rÀrår rèrþrÃròrÿrrrräés  üz$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j |j¡|j ¡|j |j¡|j |j|¡dSr) rÄrrÀrrÂr/rærÉrçrrrrrò÷s  z_UnixWritePipeTransport._closecCsPz,|j |¡W|j ¡d|_d|_d|_n|j ¡d|_d|_d|_0dSrrrrrrrçÿs ý z-_UnixWritePipeTransport._call_connection_lost)NN)rø)N)r»r¼r½rràr rÌrrrrrîrïrñr'r,r-r÷rräròrçr¾rrr#rr]<s"% #   r]c@seZdZdd„ZdS)rbc Ks¢d}|tjkrt ¡\}}zhtj|f||||d|dœ|¤Ž|_|durh| ¡t| ¡d|d|j_ d}W|durž| ¡| ¡n|durœ| ¡| ¡0dS)NF)rirjrkrlÚuniversal_newlinesrmÚwb)Ú buffering) Ú subprocessÚPIPEr~Ú socketpairÚPopenÚ_procr'rÖÚdetachrj) r!rIrirjrkrlrmrnZstdin_wrrrÚ_start s,  ÿþþ þz_UnixSubprocessTransport._startN)r»r¼r½r!rrrrrb srbc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)rcGs tƒ‚dSr©ÚNotImplementedError©r!rsrHrIrrrrc9s z&AbstractChildWatcher.add_child_handlercCs tƒ‚dSrr"©r!rsrrrÚremove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs tƒ‚dSrr"©r!rÎrrrÚ attach_loopLsz AbstractChildWatcher.attach_loopcCs tƒ‚dSrr"rérrrr'VszAbstractChildWatcher.closecCs tƒ‚dSrr"rérrrr`]szAbstractChildWatcher.is_activecCs tƒ‚dSrr"rérrrÚ __enter__fszAbstractChildWatcher.__enter__cCs tƒ‚dSrr"©r!ÚaÚbÚcrrrÚ__exit__lszAbstractChildWatcher.__exit__N) r»r¼r½rcr&r(r'r`r)r.rrrrr"s   rc@sTeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)rcCsd|_i|_dSr©rÀÚ _callbacksrérrrr}szPidfdChildWatcher.__init__cCs|Srrrérrrr)szPidfdChildWatcher.__enter__cCsdSrr)r!Úexc_typeÚ exc_valueÚ exc_tracebackrrrr.„szPidfdChildWatcher.__exit__cCs|jduo|j ¡Sr©rÀZ is_runningrérrrr`‡szPidfdChildWatcher.is_activecCs| d¡dSr©r(rérrrr'ŠszPidfdChildWatcher.closecCsd|jdur$|dur$|jr$t dt¡|j ¡D] \}}}|j |¡t |¡q.|j  ¡||_dS©NzCA loop is being detached from a child watcher with pending handlers) rÀr0r,r-ÚRuntimeWarningÚvaluesrær|r'r/)r!rÎÚpidfdÚ_rrrr(sý   zPidfdChildWatcher.attach_loopcGsZ|j |¡}|dur*|d||f|j|<n,t |¡}|j ||j|¡|||f|j|<dSrµ)r0rMr|Ú pidfd_openrÀrËÚ_do_wait)r!rsrHrIÚexistingr9rrrrc™s   z#PidfdChildWatcher.add_child_handlercCs~|j |¡\}}}|j |¡zt |d¡\}}Wn"tyTd}t d|¡Yn 0t |ƒ}t  |¡|||g|¢RŽdS)NréÿzJchild process pid %d exit status already read: will report returncode 255) r0ÚpoprÀrær|ÚwaitpidÚChildProcessErrorr rÚ_compute_returncoder')r!rsr9rHrIr:Ústatusrtrrrr<¢s  ý  zPidfdChildWatcher._do_waitcCsFz|j |¡\}}}Wnty*YdS0|j |¡t |¡dS)NFT)r0r?rNrÀrær|r')r!rsr9r:rrrr&µs   z&PidfdChildWatcher.remove_child_handlerN) r»r¼r½rr)r.r`r'r(rcr<r&rrrrrqs   rcCs2t |¡rt |¡ St |¡r*t |¡S|SdSr)r|Ú WIFSIGNALEDÚWTERMSIGÚ WIFEXITEDÚ WEXITSTATUS)rCrrrrB¿s     rBc@sDeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)ÚBaseChildWatchercCsd|_i|_dSrr/rérrrrÏszBaseChildWatcher.__init__cCs| d¡dSrr5rérrrr'ÓszBaseChildWatcher.closecCs|jduo|j ¡Srr4rérrrr`ÖszBaseChildWatcher.is_activecCs tƒ‚dSrr")r!Ú expected_pidrrrÚ _do_waitpidÙszBaseChildWatcher._do_waitpidcCs tƒ‚dSrr"rérrrÚ_do_waitpid_allÜsz BaseChildWatcher._do_waitpid_allcCsf|jdur$|dur$|jr$t dt¡|jdur<|j tj¡||_|durb| tj|j ¡|  ¡dSr6) rÀr0r,r-r7r+r<ÚSIGCHLDrLÚ _sig_chldrKr'rrrr(ßsý zBaseChildWatcher.attach_loopc Cs^z | ¡WnLttfy$‚Yn6tyX}z|j d|dœ¡WYd}~n d}~00dS)Nú$Unknown exception in SIGCHLD handler)rürý)rKrerfrgrÀrþrrrrrMós þzBaseChildWatcher._sig_chldN) r»r¼r½rr'r`rJrKr(rMrrrrrHÍsrHcsLeZdZ‡fdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ‡Z S)rcs|j ¡tƒ ¡dSr)r0r/rr'rér#rrr' s zSafeChildWatcher.closecCs|Srrrérrrr)szSafeChildWatcher.__enter__cCsdSrrr*rrrr.szSafeChildWatcher.__exit__cGs||f|j|<| |¡dSr)r0rJr$rrrrcsz"SafeChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dS©NTF©r0rNr%rrrr&s  z%SafeChildWatcher.remove_child_handlercCst|jƒD]}| |¡q dSr©r*r0rJr%rrrrK$sz SafeChildWatcher._do_waitpid_allcCsÂzt |tj¡\}}Wn&ty<|}d}t d|¡Yn.0|dkrJdSt|ƒ}|j ¡rjt  d||¡z|j   |¡\}}Wn,t yª|j ¡r¦tjd|ddYn0|||g|¢RŽdS)Nr>ú8Unknown child process pid %d, will report returncode 255rú$process %s exited with returncode %sú'Child watcher got an unexpected pid: %rTrú) r|r@ÚWNOHANGrAr rrBrÀrårèr0r?rN)r!rIrsrCrtrHrIrrrrJ)s0 þ  ÿ  ÿ zSafeChildWatcher._do_waitpid) r»r¼r½r'r)r.rcr&rKrJr¾rrr#rrs rcsPeZdZ‡fdd„Z‡fdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z ‡Z S)rcs$tƒ ¡t ¡|_i|_d|_dSrµ)rrÚ threadingÚLockÚ_lockÚ_zombiesÚ_forksrér#rrrVs  zFastChildWatcher.__init__cs"|j ¡|j ¡tƒ ¡dSr)r0r/rYrr'rér#rrr'\s  zFastChildWatcher.closecCs<|j"|jd7_|WdƒS1s.0YdS)Nr)rXrZrérrrr)aszFastChildWatcher.__enter__cCst|jN|jd8_|js"|js2WdƒdSt|jƒ}|j ¡Wdƒn1sZ0Yt d|¡dS)Nrz5Caught subprocesses termination from unknown pids: %s)rXrZrYrBr/r r)r!r+r,r-Zcollateral_victimsrrrr.gs  (þzFastChildWatcher.__exit__c Gs||jPz|j |¡}Wn.tyF||f|j|<YWdƒdS0Wdƒn1s\0Y|||g|¢RŽdSr)rXrYr?rNr0)r!rsrHrIrtrrrrcus 2z"FastChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrOrPr%rrrr&ƒs  z%FastChildWatcher.remove_child_handlerc Cszt dtj¡\}}Wnty*YdS0|dkr8dSt|ƒ}|jŒz|j |¡\}}WnNtyª|j r¢||j |<|j   ¡r’t  d||¡YWdƒqd}Yn0|j   ¡rÄt  d||¡Wdƒn1sØ0Y|durút  d||¡q|||g|¢RŽqdS)Nr5rz,unknown process %s exited with returncode %srSz8Caught subprocess termination from unknown pid: %d -> %d)r|r@rUrArBrXr0r?rNrZrYrÀrår rèr)r!rsrCrtrHrIrrrrKŠs:    þ  ÿ"þz FastChildWatcher._do_waitpid_all) r»r¼r½rr'r)r.rcr&rKr¾rrr#rrLs  rc@sdeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dd„Z dd„Z dS)rcCsi|_d|_dSr)r0Ú_saved_sighandlerrérrrrÈszMultiLoopChildWatcher.__init__cCs |jduSr)r[rérrrr`ÌszMultiLoopChildWatcher.is_activecCsT|j ¡|jdurdSt tj¡}||jkr:t d¡nt tj|j¡d|_dS)Nz+SIGCHLD handler was changed by outside code) r0r/r[r<Ú getsignalrLrMr r)r!rRrrrr'Ïs     zMultiLoopChildWatcher.closecCs|Srrrérrrr)ÛszMultiLoopChildWatcher.__enter__cCsdSrr©r!r1Úexc_valÚexc_tbrrrr.ÞszMultiLoopChildWatcher.__exit__cGs&t ¡}|||f|j|<| |¡dSr)rÚget_running_loopr0rJ)r!rsrHrIrÎrrrrcász'MultiLoopChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrOrPr%rrrr&ès  z*MultiLoopChildWatcher.remove_child_handlercCsN|jdurdSt tj|j¡|_|jdurrRFrTrTrúú%Loop %r that handles pid %r is closedrS)r|r@rUrAr rrBr0r?rNÚ is_closedrårèrr) r!rIrsrCrtZ debug_logrÎrHrIrrrrJs6 þ  ÿ  ÿz!MultiLoopChildWatcher._do_waitpidc CsHz | ¡Wn6ttfy$‚Yn tyBtjdddYn0dS)NrNTrú)rKrerfrgr r)r!rrrrrrM)s   zMultiLoopChildWatcher._sig_chldN)r»r¼r½rr`r'r)r.rcr&r(rKrJrMrrrrrµs %rc@sjeZdZdd„Zdd„Zdd„Zdd„Zd d „Zd d „Ze j fd d„Z dd„Z dd„Z dd„Zdd„ZdS)rcCst d¡|_i|_dSrµ)Ú itertoolsr¢Ú _pid_counterÚ_threadsrérrrr?s zThreadedChildWatcher.__init__cCsdSrrrérrrr`CszThreadedChildWatcher.is_activecCs | ¡dSr)Ú _join_threadsrérrrr'FszThreadedChildWatcher.closecCs.dd„t|j ¡ƒDƒ}|D] }| ¡qdS)NcSsg|]}| ¡r|js|‘qSr)Úis_aliveÚdaemon©Ú.0ÚthreadrrrÚ Ksÿz6ThreadedChildWatcher._join_threads..)r*rer8rß)r!ÚthreadsrkrrrrfIsz"ThreadedChildWatcher._join_threadscCs|Srrrérrrr)PszThreadedChildWatcher.__enter__cCsdSrrr]rrrr.SszThreadedChildWatcher.__exit__cCs6dd„t|j ¡ƒDƒ}|r2||j›dt|ddS)NcSsg|]}| ¡r|‘qSr)rgrirrrrlWsÿz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr%)r*rer8r$r.)r!rörmrrrr÷Vs  þzThreadedChildWatcher.__del__cGsFt ¡}tj|jdt|jƒ›||||fdd}||j|<| ¡dS)Nzwaitpid-T)ÚtargetÚnamerIrh) rr`rVÚThreadrJÚnextrdreÚstart)r!rsrHrIrÎrkrrrrc^s ý z&ThreadedChildWatcher.add_child_handlercCsdSrrr%rrrr&gsz)ThreadedChildWatcher.remove_child_handlercCsdSrrr'rrrr(msz ThreadedChildWatcher.attach_loopcCs˜zt |d¡\}}Wn&ty:|}d}t d|¡Yn 0t|ƒ}| ¡rZt d||¡| ¡rrt d||¡n|j |||g|¢RŽ|j   |¡dS)Nrr>rRrSra) r|r@rAr rrBrårèrbrrrer?)r!rÎrIrHrIrsrCrtrrrrJps$ þ ÿz ThreadedChildWatcher._do_waitpidN)r»r¼r½rr`r'rfr)r.r,r-r÷rcr&r(rJrrrrr2s  rcsDeZdZeZ‡fdd„Zdd„Z‡fdd„Zdd„Zd d „Z ‡Z S) Ú_UnixDefaultEventLoopPolicycstƒ ¡d|_dSr)rrÚ_watcherrér#rrrs z$_UnixDefaultEventLoopPolicy.__init__cCs\tjB|jdur:tƒ|_t ¡t ¡ur:|j |jj ¡Wdƒn1sN0YdSr) rrXrtrrVÚcurrent_threadÚ main_threadr(Ú_localrÀrérrrÚ _init_watcher“s  z)_UnixDefaultEventLoopPolicy._init_watchercs6tƒ |¡|jdur2t ¡t ¡ur2|j |¡dSr)rÚset_event_looprtrVrurvr(r'r#rrryšs   ÿz*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdur| ¡|jSr)rtrxrérrrr_¨s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdur|j ¡||_dSr)rtr')r!rorrrÚset_child_watcher²s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) r»r¼r½rZ _loop_factoryrrxryr_rzr¾rrr#rrs‹s    rs)2rFr›rcr|rÜr<r~rrr(rVr,Úrrrrrrr r r r Úlogr Ú__all__rÚ ImportErrorrZBaseSelectorEventLooprZ ReadTransportrVZ_FlowControlMixinZWriteTransportr]ZBaseSubprocessTransportrbrrrBrHrrrrZBaseDefaultEventLoopPolicyrsrrrrrrÚs`             ÿNON5Ji}Y2