a 7êdg4Êã@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/local/lib/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È|  ¡tjd|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)Úloop)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|ržrrŽÚS_ISFIFOrÚS_ISCHRr?Ú set_blockingÚ call_soonÚconnection_madeÚ _add_readerÚ _read_readyr Ú_set_result_unless_cancelled)r!rŒrXrYrZr[Ú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|ržrrŽrÈrÇrr?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|Z pidfd_openrÁrÌÚ_do_wait)r!rsrHrIZexistingr9rrrrc™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)rArrrr@¿s     r@c@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_chldrIr'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ý)rIrerfrgrÁrþrrrrrKós þzBaseChildWatcher._sig_chldN) r¼r½r¾rr'r`rHrIr(rKrrrrrFÍsrFcsLeZdZ‡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)r0rHr$rrrrcsz"SafeChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dS©NTF©r0rNr%rrrr&s  z%SafeChildWatcher.remove_child_handlercCst|jƒD]}| |¡q dSr©r*r0rHr%rrrrI$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>ÚWNOHANGr?r rr@rÁrårèr0r=rN)r!rGrsrArtrHrIrrrrH)s0 þ  ÿ  ÿ zSafeChildWatcher._do_waitpid) r¼r½r¾r'r)r.rcr&rIrHr¿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/rWrr'rér#rrr'\s  zFastChildWatcher.closecCs<|j"|jd7_|WdƒS1s.0YdS)Nr)rVrXrérrrr)aszFastChildWatcher.__enter__cCst|jN|jd8_|js"|js2WdƒdSt|jƒ}|j ¡Wdƒn1sZ0Yt d|¡dS)Nrz5Caught subprocesses termination from unknown pids: %s)rVrXrWrBr/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)rVrWr=rNr0)r!rsrHrIrtrrrrcus 2z"FastChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrMrNr%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 %srQz8Caught subprocess termination from unknown pid: %d -> %d)r|r>rSr?r@rVr0r=rNrXrWrÁrår rèr)r!rsrArtrHrIrrrrIŠs:    þ  ÿ"þz FastChildWatcher._do_waitpid_all) r¼r½r¾rr'r)r.rcr&rIr¿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)rYrérrrr`ÌszMultiLoopChildWatcher.is_activecCsT|j ¡|jdurdSt tj¡}||jkr:t d¡nt tj|j¡d|_dS)Nz+SIGCHLD handler was changed by outside code) r0r/rYr<Ú getsignalrJrKr 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_loopr0rH)r!rsrHrIrŒrrrrcász'MultiLoopChildWatcher.add_child_handlercCs(z|j|=WdSty"YdS0dSrMrNr%rrrr&ès  z*MultiLoopChildWatcher.remove_child_handlercCsN|jdurdSt tj|j¡|_|jdurrSr?r rr@r0r=rNÚ is_closedrårèrr) r!rGrsrArtZ debug_logrŒrHrIrrrrHs6 þ  ÿ  ÿz!MultiLoopChildWatcher._do_waitpidc CsHz | ¡Wn6ttfy$‚Yn tyBtjdddYn0dS)NrLTrú)rIrerfrgr r)r!rrrrrrK)s   zMultiLoopChildWatcher._sig_chldN)r¼r½r¾rr`r'r)r.rcr&r(rIrHrKrrrrrµ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*rcr8rß)r!ÚthreadsrirrrrdIsz"ThreadedChildWatcher._join_threadscCs|Srrrérrrr)PszThreadedChildWatcher.__enter__cCsdSrrr[rrrr.SszThreadedChildWatcher.__exit__cCs6dd„t|j ¡ƒDƒ}|r2||j›dt|ddS)NcSsg|]}| ¡r|‘qSr)rergrrrrjWsÿz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr%)r*rcr8r$r.)r!rörkrrrr÷Vs  þzThreadedChildWatcher.__del__cGsFt ¡}tj|jdt|jƒ›||||fdd}||j|<| ¡dS)Nzwaitpid-T)ÚtargetÚnamerIrf) rr^rTÚThreadrHÚnextrbrcÚstart)r!rsrHrIrŒrirrrrc^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<rPrQr_) r|r>r?r rr@rårèr`rrrcr=)r!rŒrGrHrIrsrArtrrrrHps$ þ ÿz ThreadedChildWatcher._do_waitpidN)r¼r½r¾rr`r'rdr)r.r,r-r÷rcr&r(rHrrrrr2s  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) rrVrrrrTÚcurrent_threadÚ main_threadr(Ú_localrÁrérrrÚ _init_watcher“s  z)_UnixDefaultEventLoopPolicy._init_watchercs6tƒ |¡|jdur2t ¡t ¡ur2|j |¡dSr)rÚset_event_looprrrTrsrtr(r'r#rrrwšs   ÿz*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdur| ¡|jSr)rrrvrérrrr_¨s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdur|j ¡||_dSr)rrr')r!rorrrÚset_child_watcher²s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) r¼r½r¾rZ _loop_factoryrrvrwr_rxr¿rrr#rrq‹s    rq)2rFrœrar|rÜr<r~rŽrr(rTr,Úrrrrrrr r r r Úlogr Ú__all__rÚ ImportErrorrZBaseSelectorEventLooprZ ReadTransportrVZ_FlowControlMixinZWriteTransportr]ZBaseSubprocessTransportrbrrr@rFrrrrZBaseDefaultEventLoopPolicyrqrrrrrrÚs`             ÿNON5Ji}Y2