RhdZdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZeejdZer ej4dZdZGddej<ZGddej@ejBZ"Gdde"Z#Gdde"ejHZ%y#e $rdZ YwxYw#e$rdZYpwxYw)zEvent loop using a selector and related classes. A selector is a "notify-when-ready" multiplexer. For a subclass which also includes support for signal handling, see the unix_events sub-module. )BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggersendmsg SC_IOV_MAXFct |j|}t|j|zS#t$rYywxYwNF)get_keyboolrKeyError)selectorfdeventkeys ./usr/lib/python3.12/asyncio/selector_events.py_test_selector_eventr*sA(r"CJJ&'' s + 77ceZdZdZd3fd Zd3ddddZ d3ddddejejddZ d4d Z fd Z d Z d Z d ZdZdZdddejejfdZdddejejfdZddejejfdZdZdZdZdZdZdZdZdZdZdZd3dZdZd Z d!Z!d"Z"d#Z#d5d$Z$d%Z%d&Z&d'Z'd(Z(d)Z)d*Z*d+Z+d3d,Z,d-Z-d.Z.d/Z/d0Z0d1Z1d2Z2xZ3S)6rzJSelector event loop. See events.EventLoop for API specification. Nct||tj}t j d|j j||_|jtj|_ y)NzUsing selector: %s) super__init__ selectorsDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfrr"s rrzBaseSelectorEventLoop.__init__;sa    002H )8+=+=+F+FG! "668extraservercD|j|t||||||SN)_ensure_fd_no_transport_SelectorSocketTransport)r)sockprotocolwaiterr,r-s r_make_socket_transportz,BaseSelectorEventLoop._make_socket_transportEs* $$T*'dHf(-v7 7r*F) server_sideserver_hostnamer,r-ssl_handshake_timeoutssl_shutdown_timeoutc |j|tj||||||| | } t||| ||| jS)N)r8r9r+)r0r SSLProtocolr1_app_transport) r)rawsockr3 sslcontextr4r6r7r,r-r8r9 ssl_protocols r_make_ssl_transportz)BaseSelectorEventLoop._make_ssl_transportKsW $$W-++ (J "7!5  !w ',V =***r*cD|j|t||||||Sr/)r0_SelectorDatagramTransport)r)r2r3addressr4r,s r_make_datagram_transportz.BaseSelectorEventLoop._make_datagram_transport]s, $$T*)$h*165B Br*c|jr td|jry|jt||j "|j j d|_yy)Nz!Cannot close a running event loop) is_running RuntimeError is_closed_close_self_pipercloser$r)r"s rrJzBaseSelectorEventLoop.closecsa ?? BC C >>      >> % NN "!DN &r*c|j|jj|jjd|_|jjd|_|xj dzc_y)Nr)_remove_reader_ssockfilenorJ_csock _internal_fdsr)s rrIz&BaseSelectorEventLoop._close_self_pipens\ DKK..01     ar*cDtj\|_|_|jj d|jj d|xj dz c_|j |jj|jy)NFr) socket socketpairrNrP setblockingrQ _add_readerrO_read_from_selfrRs rr%z%BaseSelectorEventLoop._make_self_pipevsq#)#4#4#6  T[ & & a ++-t/C/CDr*cyr/r)datas r_process_self_dataz(BaseSelectorEventLoop._process_self_data~s r*c |jjd}|sy|j|1#t$rY=t$rYywxYw)Ni)rNrecvr]InterruptedErrorBlockingIOErrorr[s rrXz%BaseSelectorEventLoop._read_from_selfsV {{''-''-  $ "  s33 A A A c|j}|y |jdy#t$r(|jrt j ddYyYywxYw)Nz3Fail to write a null byte into the self-pipe socketTexc_info)rPsendOSError_debugr r!)r)csocks r_write_to_selfz$BaseSelectorEventLoop._write_to_selfsU   =  , JJu  ,{{ 0&*, ,s#,AAdc f|j|j|j||||||| yr/)rWrO_accept_connection)r)protocol_factoryr2r>r-backlogr8r9s r_start_servingz$BaseSelectorEventLoop._start_servings4 (?(?)4VW.0D Fr*c t|D]w} |j\} } |jrtjd|| | | j dd| i} |j || | ||||} |j| yy#tttf$rYyt$r} | jtjtjtjtj fvry|j#d| t%j&|d|j)|j+|j-t.j0|j2||||||| nYd} ~ dd} ~ wwxYw)Nz#%r got a new connection from %r: %rFpeernamez&socket.accept() out of system resource)message exceptionrT)rangeacceptrhr r!rV_accept_connection2 create_taskrar`ConnectionAbortedErrorrgerrnoEMFILEENFILEENOBUFSENOMEMcall_exception_handlerr TransportSocketrMrO call_laterrACCEPT_RETRY_DELAYrp)r)rnr2r>r-ror8r9_connaddrr,rvexcs rrmz(BaseSelectorEventLoop._accept_connections]w# )A" )![[] d;;LL!F!'t5  '2$T*11$dE:v)+?A  (G# )$%57MN  99u||!& !>> //#K%("("8"8">1 '' 6OOI$@$@$($7$7$4dJ$+-B$8 :  : sABE5E5&CE00E5c Kd}d} |}|j} |r|j|||| d|||| } n|j||| ||} | d{y7#t$r| j d} wxYw#t t f$rt$r?} |jr)d| d} ||| d<| | | d<|j| Yd} ~ yYd} ~ yd} ~ wwxYww)NT)r4r6r,r-r8r9)r4r,r-z3Error on transport creation for incoming connection)rsrtr3 transport) create_futurer@r5 BaseExceptionrJ SystemExitKeyboardInterruptrhr) r)rnrr,r>r-r8r9r3rr4rcontexts rrwz)BaseSelectorEventLoop._accept_connection2s  & 5')H'')F 44(Jv $E&*?)= 5? !77(6!8#     !  -.   5{{N!$ '*2GJ'(+4GK(++G44 5sSCA BA AA CA A==BC0C CCCc*|}t|ts t|j} |j |}|jstd|d|y#ttt f$rt d|dwxYw#t$rYywxYw)NzInvalid file object: zFile descriptor z is used by transport ) isinstanceintrOAttributeError TypeError ValueErrorr( is_closingrGr)r)rrOrs rr0z-BaseSelectorEventLoop._ensure_fd_no_transports&#& KV]]_- &((0I'')"&rf,B m%&&*#Iz: K #8!?@dJ K    sAB$B BBc|jtj|||d} |jj |}|j|j c}\}}|jj ||tjz||f||j|S#t$r1|jj|tj|dfY|SwxYwr/) _check_closedrHandler$rr\modifyr EVENT_READcancelrregister r)rcallbackargshandlermaskreaderwriters rrWz!BaseSelectorEventLoop._add_readers xtT: ..((,C &)ZZ "D"66 NN ! !"dY-A-A&A#)6"2 4!   4 NN # #B (<(<%+TN 4  4B%%6CCc||jry |jj|}|j|jc}\}}|t j z}|s|jj|n|jj||d|f||jyy#t$rYywxYw)NFT) rHr$rrr\rr unregisterrrrr)rrrrrs rrMz$BaseSelectorEventLoop._remove_reader&s >>  ..((,C&)ZZ "D"66 Y))) )D))"-%%b$v?!   B// B;:B;c|jtj|||d} |jj |}|j|j c}\}}|jj ||tjz||f||j|S#t$r1|jj|tjd|fY|SwxYwr/) rrrr$rr\rr EVENT_WRITErrrrs r _add_writerz!BaseSelectorEventLoop._add_writer;s xtT: ..((,C &)ZZ "D"66 NN ! !"dY-B-B&B#)6"2 4!   4 NN # #B (=(=%)6N 4  4rc||jry |jj|}|j|jc}\}}|t j z}|s|jj|n|jj|||df||jyy#t$rYywxYw)Remove a writer callback.FNT) rHr$rrr\rrrrrrrs r_remove_writerz$BaseSelectorEventLoop._remove_writerKs >>  ..((,C&)ZZ "D"66 Y*** *D))"-%%b$?!   rcN|j||j||g|y)zAdd a reader callback.N)r0rWr)rrrs r add_readerz BaseSelectorEventLoop.add_readerb' $$R(X--r*cF|j||j|S)zRemove a reader callback.)r0rMr)rs r remove_readerz#BaseSelectorEventLoop.remove_readerg! $$R(""2&&r*cN|j||j||g|y)zAdd a writer callback..N)r0rrs r add_writerz BaseSelectorEventLoop.add_writerlrr*cF|j||j|S)r)r0rrs r remove_writerz#BaseSelectorEventLoop.remove_writerqrr*cKtj||jr|jdk7r t d |j |S#t tf$rYnwxYw|j}|j}|j||j||j|||}|jtj|j |||d{7Sw)zReceive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by nbytes. rthe socket must be non-blockingrN)r_check_ssl_socketrh gettimeoutrr_rar`rrOr0rW _sock_recvadd_done_callback functoolspartial_sock_read_done)r)r2nfutrrs r sock_recvzBaseSelectorEventLoop.sock_recvvs %%d+ ;;4??,1>? ? 99Q< !12     " [[] $$R(!!"doosD!D    d22Bv F Hyy7AC5AC5A&#C5%A&&B C5/C20C5cL||js|j|yyr/) cancelledrr)rrrs rrz%BaseSelectorEventLoop._sock_read_done% >!1!1!3   r ""4r*c|jry |j|}|j|y#ttf$rYyt t f$rt$r}|j|Yd}~yd}~wwxYwr/) doner_ set_resultrar`rrr set_exception)r)rr2rr\rs rrz BaseSelectorEventLoop._sock_recvsu 88:  !99Q? ? >>#& &!12     " [[] $$R(!!"d&:&:CsK    d22Bv F Hyyrc|jry |j|}|j|y#ttf$rYyt t f$rt$r}|j|Yd}~yd}~wwxYwr/) rrrrar`rrrr)r)rr2rnbytesrs rrz%BaseSelectorEventLoop._sock_recv_intosv 88:  #^^C(F NN6 " !12  -.   #   c " " #rcKtj||jr|jdk7r t d |j |S#t tf$rYnwxYw|j}|j}|j||j||j|||}|jtj|j |||d{7Sw)aReceive a datagram from a datagram socket. The return value is a tuple of (bytes, address) representing the datagram received and the address it came from. The maximum amount of data to be received at once is specified by nbytes. rrrN)rrrhrrrecvfromrar`rrOr0rW_sock_recvfromrrrr)r)r2bufsizerrrs r sock_recvfromz#BaseSelectorEventLoop.sock_recvfroms %%d+ ;;4??,1>? ? ==) )!12     " [[] $$R(!!"d&9&93gN    d22Bv F Hyyrc|jry |j|}|j|y#ttf$rYyt t f$rt$r}|j|Yd}~yd}~wwxYwr/) rrrrar`rrrr)r)rr2rresultrs rrz$BaseSelectorEventLoop._sock_recvfromsv 88:  #]]7+F NN6 " !12  -.   #   c " " #rc Ktj||jr|jdk7r t d|s t |} |j ||S#ttf$rYnwxYw|j}|j}|j||j||j||||}|jtj |j"|||d{7Sw)zReceive data from the socket. The received data is written into *buf* (a writable buffer). The return value is a tuple of (number of bytes written, address). rrrN)rrrhrrlen recvfrom_intorar`rrOr0rW_sock_recvfrom_intorrrr)r)r2rrrrrs rsock_recvfrom_intoz(BaseSelectorEventLoop.sock_recvfrom_intos %%d+ ;;4??,1>? ?XF %%c62 2!12     " [[] $$R(!!"d&>&>T3"(*    d22Bv F Hyys7A DA"!D"A41D3A44B D>D?Dc|jry |j||}|j|y#ttf$rYyt t f$rt$r}|j|Yd}~yd}~wwxYwr/) rrrrar`rrrr)r)rr2rrrrs rrz)BaseSelectorEventLoop._sock_recvfrom_intosz 88:  #''W5F NN6 " !12  -.   #   c " " #s7A:A:A55A:c (Ktj||jr|jdk7r t d |j |}|t|k(ry|j}|j}|j||j||j||t||g}|jt!j"|j$|||d{S#t tf$rd}YwxYw7w)Send data to the socket. The socket must be connected to a remote socket. This method continues to send data from data until either all data has been sent or an error occurs. None is returned on success. On error, an exception is raised, and there is no way to determine how much data, if any, was successfully processed by the receiving end of the connection. rrNr)rrrhrrrfrar`rrrOr0r _sock_sendall memoryviewrrr_sock_write_done)r)r2r\rrrrs r sock_sendallz"BaseSelectorEventLoop.sock_sendalls %%d+ ;;4??,1>? ?  $A D >   " [[] $$R(!!"d&8&8#t",T"2QC9    d33R G Iy !12 A s7ADC9B D4D5D9D  D D  Dc:|jry|d} |j||d}||z }|t|k(r|jdy||d<y#ttf$rYytt f$rt $r}|j|Yd}~yd}~wwxYwNr) rrfrar`rrrrrr)r)rr2viewposstartrrs rrz#BaseSelectorEventLoop._sock_sendall7s 88: A  $uv,'A   CI  NN4 CF !12  -.      c "  sAB(B?BBcKtj||jr|jdk7r t d |j ||S#t tf$rYnwxYw|j}|j}|j||j||j||||}|jtj|j |||d{7Sw)rrrrN)rrrhrrsendtorar`rrOr0r _sock_sendtorrrr)r)r2r\rCrrrs r sock_sendtoz!BaseSelectorEventLoop.sock_sendtoMs %%d+ ;;4??,1>? ? ;;tW- -!12     " [[] $$R(!!"d&7&7dD")+    d33R G Iyys7AC7AC7A'$C7&A''B C71C42C7c|jry |j|d|}|j|y#ttf$rYyt t f$rt$r}|j|Yd}~yd}~wwxYwr) rrrrar`rrrr)r)rr2r\rCrrs rrz"BaseSelectorEventLoop._sock_sendtohsx 88:   D!W-A NN1  !12  -.   #   c " " #s8A; A; A66A;c Ktj||jr|jdk7r t d|j t jk(s-tjrd|j t jk(rG|j||j |j|j|d{}|d\}}}}}|j}|j||| |d{d}S7?7#d}wxYww)zTConnect to a remote socket at address. This method is a coroutine. rr)familytypeprotoloopN)rrrhrrrrTAF_INET _HAS_IPv6AF_INET6_ensure_resolvedrrr _sock_connect)r)r2rCresolvedrrs r sock_connectz"BaseSelectorEventLoop.sock_connectws %%d+ ;;4??,1>? ? ;;&.. (%%$++*H!22 $))4::3H#+1+ Aq!Q  " 3g. 9CCs<CDD2D7D<D=DDDD  Dc|j} |j||jdd}y#ttf$rf|j ||j ||j|||}|jtj|j||Yd}yttf$rt$r}|j|Yd}~d}yd}~wwxYw#d}wxYw)Nr)rOconnectrrar`r0r_sock_connect_cbrrrrrrrr)r)rr2rCrrrs rrz#BaseSelectorEventLoop._sock_connects [[]  LL ! NN4 C# !12 M  ( ( ,%%D))3g?F  ! !!!$"7"7FK MC-.   #   c " "C  # Cs97C"A0C'C"+CCC"CC""C&cL||js|j|yyr/)rrrs rrz&BaseSelectorEventLoop._sock_write_donerr*cv|jry |jtjtj}|dk7rt |d| |j dd}y#ttf$rYd}yttf$rt$r}|j|Yd}~d}yd}~wwxYw#d}wxYw)NrzConnect call failed ) r getsockoptrT SOL_SOCKETSO_ERRORrgrrar`rrrr)r)rr2rCerrrs rrz&BaseSelectorEventLoop._sock_connect_cbs 88:  //&"3"3V__ECaxc%9'#CDD NN4 C !12  C-.   #   c " "C  # Cs<AA*B4*B19B4=B1B,%B4,B11B44B8cKtj||jr|jdk7r t d|j }|j |||d{S7w)aWAccept a connection. The socket must be bound to an address and listening for connections. The return value is a pair (conn, address) where conn is a new socket object usable to send and receive data on the connection, and address is the address bound to the socket on the other end of the connection. rrN)rrrhrrr _sock_accept)r)r2rs r sock_acceptz!BaseSelectorEventLoop.sock_accepts_ %%d+ ;;4??,1>? ?  " #t$yysA'A0)A.*A0c|j} |j\}}|jd|j||fy#tt f$rc|j ||j||j||}|jtj|j||Yyttf$rt$r}|j!|Yd}~yd}~wwxYw)NFr)rOrvrVrrar`r0rWr rrrrrrrr)r)rr2rrrCrrs rr z"BaseSelectorEventLoop._sock_accepts [[] , KKMMD'   U # NND'? + !12 L  ( ( ,%%b$*;*;S$GF  ! !!!$"6"66J L-.   #   c " " #s$A A/C-;C-C((C-cK|j|j=|j}|j|j d{ |j |j |||dd{|j|r|j||j|j<S7h7A#|j|r|j||j|j<wxYww)NF)fallback) r(_sock_fd is_reading pause_reading_make_empty_waiter sock_sendfile_sock_reset_empty_waiterresume_reading)r)transpfileoffsetcountrs r_sendfile_nativez&BaseSelectorEventLoop._sendfile_natives   V__ -**,''))) 7++FLL$5:,<<  & & (%%'06D  V__ - *<  & & (%%'06D  V__ -s<A C: B6C:#B:6B87B::=C:8B::=C77C:cd|D]\}}|j|jc}\}}|tjzr1|/|jr|j |n|j ||tjzsz|}|jr|j||j |yr/) fileobjr\rr _cancelledrM _add_callbackrr)r) event_listrrrrrs r_process_eventsz%BaseSelectorEventLoop._process_eventss# /IC(+ SXX %G%ffi***v/A$$''0&&v.i+++0B$$''0&&v. /r*cb|j|j|jyr/)rMrOrJ)r)r2s r _stop_servingz#BaseSelectorEventLoop._stop_servings DKKM* r*r/NNN)r)4r# __module__ __qualname____doc__rr5rSSL_HANDSHAKE_TIMEOUTSSL_SHUTDOWN_TIMEOUTr@rDrJrIr%r]rXrjrprmrwr0rWrMrrrrrrrrrrrrrrrrrrrrrrrr r rr"r$ __classcell__r"s@rrr5so 97%)$79=+ $t"+"A"A!*!?!? +&CGB " E  ,&#'tS-6-L-L,5,J,JFD#"+"A"A!*!?!? ,)`D"+"A"A!*!?!? -5^&$ * .. ' . ' ,#! *#".#"2#">,6 2.#* ," 7 /r*rceZdZdZdZdfd ZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZddZdZdZdZdZxZS)_SelectorTransportiNct|||tj||jd< |j |jd<d|jvr |j|jd<||_ |j|_ d|_ |j|||_t!j"|_d|_d|_d|_|j|jj-||j.|j<y#t $rd|jd<YwxYw#tj$rd|jd<YwxYw)NrTsocknamerrFr)rrr r_extra getsocknamerg getpeernamerTerrorrrOr_protocol_connected set_protocol_server collectionsdeque_buffer _conn_lost_closing_paused_attachr()r)rr2r3r,r-r"s rrz_SelectorTransport.__init__ s8 % & 6 6t < H +&*&6&6&8DKK # T[[ ( /*.*:*:*< J'   #(  (# "((*   << # LL "*.'+ +&*DKK # + << /*. J' /s#D'!E'EE"E*)E*c|jjg}|j|jdn|jr|jd|jd|j |j |j jst|j j|j tj}|r|jdn|jdt|j j|j tj}|rd}nd}|j}|jd|d |d d jd j|S) Nclosedclosingzfd=z read=pollingz read=idlepollingidlezwrite=z<{}> )r"r#rappendr<r_looprHrr$rrrget_write_buffer_sizeformatjoin)r)inforBstaters r__repr__z_SelectorTransport.__repr__'s$''( ::  KK ! ]] KK " c$--)* :: !$***>*>*@*4::+?+?+/==):N:NPG N+ K(*4::+?+?+/==+4+@+@BG!002G KK'% 7)1= >}}SXXd^,,r*c&|jdyr/) _force_closerRs rabortz_SelectorTransport.abortCs $r*c ||_d|_yNT) _protocolr5)r)r3s rr6z_SelectorTransport.set_protocolFs!#' r*c|jSr/)rSrRs r get_protocolz_SelectorTransport.get_protocolJs ~~r*c|jSr/)r<rRs rrz_SelectorTransport.is_closingMs }}r*cB|j xr |j Sr/)rr=rRs rrz_SelectorTransport.is_readingPs??$$9T\\)99r*c|jsyd|_|jj|j|jj rt jd|yy)NTz%r pauses reading)rr=rGrMr get_debugr r!rRs rrz _SelectorTransport.pause_readingSsP   !!$--0 ::   ! LL,d 3 "r*c|js |jsyd|_|j|j|j|j j rtjd|yy)NFz%r resumes reading) r<r=rWr _read_readyrGrYr r!rRs rrz!_SelectorTransport.resume_reading[sW ==   (8(89 ::   ! LL-t 4 "r*cP|jryd|_|jj|j|jsa|xj dz c_|jj |j|jj|jdyyNTr) r<rGrMrr:r;r call_soon_call_connection_lostrRs rrJz_SelectorTransport.closecss ==   !!$--0|| OOq O JJ % %dmm 4 JJ !;!;T Br*cv|j-|d|t||jjyy)Nzunclosed transport )source)rResourceWarningrJ)r)_warns r__del__z_SelectorTransport.__del__ms5 :: ! 'x0/$ O JJ    "r*ct|tr4|jjrDt j d||dn*|jj ||||jd|j|y)Nz%r: %sTrd)rsrtrr3) rrgrGrYr r!rrSrO)r)rrss r _fatal_errorz_SelectorTransport._fatal_errorrse c7 #zz##% XtWtD JJ - -" ! NN /  #r*c|jry|jr?|jj|jj |j |j s,d|_|jj|j |xjdz c_|jj|j|yr]) r;r:clearrGrrr<rMr^r_)r)rs rrOz_SelectorTransport._force_closes ??  << LL   JJ % %dmm 4}} DM JJ % %dmm 4 1 T77=r*c |jr|jj||jj d|_d|_d|_|j }||jd|_yy#|jj d|_d|_d|_|j }||jd|_wwxYwr/)r5rSconnection_lostrrJrGr7_detach)r)rr-s rr_z(_SelectorTransport._call_connection_losts $''..s3 JJ   DJ!DNDJ\\F! # " JJ   DJ!DNDJ\\F! # "s 'A??ACcHttt|jSr/)summaprr:rRs rrHz(_SelectorTransport.get_write_buffer_sizes3sDLL)**r*cb|jsy|jj||g|yr/)rrGrWrs rrWz_SelectorTransport._add_readers*  r83d3r*)NN)zFatal error on transport)r#r&r'max_sizerrrMrPr6rUrrrrrJwarningswarnrdrfrOr_rHrWr+r,s@rr.r.skH E/8-8 (:45C%MM  > $+4r*r.ceZdZdZej j Z dfd ZfdZ dZ dZ dZ dZ d Zd Zd Zd ed dfdZdZdZdZdZfdZdZdZfdZxZS)r1TNcd|_t| |||||d|_d|_t r|j |_n|j|_tj|j|jj|jj||jj|j |j"|j$|,|jjt&j(|dyyr)_read_ready_cbrr_eof _empty_waiter _HAS_SENDMSG_write_sendmsg _write_ready _write_sendr _set_nodelayrrGr^rSconnection_maderWrr[r_set_result_unless_cancelled)r)rr2r3r4r,r-r"s rrz!_SelectorSocketTransport.__init__s# tXuf= !  $ 3 3D  $ 0 0D    , T^^;;TB T--!]]D,<,< >   JJ !E!E!' / r*ct|tjr|j|_n|j |_t ||yr/)rr BufferedProtocol_read_ready__get_bufferru_read_ready__data_receivedrr6)r)r3r"s rr6z%_SelectorSocketTransport.set_protocols< h : : ;"&">">D "&"A"AD  X&r*c$|jyr/)rurRs rr[z$_SelectorSocketTransport._read_readys r*c|jry |jjd}t|s t d |jj|}|s|jy |jj|y#t t f$rt$r}|j|dYd}~yd}~wwxYw#ttf$rYyt t f$rt$r}|j|dYd}~yd}~wwxYw#t t f$rt$r}|j|dYd}~yd}~wwxYw)Nz%get_buffer() returned an empty bufferz/Fatal error: protocol.get_buffer() call failed.$Fatal read error on socket transportz3Fatal error: protocol.buffer_updated() call failed.)r;rS get_bufferrrGrrrrfrrrar`_read_ready__on_eofbuffer_updated)r)rrrs rrz0_SelectorSocketTransport._read_ready__get_buffersC ??  ..++B/Cs8"#JKK ZZ))#.F  $ $ &  L NN ) )& 1--.      F H   !12  -.      c#I J  -.   L   J L L LsM1B C1D C%B<<CDD,DD D?#D::D?c|jry |jj|j}|s|jy |jj|y#tt f$rYyt tf$rt$r}|j|dYd}~yd}~wwxYw#t tf$rt$r}|j|dYd}~yd}~wwxYw)Nrz2Fatal error: protocol.data_received() call failed.) r;rr_rprar`rrrrfrrS data_received)r)r\rs rrz3_SelectorSocketTransport._read_ready__data_receiveds ??  ::??4==1D  $ $ &  K NN ( ( . !12  -.      c#I J  -.   K   I K K Ks5%A$B+$B(5B( B##B(+CCCcx|jjrtjd| |jj }|r&|jj|jy|jy#t tf$rt$r}|j|dYd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rGrYr r!rS eof_receivedrrrrfrMrrJ)r) keep_openrs rrz,_SelectorSocketTransport._read_ready__on_eof s ::   ! LL*D 1 335I  JJ % %dmm 4 JJL-.      H J  sBB9B44B9c<t|tttfs!t dt |j |jr td|j td|sy|jrH|jtjk\rtjd|xjdz c_ y|js] |j j#|}t||d}|sy|j0j3|j4|j6|jj9||j;y#t$t&f$rYmt(t*f$rt,$r}|j/|dYd}~yd}~wwxYw)N/data argument must be a bytes-like object, not z%Cannot call write() after write_eof()z(unable to write; sendfile is in progresssocket.send() raised exception.r%Fatal write error on socket transport)rbytes bytearrayrrrr#rvrGrwr;r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningr:rrfrar`rrrrfrGrrrzrF_maybe_pause_protocol)r)r\rrs rwritez_SelectorSocketTransport.writes_$ : >?##':#6#6"9;< < 99FG G    )IJ J  ??)"M"MM@A OOq O || JJOOD)"$'+ JJ " "4==$2C2C D D! ""$!$%56  12   !!#'NO sEF(F?FFcJtj|jtSr/) itertoolsislicer:rrRs r_get_sendmsg_bufferz,_SelectorSocketTransport._get_sendmsg_bufferFs j99r*c|jsJd|jry |jj|j }|j ||j |js|jj|j|j|jjd|jr|jdy|jr*|jjt j"yyy#t$t&f$rYyt(t*f$rt,$r}|jj|j|jj/|j1|d|j |jj3|Yd}~yYd}~yd}~wwxYwNzData should not be emptyr)r:r;rrr_adjust_leftover_buffer_maybe_resume_protocolrGrrrwrr<r_rvshutdownrTSHUT_WRrar`rrrrhrfr)r)rrs rryz'_SelectorSocketTransport._write_sendmsgIsh||777| ??  8ZZ''(@(@(BCF  ( ( 0  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6s:DG +G A8GG rreturnc|j}|r?|j}t|}||kr||z}n|j||dy|r>yyr/)r:popleftr appendleft)r)rbufferbb_lens rrz0_SelectorSocketTransport._adjust_leftover_bufferesO AFE%!!!FG*-r*c|jsJd|jry |jj}|jj |}|t |k7r|jj ||d|j|js|jj|j|j|jjd|jr|jdy|jr*|jj!t"j$yyy#t&t(f$rYyt*t,f$rt.$r}|jj|j|jj1|j3|d|j |jj5|Yd}~yYd}~yd}~wwxYwr)r:r;rrrfrrrrGrrrwrr<r_rvrrTrrar`rrrrhrfr)r)rrrs rr{z$_SelectorSocketTransport._write_sendps||777| ??  8\\))+F 'ACK ''qr 3  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6sA!EG0G0)A8G++G0c|js |jryd|_|js*|jj t j yyrR)r<rvr:rrrTrrRs r write_eofz"_SelectorSocketTransport.write_eofs; ==DII  || JJ   /r*c|jr td|j td|sy|jj |Dcgc] }t |c}|j |jrA|jj|j|j |jyycc}w)Nz*Cannot call writelines() after write_eof()z-unable to writelines; sendfile is in progress) rvrGrwr:extendrrzrGrrr)r) list_of_datar\s r writelinesz#_SelectorSocketTransport.writeliness 99KL L    )NO O  ,G$Z-GH  << JJ " "4==$2C2C D  & & ( Hs CcyrRrZrRs r can_write_eofz&_SelectorSocketTransport.can_write_eofsr*ct|||j%|jjt dyy)NzConnection is closed by peer)rr_rwrConnectionError)r)rr"s rr_z._SelectorSocketTransport._call_connection_losts? %c*    )    , , >? A *r*c|j td|jj|_|js|jj d|jS)NzEmpty waiter is already set)rwrGrGrr:rrRs rrz+_SelectorSocketTransport._make_empty_waitersV    )<= =!ZZ557||    ) )$ /!!!r*cd|_yr/)rwrRs rrz,_SelectorSocketTransport._reset_empty_waiters !r*c>d|_d|_t| yr/)rurzrrJrKs rrJz_SelectorSocketTransport.closes"   r*r%)r#r&r'_start_tls_compatibler _SendfileMode TRY_NATIVE_sendfile_compatiblerr6r[rrrrrryrrr{rrrr_rrrJr+r,s@rr1r1s $22==48$(/2'#LJK2*%%N:88 c d 8>0 )A ""r*r1cVeZdZejZ dfd ZdZdZddZ dZ xZ S)rBcxt|||||||_d|_|jj |j j||jj |j|j|j|,|jj tj|dyyr) rr_address _buffer_sizerGr^rSr}rWrr[rr~)r)rr2r3rCr4r,r"s rrz#_SelectorDatagramTransport.__init__s tXu5  T^^;;TB T--!]]D,<,< >   JJ !E!E!' / r*c|jSr/)rrRs rrHz0_SelectorDatagramTransport.get_write_buffer_sizes   r*c|jry |jj|j\}}|jj ||y#t tf$rYyt$r%}|jj|Yd}~yd}~wttf$rt$r}|j|dYd}~yd}~wwxYw)Nz&Fatal read error on datagram transport)r;rrrprSdatagram_receivedrar`rgerror_receivedrrrrfr)r\rrs rr[z&_SelectorDatagramTransport._read_readys ??  9,,T]];JD$ NN , ,T4 8 !12   / NN ) )# . .-.   M   c#K L L Ms)(AC%C-B  C(B??CcZt|tttfs!t dt |j |sy|jr4|d|jfvrtd|j|j}|jrT|jrH|jtjk\rtjd|xjdz c_ y|jsI |jdr|j j#|y|j j%||y|jjAt||f|xjBtE|z c_!|jGy#t&t(f$r3|j*j-|j.|j0Yt2$r%}|j4j7|Yd}~yd}~wt8t:f$rt<$r}|j?|dYd}~yd}~wwxYw)Nrz!Invalid address: must be None or rrrr'Fatal write error on datagram transport)$rrrrrrr#rrr;rrr rr:r1rrfrrar`rGrr _sendto_readyrgrSrrrrrfrFrrrrs rrz!_SelectorDatagramTransport.sendtos$ : >?##':#6#6"9;< <  ==D$--00 7 GII==D ??t}})"M"MM@A OOq O || ;;z*JJOOD)JJ%%dD1 U4[$/0 SY& ""$$%56 J &&t}}d6H6HI --c2 12   !!BD s0-*F F ?H* H*G33H*H%%H*cX|jr|jj\}}|xjt|zc_ |jdr|j j |n|j j|||jr|j%|jsD|j&j)|j*|j,r|j/dyyy#ttf$r>|jj||f|xjt|z c_Yt$r%}|jj|Yd}~yd}~wttf$rt $r}|j#|dYd}~yd}~wwxYw)Nrrr)r:rrrr1rrfrrar`rrgrSrrrrrfrrGrrr<r_rs rrz(_SelectorDatagramTransport._sendto_readysQll--/JD$   T *  ;;z*JJOOD)JJ%%dD1ll, ##%|| JJ % %dmm 4}}**40$%56  ''t 5!!SY.! --c2 12   !!BD s, AC>>A F) F)E22F) F$$F)r%r/) r#r&r'r8r9_buffer_factoryrrHr[rrr+r,s@rrBrBs.!''O59$( /!9 *%X1r*rB)&r(__all__r8rzrrosrrTrqr&ssl ImportErrorrrrrr r r r logr hasattrrxsysconfrrgr BaseEventLoopr_FlowControlMixin Transportr.r1DatagramTransportrBrZr*rrs #   v}}i0 RZZ - (I K55I X_455#--_4DX1Xvl1!3Z5Q5Ql1U% C$  s#C&:C3&C0/C03C=<C=