f0>dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlm Z ddlm!Z!ddl"m#Z#dZ$dZ%dZ&e'e dZ(dZ)dZ*dZ+dZ,d&dZ-d'dZ.dZ/e'e drdZ0ndZ0dZ1Gd d!ejdZ3Gd"d#ejhZ5Gd$d%ejlZ7y#e$rdZYwxYw)(aBase implementation of event loop. The event loop can be broken up into a multiplexer (the part responsible for notifying us of I/O events) and the event loop proper, which wraps a multiplexer with functionality for scheduling callbacks, immediately or at a given time in the future. Whenever a public API takes a callback, subsequent positional arguments will be passed to the callback if/when it is called. This avoids the proliferation of trivial lambdas implementing closures. Keyword arguments for the callback are not supported; this is a conscious design decision, leaving the door open for keyword arguments to modify the meaning of the API call itself. N) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks)timeouts) transports)trsock)logger) BaseEventLoopServerdg?AF_INET6iQc|j}tt|ddtjrt |j St|S)N__self__) _callback isinstancegetattrr Taskreprrstr)handlecbs */usr/lib/python3.12/asyncio/base_events.py_format_handler Hs=   B'"j$/<BKK  6{ch|tjk(ry|tjk(ryt|S)Nzz) subprocessPIPESTDOUTr)fds r _format_piper'Qs+ Z__ z  Bxr!cttds td |jtjtj dy#t $r tdwxYw)N SO_REUSEPORTz)reuse_port not supported by socket modulerzTreuse_port not supported by socket module, SO_REUSEPORT defined but not implemented.)hasattrsocket ValueError setsockopt SOL_SOCKETr)OSErrorsocks r_set_reuseportr2Zs` 6> *DEE J OOF--v/B/BA F JIJ J Js /A A"c Pttdsy|dtjtjhvs|y|tjk(rtj}n%|tj k(rtj}ny|d}n,>?? L v!!!"" "" """ | D% TS[ D# 42: t9D!!!~~  JJv 'h${{6" d{     R &R6??24T47,KKK4T4L88  ;:&  2   s*7 F;9F7FFF F%$F%ctj}|D]$}|d}||vrg||<||j|&t|j }g}|dkDr%|j |dd|dz |dd|dz =|j dt jjt j|D|S)z-Interleave list of addrinfo tuples by family.rrNc3$K|]}|| ywN).0as r z(_interleave_addrinfos..s ] s) collections OrderedDictrBlistvaluesextend itertoolschain from_iterable zip_longest) addrinfosfirst_address_family_countaddrinfos_by_familyaddrrFaddrinfos_lists reordereds r_interleave_addrinfosrds&1131a , ,*,  'F#**40 1 .5578OI!A%+,K-G!-KLM A > :Q >> ? ??00  ! !? 3  r!c|js'|j}t|ttfryt j |jyrP) cancelled exceptionr SystemExitKeyboardInterruptr _get_loopstop)futexcs r_run_until_complete_cbrnsB ==?mmo cJ(9: ;  c!r! TCP_NODELAYc4|jtjtjhvrl|jtj k(rN|j tjk(r0|jtjtjdyyyyNr) rFr+r@rrGr:rHr8r-ror0s r _set_nodelayrrsj KKFNNFOO< < V/// f000 OOF..0B0BA F10 =r!cyrPrQr0s rrrrrs r!c\t&t|tjr tdyy)Nz"Socket cannot be of type SSLSocket)sslr SSLSocketr>r0s r_check_ssl_socketrws' :dCMM:<==;r!cBeZdZdZdZdZdZdZdZdZ dZ d Z y ) _SendfileFallbackProtocolct|tjs td||_|j |_|j|_|j|_ |j|j||jr*|jjj|_yd|_y)Nz.transport should be _FlowControlMixin instance)rr_FlowControlMixinr> _transport get_protocol_proto is_reading_should_resume_reading_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransps r__init__z"_SendfileFallbackProtocol.__init__s&*">">?LM M ))+ &,&7&7&9#&,&=&=#D!  & &$(OO$9$9$G$G$ID !$(D !r!cK|jjr td|j}|y|d{y7w)NzConnection closed by peer)r| is_closingConnectionErrorr)rrls rdrainz_SendfileFallbackProtocol.drains< ?? % % '!"=> >## ;  s:AAActd)Nz?Invalid state: connection should have been established already. RuntimeError)r transports rconnection_madez)_SendfileFallbackProtocol.connection_madesNO Or!c|jB|%|jjtdn|jj||jj |y)NzConnection is closed by peer)r set_exceptionrr~connection_lost)rrms rrz)_SendfileFallbackProtocol.connection_losts[  ,{%%33#$BCE%%33C8 ##C(r!cp|jy|jjj|_yrP)rr|rrrs r pause_writingz'_SendfileFallbackProtocol.pause_writings,  ,  $ 5 5 C C Er!cb|jy|jjdd|_y)NF)r set_resultrs rresume_writingz(_SendfileFallbackProtocol.resume_writings-  (  ((/ $r!ctdNz'Invalid state: reading should be pausedr)rdatas r data_receivedz'_SendfileFallbackProtocol.data_receivedDEEr!ctdrrrs r eof_receivedz&_SendfileFallbackProtocol.eof_receivedrr!c<K|jj|j|jr|jj |j |j j |jr|jjyywrP) r|rr~rresume_readingrcancelrrrs rrestorez!_SendfileFallbackProtocol.restoress $$T[[1  & & OO * * ,  ,  ! ! ( ( *  & & KK & & ( 'sBBN) __name__ __module__ __qualname__rrrrrrrrrrQr!rryrys3 )O )F % FF )r!rycheZdZ ddZdZdZdZdZdZdZ d Z e d Z d Z d Zd ZdZy)rNc||_||_d|_g|_||_||_||_||_||_d|_ d|_ y)NrF) r_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_ssl_shutdown_timeout_serving_serving_forever_fut)rloopsocketsprotocol_factory ssl_contextbacklogssl_handshake_timeoutssl_shutdown_timeouts rrzServer.__init__sU   !1 '&;#%9" $(!r!cPd|jjd|jdS)N) __class__rrrs r__repr__zServer.__repr__$s'4>>**+9T\\4DAFFr!cJ|jJ|xjdz c_yrq)rrrs r_attachzServer._attach's#}}((( ar!c|jdkDsJ|xjdzc_|jdk(r|j|jyyy)Nrr)rr_wakeuprs r_detachzServer._detach+sO!!A%%% a    "t}}'< LLN(= "r!c||j}d|_|D]$}|jr|jd&yrP)rdoner)rwaiterswaiters rrzServer._wakeup1s8--  (F;;=!!$' (r!c *|jryd|_|jD]p}|j|j|jj |j ||j||j|j|jry)NT) rrlistenrr_start_servingrrrr)rr1s rrzServer._start_serving8su ==  MM ,D KK & JJ % %&&d.?.?dmmT%@%@** , ,r!c|jSrP)rrs rget_loopzServer.get_loopCs zzr!c|jSrP)rrs r is_servingzServer.is_servingFs }}r!cT|jytd|jDS)NrQc3FK|]}tj|ywrP)rTransportSocket)rRss rrTz!Server.sockets..MsF1V++A.Fs!)rtuplers rrzServer.socketsIs$ == F FFFr!cP|j}|yd|_|D]}|jj|d|_|j;|jj s!|jj d|_|jdk(r|jyy)NFr) rr _stop_servingrrrrrr)rrr1s rclosez Server.closeOs-- ?   +D JJ $ $T * +  % % 1--224  % % , , .(,D %    " LLN #r!cjK|jtjdd{y7w)Nr)rr sleeprs r start_servingzServer.start_servingbs% kk!ns )313cK|jtd|d|jtd|d|j|jj |_ |jd{ d|_y7 #t j$r1 |j|jd{7#xYwwxYw#d|_wxYww)Nzserver z, is already being awaited on serve_forever()z is closed) rrrrrrrCancelledErrorr wait_closedrs r serve_foreverzServer.serve_foreverhs  $ $ 0$!MNP P ==  ;< < $(JJ$<$<$>! -++ + +)-D % ,((   &&(((  )-D %s`A&C)B8B9B>CBC #C?CCC CC  C CCcK|jy|jj}|jj||d{y7w)aWait until server is closed and all connections are dropped. - If the server is not closed, wait. - If it is closed, but there are still active connections, wait. Anyone waiting here will be unblocked once both conditions (server is closed and all connections have been dropped) have become true, in either order. Historical note: In 3.11 and before, this was broken, returning immediately if the server was already closed, even if there were still active connections. An attempted fix in 3.12.0 was still broken, returning immediately if the server was still open and there were no active connections. Hopefully in 3.12.1 we have it right. N)rrrrB)rrs rrzServer.wait_closed}s@* == ))+ V$ sAA A ArP)rrrrrrrrrrrpropertyrrrrrrQr!rrrs[>B )G  ( ,GG & -*r!rceZdZdZdZdZddddZdZdZd\ddd d Z d\d dddddd d dZ d]dZ d^dZ d^dZ d\dZdZdZdZdZdZdZdZd\dZdZdZdZdZdZd Zd!Zej>fd"Z d#Z!d$Z"dd%d&Z#dd%d'Z$dd%d(Z%d)Z&d*Z'd+Z(dd%d,Z)d-Z*d.Z+d/Z,d0d0d0d0d1d2Z-d_d3Z.d`d d4d5Z/d6Z0d7Z1d8Z2d\d9Z3 d^dd0d0d0dddddddd d: d;Z4 dad<Z5d`d d4d=Z6d>Z7d?Z8d dddd@dAZ9 d^d0d0d0ddddBdCZ:d0e;jxd0d0d1dDZ=dEZ> d^e;j~e;jddFdddddd dG dHZAddddIdJZBdKZCdLZDdMZEeFjeFjeFjd d d0ddddN dOZHeFjeFjeFjd d d0ddddN dPZIdQZJdRZKdSZLdTZMdUZNdVZOdWZPdXZQdYZRdZZSd[ZTy)brcd|_d|_d|_tj|_g|_d|_d|_d|_ tjdj|_ d|_|jt!j"d|_d|_d|_d|_d|_t/j0|_d|_d|_y)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrUdeque_ready _scheduled_default_executor _internal_fds _thread_idtimeget_clock_info resolution_clock_resolution_exception_handler set_debugr_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefWeakSet _asyncgens_asyncgens_shutdown_called_executor_shutdown_calledrs rrzBaseEventLoop.__init__s&'# !'') !%!%!4!4[!A!L!L"& z0023'*##!27/6:3"//+*/').&r!c d|jjd|jd|jd|j d S)Nrz running=z closed=z debug=r)rr is_running is_closed get_debugrs rrzBaseEventLoop.__repr__sP''( $//2C1DEnn&'wt~~/?.@ C r!c.tj|S)z,Create a Future object attached to the loop.r)rFuturers rrzBaseEventLoop.create_futures~~4((r!N)namecontextc$|j|j4tj||||}|jr |jd=|S||j||}n|j|||}tj |||S)zDSchedule a coroutine object. Return a task object. )rrr r ) _check_closedrr r_source_traceback_set_task_name)rcororr tasks r create_taskzBaseEventLoop.create_tasks     %::dD'JD%%**2. ))$5))$g)F  t , r!cB|t|s td||_y)awSet a task factory that will be used by loop.create_task(). If factory is None the default task factory will be set. If factory is a callable, it should have a signature matching '(loop, coro)', where 'loop' will be a reference to the active event loop, 'coro' will be a coroutine object. The callable must return a Future. Nz'task factory must be a callable or None)callabler>r)rfactorys rset_task_factoryzBaseEventLoop.set_task_factorys%  x'8EF F$r!c|jS)z3B#4B>7B)=B%>B) B> B'B>D #B>%B)'B>)B;/B2 0B;7B>>ADD DD cZ |jjd|js"|jtj |dyy#t $rP}|js6|js!|j|j|Yd}~yYd}~yYd}~yd}~wwxYw)NTrd) rrnrrDr_set_result_unless_cancelledrYrfr)rroexs rrhzBaseEventLoop._do_shutdownbs D  " " + + + 6>>#))'*N*N*0$8$ D>>#F,<,<,>))&*>*>CC-?# DsA A B* ?? CD D  # # % 1IK K 2r!c|j|j|j|jt j } t j|_t j|j|jtj| |j|jrn d|_d|_tjd|jdt j|y#d|_d|_tjd|jdt j|wxYw)zRun until stop() is called.) firstiter finalizerFN)r rw_set_coroutine_origin_tracking_debugsysget_asyncgen_hooksrf get_identrset_asyncgen_hooksrPrHr_set_running_loop _run_oncer)rold_agen_hookss r run_foreverzBaseEventLoop.run_foreverss   ++DKK8//1 4'113DO  " "T-J-J-1-J-J L  $ $T * >>"DN"DO  $ $T *  / / 6  " "N 3 #DN"DO  $ $T *  / / 6  " "N 3sA8DAEc |j|jtj| }t j ||}|rd|_|jt |j |jt|js td|jS#|r0|jr |js|jxYw#|jtwxYw)a\Run until the Future is done. If the argument is a coroutine, it is wrapped in a Task. WARNING: It would be disastrous to call run_until_complete() with the same coroutine twice -- it would wrap it in two different Tasks and that can't be good. Return the Future's result, or raise its exception. rFz+Event loop stopped before Future completed.)r rwrisfuturer ensure_future_log_destroy_pendingadd_done_callbackrnrrrfrgremove_done_callbackrr^)rronew_tasks rrun_until_completez BaseEventLoop.run_until_completes  ''//$$V$7 +0F '  !78 @      ' '(> ?{{}LM M}} FKKM&2B2B2D  "   ' '(> ?s-B>>5C33C66D cd|_y)zStop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. TN)rrs rrkzBaseEventLoop.stops r!cl|jr td|jry|jrt j d|d|_|j j|jjd|_ |j}|d|_ |jdyy)zClose the event loop. This clears the queues and shuts down the executor, but does not wait for the executor to finish. The event loop must not be running. z!Cannot close a running event loopNzClose %rTFrd) rrrr|rdebugrrVrrrrnrexecutors rrzBaseEventLoop.closes ?? BC C <<  ;; LLT *   )-&))  %)D "   5  ) r!c|jS)z*Returns True if the event loop was closed.)rrs rrzBaseEventLoop.is_closeds ||r!c|js4|d|t||js|jyyy)Nzunclosed event loop rJ)rrNrr)r_warns r__del__zBaseEventLoop.__del__s=~~ (1?4 P??$ % r!c|jduS)z*Returns True if the event loop is running.N)rrs rrzBaseEventLoop.is_runningst+,r!c*tjS)zReturn the time according to the event loop's clock. This is a float expressed in seconds since an epoch, but the epoch, precision, accuracy and drift are unspecified and may differ per event loop. )rrrs rrzBaseEventLoop.times~~r!r c| td|j|j|z|g|d|i}|jr |jd=|S)a;Arrange for a callback to be called at a given time. Return a Handle: an opaque object with a cancel() method that can be used to cancel the call. The delay can be an int or float, expressed in seconds. It is always relative to the current time. Each callback will be called exactly once. If two callbacks are scheduled for exactly the same time, it is undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. zdelay must not be Noner r )r>call_atrr)rdelaycallbackr r2timers r call_laterzBaseEventLoop.call_laters_ =45 5 TYY[50(.T.%,.  " "''+ r!cN| td|j|jr"|j|j |dt j |||||}|jr |jd=tj|j|d|_ |S)z|Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. zwhen cannot be Nonerr T) r>r r| _check_thread_check_callbackr TimerHandlerheapqheappushr)rwhenrr r2rs rrzBaseEventLoop.call_ats <12 2  ;;     9 5""44wG  " "''+ t. r!c|j|jr"|j|j|d|j |||}|j r |j d=|S)aTArrange for a callback to be called as soon as possible. This operates as a FIFO queue: callbacks are called in the order in which they are registered. Each callback will be called exactly once. Any positional arguments after the callback will be passed to the callback when it is called. call_soonr )r r|rr _call_soonrrrr r2rs rrzBaseEventLoop.call_soonsa  ;;     ; 749  # #((, r!ctj|stj|rtd|dt |std|d|y)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )r iscoroutineiscoroutinefunctionr>r)rrmethods rrzBaseEventLoop._check_callback$sg  " "8 ,..x81&<> >!4VH=l$% %"r!ctj||||}|jr |jd=|jj ||S)Nr )rHandlerrrB)rrr2r rs rrzBaseEventLoop._call_soon.sDxtW=  # #((, 6" r!cz|jytj}||jk7r tdy)aoCheck that the current thread is the thread running the event loop. Non-thread-safe methods of this class make this assumption and will likely behave incorrectly when the assumption is violated. Should only be called when (self._debug == True). The caller is responsible for checking this condition for performance reasons. NzMNon-thread-safe operation invoked on an event loop other than the current one)rrfrr)r thread_ids rrzBaseEventLoop._check_thread5sB ?? " '')  ''( ( (r!c|j|jr|j|d|j|||}|jr |jd=|j |S)z"Like call_soon(), but thread-safe.rDr )r r|rrrr;rs rrDz"BaseEventLoop.call_soon_threadsafeFs`  ;;  +A B49  # #((,  r!c<|j|jr|j|d|E|j}|j |'t j jd}||_t j|j|g||S)Nrun_in_executorasyncio)thread_name_prefixr) r r|rrrA concurrentrThreadPoolExecutor wrap_futuresubmit)rrfuncr2s rrzBaseEventLoop.run_in_executorQs  ;;  '8 9  --H  ( ( *%--@@'0A*2&"" HOOD (4 (t5 5r!cpt|tjjs t d||_y)Nz,executor must be ThreadPoolExecutor instance)rrrrr>rrs rset_default_executorz"BaseEventLoop.set_default_executoras,(J$6$6$I$IJJK K!)r!c"|d|g}|r|jd||r|jd||r|jd||r|jd|dj|}tjd||j }t j ||||||} |j |z } d|d | d zd d | }| |jk\rtj|| Stj|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) rBrkrrrr+ getaddrinforinfo) rrDrErFrGrHflagsmsgt0addrinfodts r_getaddrinfo_debugz BaseEventLoop._getaddrinfo_debugfsq!"  JJ + ,  JJth' (  JJy) *  JJy) *iin *C0 YY[%%dD&$uM YY[2 %cU&c#d8,O ,, , KK  LL r!rrFrGrHrc K|jr |j}ntj}|j d|||||||d{S7wrP)r|rr+rr)rrDrErFrGrHr getaddr_funcs rrzBaseEventLoop.getaddrinfo~sU ;;22L!--L)) ,dFD%HH HHsAAA AcbK|jdtj||d{S7wrP)rr+ getnameinfo)rsockaddrrs rrzBaseEventLoop.getnameinfos2)) &$$h77 77s &/-/)fallbackcZK|jr|jdk7r tdt||j |||| |j ||||d{S7#t j$r }|sYd}~nd}~wwxYw|j||||d{7Sw)Nrzthe socket must be non-blocking) r| gettimeoutr,rw_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rr1fileoffsetcountrrms r sock_sendfilezBaseEventLoop.sock_sendfiles ;;4??,1>? ?$ ##D$> 33D$4:ECC CC33  11$28%AAA AsNA B+ A+$A)%A+(B+)A++B >BB+B  B+%B(&B+cBKtjd|d|dw)Nz-syscall sendfile is not available for socket z and file z combinationrrrr1rrrs rrz#BaseEventLoop._sock_sendfile_natives422;D8Dx| -. .sc8K|r|j||rt|tjntj}t |}d} |rt||z |}|dkrnYt |d|}|j d|j|d{} | sn#|j||d| d{|| z }p||dkDr"t|dr|j||zSSS7S75#|dkDr"t|dr|j||zwwwxYww)Nrseek) rminr!SENDFILE_FALLBACK_READBUFFER_SIZE bytearray memoryviewrreadinto sock_sendallr*) rr1rrr blocksizebuf total_sentviewreads rrz%BaseEventLoop._sock_sendfile_fallbacks1  IIf  yBB C#EE  "  / #EJ$6 BI A~!#z 2!11$ tLL''d5Dk:::d" A~'$"7 &:-.#8~M;A~'$"7 &:-.#8~sCA DAC.C*C.6C,7 C.(D*C.,C..)DDcdt|ddvr td|jtjk(s td|It |t stdj||dkrtdj|t |t stdj||dkrtdj|y)Nbmodez$file should be opened in binary modez+only SOCK_STREAM type sockets are supportedz+count must be a positive integer (got {!r})rz0offset must be a non-negative integer (got {!r})) rr,rGr+r:rr=r>formatrs rrz$BaseEventLoop._check_sendfile_paramss gdFC0 0CD DyyF...JK K  eS)AHHOQQz AHHOQQ&#&BII  A:BII  r!cKg}|j||\}}}}} d} tj|||} | jd|G|D]!\} }}}} | |k7r | j| n"|r|jt d|d|j| | d{| dx}}S#t$rQ} d| d| j j }t | j|} |j| Yd} ~ d} ~ wwxYw7g#t$r)} |j| | | jd} ~ w| | jxYw#dx}}wxYww)z$Create, bind and connect one socket.NrFrGrHF*error while attempting to bind on address : z&no matching local address with family=z found) rBr+ setblockingbindr/strerrorlowererrnopop sock_connectr)rr addr_infolocal_addr_infos my_exceptionsrFtype_rH_r)r1lfamilyladdrrmrs r _connect_sockzBaseEventLoop._connect_socks  -(+4(ua$ .==U%HD   U #+/?Y+GQ1e&(  2 %( Y %+//11%(OyPV&WXX##D'2 2 2*. -J3#2'',ir"||11346 &cii5%,,S112 3    %   )- -JskE$.Ws4,!&&t'9'9'18[J,s,/rzcreate_connection failedrc3:K|]}t|k(ywrPr)rRrmmodels rrTz2BaseEventLoop.create_connection..fsGSs3x50GszMultiple exceptions: {}rc32K|]}t|ywrPr)rRrms rrTz2BaseEventLoop.create_connection..ks%E3c#h%Esz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rrr+z%r connected to %s:%r: (%r, %r))r,rw_ensure_resolvedr+r:r/rdrr staggered_raceExceptionGrouprUrallrrkrG_create_connection_transportr|get_extra_inforr)rrrDrErurFrHrr1rr"rrrrrinfosrrsubrmrrrr rs` @@@rcreate_connectionzBaseEventLoop.create_connectionso(  &sJK K  "s "ABB"O ,SCE E +CBD D   d #  + 0BJ  t/ NPP//t V''uE0NNEABB%$($9$9v++5d%:%,, #!"EFF" -eZ@J#+ %!H!%)%7%7&+&? ? !$-#;#;,%*,)t $55 a |-7Gc3GCcGcG &!,-GTT:!+(m+!$JqM 2GJGG",Q-/&&?&F&F II%E*%EE'GHH | KMMyyF...!8ACC%)$E$E "C"7!5%F%77 8 ;;++H5D LL:tT9h @(""_N," ?#! !5H "&J 7sBJ I5;J I8*J >I>I;I>*J JJ J#J (A8J AJ 2J3AJ 8J ;I>> J J  J  J J JJ c .K|jd|}|j} |r.t|trdn|} |j ||| | ||||} n|j ||| } | d{| |fS7#| j xYww)NFr!r"rr)rrrboolr'rr) rr1rrur"r!rrrrr&rs rrz*BaseEventLoop._create_connection_transports #%##% !+C!6CJ00h F'&;%9 1;I 33D(FKI LL (""   OO  s0A,B/A?4A=5A?9B=A??BBcK|jr tdt|dtjj }|tjj urtd||tjj ur |j||||d{S|std||j||||d{S70#tj$r }|sYd}~Id}~wwxYw7)w)aSend a file to transport. Return the total number of bytes which were sent. The method uses high-performance os.sendfile if available. file must be a regular file object opened in binary mode. offset tells from where to start reading the file. If specified, count is the total number of bytes to transmit as opposed to sending the file until EOF is reached. File position is updated on return or also in case of error in which case file.tell() can be used to figure out the number of bytes which were sent. fallback set to True makes asyncio to manually read and send the file when the platform does not support the sendfile syscall (e.g. Windows or SSL socket on Unix). Raise SendfileNotAvailableError if the system does not support sendfile syscall and fallback is False. zTransport is closing_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rrrr _SendfileMode UNSUPPORTED TRY_NATIVE_sendfile_nativerr_sendfile_fallback)rrrrrrrrms rsendfilezBaseEventLoop.sendfiles0    !56 6y"8 ..::< 9**66 6:9-HJ J 9**55 5 !229d395BBB ++4-9: :,,Y-3U<< <B77   rrr SSLProtocolrrrrr BaseExceptionrr_app_transport) rrrr&r!r"rrr ssl_protocol conmade_cb resume_cbs r start_tlszBaseEventLoop.start_tlss= ;CD D*cnn5!n&' 'y"95AYM)IJL L##%++ (J "7!5!& (  !|,^^L$@$@)L NN9#;#;<  LL***   OO            s0CD5C7$C5%C7) D55C77;D22D5)rFrHr reuse_portallow_broadcastr1c DK| | jtjk(rtd| |s |s |s|s|s|s|rGt |||||||} dj d| j D} td| d| jdd} nb|s|s|d k(r td ||fd ff} nttd r|tjk(r||fD] }|t|trtd |rO|d dvrH tjtj|j rtj"|||f||fff} ni}d |fd|ffD]\}}| t|t,rt/|dk(s td|j1||tj2|||d{}|s t'd|D]\}}}}}||f}||vrddg||<||||<!|j Dcgc]\}}|r|d  |r|d||f} }}| s tdg}| D]\\}}\}}d} d} tj|tj2|} |r t5| |r/| j7tj8tj:d| jd|r| j=||r|s|j?| |d{|} n|d |}|jE}|jG| || |}|jHr4|rt)jJd||||nt)jLd||| |d{||fS#t$$rY0t&$r"}t)j*d||Yd}~Ud}~wwxYw7cc}}w7#t&$r/}| | jA|jB|Yd}~d}~w| | jAxYw7#|jAxYww)zCreate datagram connection.Nz$A datagram socket was expected, got )r remote_addrrFrHrr4r5rc36K|]\}}|s |d|yw)=NrQ)rRkvs rrTz9BaseEventLoop.create_datagram_endpoint..3s $NDAqAs!A3Z$Ns  zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address familyNNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrrbz2-tuple is expectedrr zcan not get address informationrz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))'rGr+r:r,dictrkitemsrr*r>rrr>statS_ISSOCKosst_moderemoveFileNotFoundErrorr/rerrorrrUrr;r2r-r. SO_BROADCASTrrrrBrr*r|rr) rrrr7rFrHrr4r5r1optsproblemsr_addraddr_pairs_inforaerr addr_infosidxrfamrpror)key addr_pairr local_addressremote_addressrmrrrs rcreate_datagram_endpointz&BaseEventLoop.create_datagram_endpoint!s  yyF... :4(CEEkeu/z{#)e'1,;= 99$NDJJL$NN 008z<==   U #F+Q;$%@AA%+UO\#B"D+&..0H'5>D' 40E'(<==>*Q-{"B 6==)<)D)DEIIj1&,UO%/$=$?#B #$j/A{3C!D;IC' *4 7CIN"+,A"BB&*&;&; f6G6G"'u4'<'A!A %")*M"NN7<;3CCG#&*C"*437, 33:JsOC0 ;;&!m##%##%11 (FF, ;; 0& YJ (()X? LL (""}-"6 &5%/666 !A#E8J+' %J%%c**' *   OO  sC!P $P 5P  AM6P /AP N/A P  N2'$P  B!N:-N8.N:4A3P (P -P.P 2P 6 N,?P N, N'!P 'N,,P 2P 8N:: P$O-'P -PP P PP cK|dd\}}t|||||g|dd} | | gS|j||||||d{S7w)Nrbr)rMr) rr)rFrGrHrrrDrErs rrzBaseEventLoop._ensure_resolvedstRa[ dD$eJgabkJ  6M))$V$05U*DD DDs;AAAcK|j||f|tj||d{}|std|d|S7w)N)rFrGrrz getaddrinfo(z) returned empty list)rr+r:r/)rrDrErFrrs r_create_server_getaddrinfoz(BaseEventLoop._create_server_getaddrinfos]++T4L171C1C27d,DDL0EFG G Ds*AAAr) rFrr1rru reuse_addressr4rrrc DKt|tr td| | td| | td| t |||| td| (t j dk(xrtjdk7} g}|dk(rdg}n:t|ts$t|tjjs|g}n|}|Dcgc]}|j|||| }}tj|d{}t!t"j$j'|}d } |D]}|\}}}}} t)j(|||}|j3|| r/|j5t(j6t(j8d | r t;|t<rR|t(j>k(r?tAt(dr/|j5t(jBt(jDd  |jG||stId|Dcgc]}|d c}d }|sS|D]}|jUn;| td|jVt(jXk7rtd||g}|D]}|j[d t]|||||| | }| r-|j_tj`dd{|j,rt/jbd||Scc}w7 #t(j*$r*|j,rt/j0d |||d YwxYw#tH$r}d|d|jJjM}|jNtNjPk(rG|jS|jU|j,rt/j0|Yd}~tI|jN|dd}~wwxYwcc}w#|s|D]}|jUwwxYw7Aw)a1Create a TCP server. The host parameter can be a string, in that case the TCP server is bound to host and port. The host parameter can also be a sequence of strings and in that case the TCP server is bound to all hosts of the sequence. If a host appears multiple times (possibly indirectly e.g. when hostnames resolve to the same IP address), the server is only bound once to that host. Return a Server object which can be used to stop the service. This method is a coroutine. z*ssl argument must be an SSLContext or NoneNrrrposixcygwinr5)rFrFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6rrz%could not bind on any address out of z)Neither host/port nor sock were specifiedrrz %r is serving)2rrr>r,rwrDrr}platformrrUabcIterablerZr rWsetrZr[r\r+rHr|rwarningrBr-r. SO_REUSEADDRr2rArr*ra IPV6_V6ONLYrr/rrr EADDRNOTAVAILrrrGr:rrrrr)rrrDrErFrr1rrur[r4rrrrhostsfsr completedresrLsocktyperH canonnamesarNrrrs r create_serverzBaseEventLoop.create_servers8 c4 HI I ,CE E + BD D   d #  t/ NPP$ "7 2 Os||x7O GrzT3' {'?'?@$%11$V8=2?%B% ,,++E 55e<=EI2 % '@C9<6B%B!%}}R5ANN4($"--v/B/BDJ!&t,"&//1#FN;(;(;(.(:(:(,. @ " 7'@R!:?%@$d1g%@#CDD!  '% %| !LMMyyF... #EdX!NOOfG $D   U # $g'7W&;,.   ! ! #++a. ;; KK 0 _%,"<<!;;"NN,G+-xO! !0# @#%cll&8&8&: <99(;(;;#KKM JJL#{{ &s 3$%cii54? @&A! '% %!( !sC P L*P L .P 1 O>?L B'O>>M O> O9 ) O>4B(P P.P  9M O> M  O> O6A>O1O>O11O66O>>PP )rurrc rK|jtjk7rtd|| |s td| |s td| t ||j |||dd||d{\}}|j r)|jd}tjd|||||fS7@w) Nrrrr5T)r!rrr+z%r handled: (%r, %r)) rGr+r:r,rwrr|rrr)rrr1rurrrrs rconnect_accepted_socketz%BaseEventLoop.connect_accepted_socketFs 99** *A$JK K ,SCE E +CBD D   d #$($E$E "C"7!5%F%77 8 ;;++H5D LL/y( K(""7sA2B74B55AB7cK|}|j}|j|||} |d{|jr&t j d|j ||||fS7:#|jxYww)Nz Read pipe %r connected: (%r, %r))rr.rr|rrfilenorrr-rrrs rconnect_read_pipezBaseEventLoop.connect_read_pipeds#%##%2246J  LL ;; LL; 8 =(""   OO  ++BA0A.A06B.A00BBcK|}|j}|j|||} |d{|jr&t j d|j ||||fS7:#|jxYww)Nz!Write pipe %r connected: (%r, %r))rr0rr|rrrvrws rconnect_write_pipez BaseEventLoop.connect_write_pipets#%##%33D(FK  LL ;; LL< 8 =(""   OO  rycr|g}||jdt||1|tjk(r|jdt|n>||jdt|||jdt|t j dj |y)Nzstdin=zstdout=stderr=zstdout=zstderr= )rBr'r#r%rrrk)rrr4r5r6rs r_log_subprocesszBaseEventLoop._log_subprocesssu   KK&e!4 56 7  &J,=,="= KK.f)=(>? @! gl6&:%;<=! gl6&:%;<= SXXd^$r!) r4r5r6universal_newlinesr3r7encodingerrorstextc Kt|ttfs td|r td|s td|dk7r td| r td| td| td|} d}|jrd |z}|j |||||j | |d ||||fi| d{}|jr|tjd |||| fS7-w) Nzcmd must be a string universal_newlines must be Falsezshell must be Truerbufsize must be 0text must be Falseencoding must be Noneerrors must be Nonezrun shell command %rT%s: %r) rr<rr,r|r~r9rr)rrcmdr4r5r6rr3r7rrrr8r debug_logrs rsubprocess_shellzBaseEventLoop.subprocess_shells#s|,34 4 ?@ @12 2 a<01 1 12 2  45 5  23 3#% ;;/4I  E66 B9$99 c4KCIKK ;;90 KK)Y 7("" KsB=C/?C-.C/c K|r td|r td|dk7r td| r td| td| td|f| z}|}d}|jrd|}|j|||||j||d ||||fi| d{}|jr|t j d ||||fS7-w) Nrzshell must be Falserrrrrzexecute program Fr)r,r|r~r9rr)rrprogramr4r5r6rr3r7rrrr2r8 popen_argsrrrs rsubprocess_execzBaseEventLoop.subprocess_execs  ?@ @ 23 3 a<01 1 12 2  45 5  23 3Z$& #% ;;+7+6I  E66 B9$99 j%   ;;90 KK)Y 7("" sB"C$C%.Cc|jS)zKReturn an exception handler, or None if the default one is in use. )rrs rget_exception_handlerz#BaseEventLoop.get_exception_handlers&&&r!cH|t|std|||_y)aSet handler as the new event loop exception handler. If handler is None, the default exception handler will be set. If handler is a callable object, it should have a signature matching '(loop, context)', where 'loop' will be a reference to the active event loop, 'context' will be a dict object (see `call_exception_handler()` documentation for details about context). Nz+A callable object or None is expected, got )rr>r)rhandlers rset_exception_handlerz#BaseEventLoop.set_exception_handlers5  x'8##*+/0 0")r!c|jd}|sd}|jd}|t|||jf}nd}d|vr;|j/|jjr|jj|d<|g}t |D]}|dvr||}|dk(r:d j tj|}d }||jz }nJ|dk(r:d j tj|}d }||jz }n t|}|j|d |tjd j ||y)aEDefault exception handler. This is called when an exception occurs and no exception handler is set, and can be called by a custom exception handler that wants to defer to the default behavior. This default handler logs the error message and other context-dependent information. In debug mode, a truncated stack trace is also appended showing where the given object (e.g. a handle or future or task) was created, if any. The context parameter has the same meaning as in `call_exception_handler()`. rSz!Unhandled exception in event looprgNFsource_tracebackhandle_traceback>rSrgr5z+Object created at (most recent call last): z+Handle created at (most recent call last): r r_)getrG __traceback__rrsortedrk traceback format_listrstriprrBrrH) rr rSrgr` log_linesrSvaluetbs rdefault_exception_handlerz'BaseEventLoop.default_exception_handlers`++i(9GKK ,  YI4K4KLHH g -$$0$$66$$66 & 'I '? 0C..CLE((WWY2259:F$**WWY2259:F$U    uBug. / 0  TYYy)H=r!c|j |j|y d}|jd}||jd}||jd}|t|dr|j}|*t|d r|j|j||y|j||y#ttf$rt$rt j ddYywxYw#ttf$rt$r[} |jd ||d n:#ttf$rt$rt j d dYnwxYwYd}~yYd}~yd}~wwxYw) aDCall the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'task' (optional): Task instance; - 'handle' (optional): Handle instance; - 'protocol' (optional): Protocol instance; - 'transport' (optional): Transport instance; - 'socket' (optional): Socket instance; - 'asyncgen' (optional): Asynchronous generator that caused the exception. New keys maybe introduced in the future. Note: do not overload this method in an event loop subclass. For custom exception handling, use the `set_exception_handler()` method. Nz&Exception in default exception handlerTr_rror get_contextrunz$Unhandled error in exception handler)rSrgr zeException in default exception handler while handling an unexpected error in custom exception handler) rrrhrir.rrHrr*rr)rr ctxthingrms rrZz$BaseEventLoop.call_exception_handlersq,  " " * ,..w7$ 0 F+=$KK1E=#KK1E$ )F++-C?wsE':GGD33T7C++D':3 12   , E&*,  ,0 12   0022#I%(#*4 #$56$0LL"?+/000  0sMB7BC,$C,7/C)(C),EDE/E  E E  EEcT|js|jj|yy)zAdd a Handle to _ready.N) _cancelledrrBrrs r _add_callbackzBaseEventLoop._add_callbackgs"  KK  v &!r!cF|j||jy)z6Like _add_callback() but called from a signal handler.N)rr;rs r_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafels 6" r!cH|jr|xjdz c_yy)z3Notification that a TimerHandle has been cancelled.rN)rrrs r_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelledqs!     ' '1 , ' r!cbt|j}|tkDrr|j|z tkDr\g}|jD]'}|j rd|_|j |)tj|||_d|_n|jrz|jdj ra|xjdzc_tj|j}d|_|jr|jdj rad}|js |jrd}nP|jrD|jdj}ttd||jz t }|j"j%|}|j'|d}|j|j(z}|jrm|jd}|j|k\rnNtj|j}d|_|jj ||jrmt|j}t+|D]} |jj-}|j r*|j.rr ||_|j} |j3|j| z } | |j4k\r t7j8dt;|| d|_|j3d}y#d|_wxYw)zRun one full iteration of the event loop. This calls all currently ready callbacks, polls for I/O, schedules the resulting callbacks, and finally schedules 'call_later' callbacks. FrrNzExecuting %s took %.3f seconds)rUr_MIN_SCHEDULED_TIMER_HANDLESr%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrrBrheapifyheappoprr_whenrmaxrMAXIMUM_SELECT_TIMEOUT _selectorselectr>rrangepopleftr|r_runrrrgr ) r sched_count new_scheduledrrjrr=end_timentodoirrs rrzBaseEventLoop._run_oncevs$//* 6 6  ' '+ 55 6M// 1$$(-F%!((0  1 MM- (+DO*+D '//dooa&8&C&C++q0+t7$)!//dooa&8&C&C  ;;$..G __??1%++D#a !346LMG^^**73  Z( 99;!7!77oo__Q'F||x']]4??3F %F  KK  v & ooDKK u A[[((*F  {{ 0+1D(BKKMr)BT888'G'5f'=rC,0D( ! ",0D(s A)L%% L.c t|t|jk(ry|rDtj|_tj t j||_ytj |j||_yrP)rrr}#get_coroutine_origin_tracking_depthr#set_coroutine_origin_tracking_depthrDEBUG_STACK_DEPTHrenableds rr{z,BaseEventLoop._set_coroutine_origin_trackingsw =D!H!HI I  779  7  3 3++ - 3:/  3 3;; =3:/r!c|jSrP)r|rs rrzBaseEventLoop.get_debugs {{r!cl||_|jr|j|j|yyrP)r|rrDr{rs rrzBaseEventLoop.set_debugs. ??   % %d&I&I7 S r!rP)NNNr=)r)rN)FNN)Urrrrrrrrrrr'r*r.r0r9r;r>r rArHrPr_rqrhrwrrrkrrrLrMrrrrrrrrrrDrrrrrrrrrrrrr&r$r%r3rWr+r:rrZr? AI_PASSIVErrrtrxr{r~r#r$rrrrrrZrrrrr{rrrQr!rrrs/< ))-d* %""%)$" 9=" $t"&!%!% "CG" @D(," AE)-"04" ""7DG "20DK40$L*.%MM - :>06:$26&%("=A 5 * 2"#!1H7 A(, A./4**.Z59J#14T"&!%!%$J#\*/"&!% #8-<#'-<^1"4%*(,.2-1 .+bEID#./q267;$ D#N'(f.@.@%&a D59I####"&!%IZ"&!% #<# # %&0__&0oo&0oo27%)1(,T "#J%/OOJOO%/__$)1'+Dt #D' *"0>dF0P'  - N` :Tr!r)rr)r)8__doc__rUcollections.abcconcurrent.futuresrrr rrZrDr+rBr#rfrrr}rLrru ImportErrorr5rrrrrr r r r r rrlogr__all__rrr*rArr r'r2rMrdrnrrrwProtocolryAbstractServerrAbstractEventLooprrQr!rrs0       $ #),% FJ ' #J8v," 6=!G  > A) 2 2A)HBV " "BJCTF,,CTk  CsDDD