o ?Og"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZ d0fdd ZddZddZdd Zd d Zd d ZddZ e j fddZ ddZ ddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc st| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr0d|j d<|tjkr:d|j d<|tjkrDd|j d<z|jd||||||d| Wn||jj|_|j|jd<|jrt|ttfrx|} n|d} td| |j|j|| dS) NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepidZ_extra get_debug isinstancebytesstrrdebugZ create_task_connect_pipes) selfloopprotocolrr r r r r waiterZextrakwargsZprogram __class__r>/opt/alt/python310/lib64/python3.10/asyncio/base_subprocess.pyr sH            z BaseSubprocessTransport.__init__cCs|jjg}|jr |d|jdur|d|j|jdur*|d|jn|jdur5|dn|d|jd}|durM|d|j|jd}|jd }|durk||urk|d |jn|durx|d |j|dur|d |jd d |S)Nclosedzpid=z returncode=Zrunningz not startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}> ) r.__name__rappendrrrgetpipeformatjoin)r(infor r r rrr/__repr__7s,          z BaseSubprocessTransport.__repr__cKstN)NotImplementedError)r(rr r r r r r,rrr/rTszBaseSubprocessTransport._startcC ||_dSr:r)r(r*rrr/ set_protocolW z$BaseSubprocessTransport.set_protocolcC|jSr:r=r(rrr/ get_protocolZz$BaseSubprocessTransport.get_protocolcCr@r:)rrArrr/ is_closing]rCz"BaseSubprocessTransport.is_closingcCs|jrdSd|_|jD] }|durq |jq |jdurI|jdurK|jdurM|j r6t d|z|j WdSt yHYdSwdSdSdS)NTz$Close running child process: kill %r)rrvaluesr5r rrZpollrr"rZwarningkillProcessLookupError)r(protorrr/r `s(      zBaseSubprocessTransport.closecCs*|js|d|t|d|dSdS)Nzunclosed transport )source)rResourceWarningr )r(Z_warnrrr/__del__{s zBaseSubprocessTransport.__del__cCr@r:)rrArrr/get_pidrCzBaseSubprocessTransport.get_pidcCr@r:)rrArrr/get_returncoderCz&BaseSubprocessTransport.get_returncodecCs||jvr |j|jSdSr:)rr5)r(fdrrr/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdurtdSr:)rrGrArrr/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rPr send_signal)r(signalrrr/rQsz#BaseSubprocessTransport.send_signalcC||jdSr:)rPr terminaterArrr/rTz!BaseSubprocessTransport.terminatecCrSr:)rPrrFrArrr/rFrUzBaseSubprocessTransport.killc s|zrj}j}|jdur"|fdd|jIdH\}}|jd<|jdur<|fdd|jIdH\}}|jd<|jdurV|fdd|jIdH\}}|jd<|j j j D] \}}|j|g|Rqad_ Wn7t t fy}ty}z"|dur|s||WYd}~dSWYd}~dSWYd}~dSd}~ww|dur|s|ddSdSdS)Nc tdS)Nr)WriteSubprocessPipeProtorrArr/ z8BaseSubprocessTransport._connect_pipes..rcrV)NrReadSubprocessPipeProtorrArr/rXrYrcrV)NrrZrrArr/rXrYr)rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r(r+procr)_r5callbackdataexcrrAr/r'sJ          z&BaseSubprocessTransport._connect_pipescGs6|jdur|j||fdS|jj|g|RdSr:)rr3rr\)r(cbrfrrr/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rirZpipe_connection_lost _try_finish)r(rNrgrrr/_pipe_connection_losts z-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rirZpipe_data_received)r(rNrfrrr/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCsp|jr td||||_|jjdur||j_||jj | |j D] }| s2| |q'd|_ dS)Nz%r exited with return code %r)rr"rr8rr returncoderirZprocess_exitedrjrrarb)r(rmr+rrr/_process_exiteds     z'BaseSubprocessTransport._process_exitedcs2|jdur |jS|j}|j||IdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr3)r(r+rrr/_waits     zBaseSubprocessTransport._waitcCsB|jdurdStdd|jDrd|_||jddSdS)Ncss|] }|duo |jVqdSr:) disconnected).0prrr/ sz6BaseSubprocessTransport._try_finish..T)rallrrErri_call_connection_lostrArrr/rjs z#BaseSubprocessTransport._try_finishcCs:z|j|Wd|_d|_d|_dSd|_d|_d|_wr:)rconnection_lostrrr(rgrrr/rus z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr>rBrDr warningswarnrKrLrMrOrPrQrTrFr'rirkrlrnrorjru __classcell__rrr-r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rWcCs||_||_d|_d|_dS)NF)rcrNr5rp)r(rcrNrrr/rs z!WriteSubprocessPipeProto.__init__cCr<r:)r5)r(Z transportrrr/r]r?z(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r.r2rNr5rArrr/r9 s z!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rprcrkrNrwrrr/rv s z(WriteSubprocessPipeProto.connection_lostcC|jjdSr:)rcr pause_writingrArrr/rz&WriteSubprocessPipeProto.pause_writingcCrr:)rcrresume_writingrArrr/rrz'WriteSubprocessPipeProto.resume_writingN) r2rxryrr]r9rvrrrrrr/rWs rWc@seZdZddZdS)r[cCs|j|j|dSr:)rcrlrN)r(rfrrr/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rxryrrrrr/r[s r[)rrrzrrlogrZSubprocessTransportrZ BaseProtocolrWZProtocolr[rrrr/s   v