ÿØÿà JFIF    ÿÛ „ ( %!1!%*+...983,7(-.- __main__.py000064400000006643152343231170006650 0ustar00import ast import asyncio import code import concurrent.futures import contextvars import inspect import sys import threading import types import warnings from . import futures class AsyncIOInteractiveConsole(code.InteractiveConsole): def __init__(self, locals, loop): super().__init__(locals) self.compile.compiler.flags |= ast.PyCF_ALLOW_TOP_LEVEL_AWAIT self.loop = loop self.context = contextvars.copy_context() def runcode(self, code): future = concurrent.futures.Future() def callback(): global repl_future global repl_future_interrupted repl_future = None repl_future_interrupted = False func = types.FunctionType(code, self.locals) try: coro = func() except SystemExit: raise except KeyboardInterrupt as ex: repl_future_interrupted = True future.set_exception(ex) return except BaseException as ex: future.set_exception(ex) return if not inspect.iscoroutine(coro): future.set_result(coro) return try: repl_future = self.loop.create_task(coro, context=self.context) futures._chain_future(repl_future, future) except BaseException as exc: future.set_exception(exc) loop.call_soon_threadsafe(callback, context=self.context) try: return future.result() except SystemExit: raise except BaseException: if repl_future_interrupted: self.write("\nKeyboardInterrupt\n") else: self.showtraceback() class REPLThread(threading.Thread): def run(self): try: banner = ( f'asyncio REPL {sys.version} on {sys.platform}\n' f'Use "await" directly instead of "asyncio.run()".\n' f'Type "help", "copyright", "credits" or "license" ' f'for more information.\n' f'{getattr(sys, "ps1", ">>> ")}import asyncio' ) console.interact( banner=banner, exitmsg='exiting asyncio REPL...') finally: warnings.filterwarnings( 'ignore', message=r'^coroutine .* was never awaited$', category=RuntimeWarning) loop.call_soon_threadsafe(loop.stop) if __name__ == '__main__': sys.audit("cpython.run_stdin") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) repl_locals = {'asyncio': asyncio} for key in {'__name__', '__package__', '__loader__', '__spec__', '__builtins__', '__file__'}: repl_locals[key] = locals()[key] console = AsyncIOInteractiveConsole(repl_locals, loop) repl_future = None repl_future_interrupted = False try: import readline # NoQA except ImportError: pass repl_thread = REPLThread() repl_thread.daemon = True repl_thread.start() while True: try: loop.run_forever() except KeyboardInterrupt: if repl_future and not repl_future.done(): repl_future.cancel() repl_future_interrupted = True continue else: break base_tasks.py000064400000005160152343231170007240 0ustar00import linecache import reprlib import traceback from . import base_futures from . import coroutines def _task_repr_info(task): info = base_futures._future_repr_info(task) if task.cancelling() and not task.done(): # replace status info[0] = 'cancelling' info.insert(1, 'name=%r' % task.get_name()) if task._fut_waiter is not None: info.insert(2, f'wait_for={task._fut_waiter!r}') if task._coro: coro = coroutines._format_coroutine(task._coro) info.insert(2, f'coro=<{coro}>') return info @reprlib.recursive_repr() def _task_repr(task): info = ' '.join(_task_repr_info(task)) return f'<{task.__class__.__name__} {info}>' def _task_get_stack(task, limit): frames = [] if hasattr(task._coro, 'cr_frame'): # case 1: 'async def' coroutines f = task._coro.cr_frame elif hasattr(task._coro, 'gi_frame'): # case 2: legacy coroutines f = task._coro.gi_frame elif hasattr(task._coro, 'ag_frame'): # case 3: async generators f = task._coro.ag_frame else: # case 4: unknown objects f = None if f is not None: while f is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(f) f = f.f_back frames.reverse() elif task._exception is not None: tb = task._exception.__traceback__ while tb is not None: if limit is not None: if limit <= 0: break limit -= 1 frames.append(tb.tb_frame) tb = tb.tb_next return frames def _task_print_stack(task, limit, file): extracted_list = [] checked = set() for f in task.get_stack(limit=limit): lineno = f.f_lineno co = f.f_code filename = co.co_filename name = co.co_name if filename not in checked: checked.add(filename) linecache.checkcache(filename) line = linecache.getline(filename, lineno, f.f_globals) extracted_list.append((filename, lineno, name, line)) exc = task._exception if not extracted_list: print(f'No stack for {task!r}', file=file) elif exc is not None: print(f'Traceback for {task!r} (most recent call last):', file=file) else: print(f'Stack for {task!r} (most recent call last):', file=file) traceback.print_list(extracted_list, file=file) if exc is not None: for line in traceback.format_exception_only(exc.__class__, exc): print(line, file=file, end='') __pycache__/constants.cpython-312.pyc000064400000001675152343231170013505 0ustar00 ֦iZddlZdZdZdZdZdZdZdZd Zd Z Gd d ejZ y) N gN@g>@iii,creZdZejZejZejZy) _SendfileModeN)__name__ __module__ __qualname__enumauto UNSUPPORTED TRY_NATIVEFALLBACK*/usr/lib64/python3.12/asyncio/constants.pyrr&s)$))+KJtyy{Hrr) r !LOG_THRESHOLD_FOR_CONNLOST_WRITESACCEPT_RETRY_DELAYDEBUG_STACK_DEPTHSSL_HANDSHAKE_TIMEOUTSSL_SHUTDOWN_TIMEOUT!SENDFILE_FALLBACK_READBUFFER_SIZE FLOW_CONTROL_HIGH_WATER_SSL_READ!FLOW_CONTROL_HIGH_WATER_SSL_WRITETHREAD_JOIN_TIMEOUTEnumrrrrrs^  %&! %/!#& $'!DIIr__pycache__/futures.cpython-312.opt-1.pyc000064400000041064152343231170014121 0ustar00 ֦i8jdZdZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z dd l m Z e jZe jZe j Ze j"Zej$dz ZGd d ZeZd Zd ZdZdZdZdZdddZ ddlZej(xZZy#e$rYywxYw)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) GenericAlias) base_futures)events) exceptions)format_helpersceZdZdZeZdZdZdZdZ dZ dZ dZ dZ dddZdZdZeeZedZej,d Zd Zd Zdd Zd ZdZdZdZdZdddZdZ dZ!dZ"dZ#e#Z$y)ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopc|tj|_n||_g|_|jj r.t j tjd|_ yy)zInitialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r get_event_loop_loop _callbacks get_debugr extract_stacksys _getframe_source_tracebackselfrs (/usr/lib64/python3.12/asyncio/futures.py__init__zFuture.__init__Hs[ <..0DJDJ ::   !%3%A%A a &"D " "c,tj|SN)r _future_reprrs r__repr__zFuture.__repr__Xs((..rc|jsy|j}|jjd||d}|jr|j|d<|j j |y)Nz exception was never retrieved)message exceptionfuturesource_traceback)_Future__log_traceback _exception __class____name__rrcall_exception_handler)rexccontexts r__del__zFuture.__del__[sl## oo>>**++IJ    ! !*.*@*@G& ' ))'2rc|jSr)r'r s r_log_tracebackzFuture._log_tracebackms###rc,|r tdd|_y)Nz'_log_traceback can only be set to FalseF) ValueErrorr')rvals rr0zFuture._log_tracebackqs FG G$rc8|j}| td|S)z-Return the event loop the Future is bound to.z!Future object is not initialized.)r RuntimeErrorrs rget_loopzFuture.get_loopws!zz <BC C rc|j|j}d|_|S|jtj}ntj|j}|j|_d|_|S)zCreate the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. N)_cancelled_exc_cancel_messager CancelledError __context__)rr,s r_make_cancelled_errorzFuture._make_cancelled_error~sr    *%%C"&D J    '++-C++D,@,@AC--" rc~d|_|jtk7ryt|_||_|j y)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r'_state_PENDING _CANCELLEDr9_Future__schedule_callbacks)rmsgs rcancelz Future.cancels9 % ;;( "  " !!#rc|jdd}|syg|jdd|D]#\}}|jj|||%y)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr-)rr call_soon)r callbackscallbackctxs r__schedule_callbackszFuture.__schedule_callbackssM OOA&  &MHc JJ 4 ='rc(|jtk(S)z(Return True if the future was cancelled.)r>r@r s r cancelledzFuture.cancelleds{{j((rc(|jtk7S)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r>r?r s rdonez Future.dones {{h&&rc |jtk(r|j|jtk7rt j dd|_|j%|jj|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.F) r>r@r< _FINISHEDr InvalidStateErrorr'r(with_traceback _exception_tb_resultr s rresultz Future.resultst ;;* $,,. . ;;) #../EF F$ ?? &//001C1CD D||rc|jtk(r|j|jtk7rt j dd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r>r@r<rPr rQr'r(r s rr$zFuture.exceptionsO ;;* $,,. . ;;) #../FG G$rrEc|jtk7r|jj|||y|t j }|j j||fy)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. rEN)r>r?rrF contextvars copy_contextrappend)rfnr-s radd_done_callbackzFuture.add_done_callbacksR ;;( " JJ T7 ;%224 OO " "B= 1rc|jDcgc]\}}||k7r||f}}}t|jt|z }|r||jdd|Scc}}w)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. N)rlen)rr[frIfiltered_callbacks removed_counts rremove_done_callbackzFuture.remove_done_callbacksn /3oo*.=(1c!"b !#h.= *DOO,s3E/FF !3DOOA  *sAc|jtk7r$tj|jd|||_t |_|j y)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r>r?r rQrTrPrA)rrUs r set_resultzFuture.set_resultsJ ;;( "..$++b/IJ J   !!#rcj|jtk7r$tj|jd|t |t r|}t |t rtd}||_||_ |}||_ |j|_ t|_|jd|_y)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rdzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r>r?r rQ isinstancetype StopIterationr5 __cause__r;r( __traceback__rSrPrAr')rr$new_excs r set_exceptionzFuture.set_exceptions ;;( "..$++b/IJ J i &! I i /"$,-G!*G "+G I#&44  !!##rc#K|js d|_||js td|jSw)NTzawait wasn't used with future)rN_asyncio_future_blockingr5rUr s r __await__zFuture.__await__s=yy{,0D )Jyy{>? ?{{}sAA r)%r* __module__ __qualname____doc__r?r>rTr(rrr9r8ror'rr!r. classmethodr__class_getitem__propertyr0setterr6r<rCrArLrNrUr$r\rbrermrp__iter__rrrrs&FGJ EON %O#" /3 $L1 $$%% (  >) ' 04 2  $$.Hrrc^ |j}|S#t$rY|jSwxYwr)r6AttributeErrorr)futr6s r _get_loopr}-s:<<z    99  s  ,,cH|jry|j|y)z?Helper setting the result only if the future was not cancelled.N)rLre)r|rUs r_set_result_unless_cancelledr9s }}NN6rclt|}|tjjurt j|j S|tjj urt j |j S|tjjurt j|j S|Sr)rh concurrentfuturesr:r args TimeoutErrorrQ)r, exc_classs r_convert_future_excr@sS IJ&&555((#((33 j((55 5&&11 j((:: :++SXX66 rc |jr|j|jsy|j}||jt |y|j }|j|y)z8Copy state from a future to a concurrent.futures.Future.N)rLrCset_running_or_notify_cancelr$rmrrUre)rsourcer$rUs r_set_concurrent_future_staterLst  2: 2 2 4  "I   !4Y!?@ f%rc|jry|jr|jy|j}||jt |y|j }|j |y)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rLrCr$rmrrUre)rdestr$rUs r_copy_future_stater[se  ~~  $$&    29= >]]_F OOF #rcts/ttjjs t dts/ttjjs t dtr t ndtr t nddfd}fd}j|j|y)aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcLt|r t||yt||yr)rrr)r%others r _set_statez!_chain_future.._set_states F  uf - ( 7rc|jr3urjyjjyyr)rLrCcall_soon_threadsafe) destination dest_loopr source_loops r_call_check_cancelz)_chain_future.._call_check_cancels<  ""kY&> 00? #rcjrjryur |yjryj|yr)rL is_closedr)rrrrrs r_call_set_statez&_chain_future.._call_set_states[  ! ! #%)*=*=*?    [ 8 {F +""$  * *:{F Kr)rrgrrr TypeErrorr}r\)rrrrrrrs`` @@@r _chain_futureros F Jv/9/A/A/H/H%JBCC K K4>4F4F4M4M*OGHH'/'7)F#TK*2;*? +&TI8 @ L!!"45 _-rr ct|r|S|tj}|j}t |||S)z&Wrap concurrent.futures.Future object.)rr r create_futurer)r%r new_futures rrrsB  |$$&##%J&*% r) rs__all__concurrent.futuresrrXloggingrtypesrrr r r rr?r@rPDEBUG STACK_DEBUGr _PyFuturer}rrrrrr_asyncio_CFuture ImportErrorryrrrs4        $ $  " " mma HHX     &$().X!% ( !'FX   sB**B21B2__pycache__/constants.cpython-312.opt-2.pyc000064400000001675152343231170014445 0ustar00 ֦iZddlZdZdZdZdZdZdZdZd Zd Z Gd d ejZ y) N gN@g>@iii,creZdZejZejZejZy) _SendfileModeN)__name__ __module__ __qualname__enumauto UNSUPPORTED TRY_NATIVEFALLBACK*/usr/lib64/python3.12/asyncio/constants.pyrr&s)$))+KJtyy{Hrr) r !LOG_THRESHOLD_FOR_CONNLOST_WRITESACCEPT_RETRY_DELAYDEBUG_STACK_DEPTHSSL_HANDSHAKE_TIMEOUTSSL_SHUTDOWN_TIMEOUT!SENDFILE_FALLBACK_READBUFFER_SIZE FLOW_CONTROL_HIGH_WATER_SSL_READ!FLOW_CONTROL_HIGH_WATER_SSL_WRITETHREAD_JOIN_TIMEOUTEnumrrrrrs^  %&! %/!#& $'!DIIr__pycache__/subprocess.cpython-312.pyc000064400000027500152343231170013654 0ustar00 ֦i92dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZ Gd d ejejZGd d Zdddej fd Zdddej ddZy))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercLeZdZdZfdZdZdZdZdZdZ dZ d Z xZ S) SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.ct||||_dx|_x|_|_d|_d|_g|_|jj|_ y)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loop create_future _stdin_closed)selflimitr __class__s +/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ d# 155 5T[4;$!ZZ557cl|jjg}|j|jd|j|j|jd|j|j |jd|j dj dj|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinfos r__repr__z!SubprocessStreamProtocol.__repr__s''( :: ! KK&/ 0 ;; " KK'$++1 2 ;; " KK'$++1 2}}SXXd^,,rcn||_|jd}|ftj|j|j |_|j j||jjd|jd}|ftj|j|j |_ |jj||jjd|jd}|)tj||d|j |_ yy)Nrrrr)protocolreaderr) rget_pipe_transportr StreamReaderrrr set_transportrr#r StreamWriterr)r transportstdout_transportstderr_transportstdin_transports rconnection_madez(SubprocessStreamProtocol.connection_made(s#$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $#66q9  & --o7;5937::?DJ 'rcx|dk(r |j}n|dk(r |j}nd}||j|yyNrr*)rr feed_data)rfddatar,s rpipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@ 7[[F 1W[[FF     T " rc |dk(rz|j}||j|j|||jj dy|jj |d|j_y|dk(r |j}n|dk(r |j}nd}|$||jn|j |||jvr|jj||jy)NrFrr*) rcloseconnection_lostr set_result set_exception_log_tracebackrrfeed_eofrremove_maybe_close_transport)rr9excpiper,s rpipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs 7::D   %{""--d3  ""0055:""1  7[[F 1W[[FF  {!$$S)   NN ! !" % ##%rc2d|_|jy)NT)rrDrs rprocess_exitedz'SubprocessStreamProtocol.process_exitedhs# ##%rct|jdk(r/|jr"|jj d|_yyy)Nr)lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls: t~~ ! #(<(< OO ! ! #"DO)= #rc8||jur |jSyN)rr)rstreams r_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs TZZ %% % r) r" __module__ __qualname____doc__rr'r5r;rGrJrDrP __classcell__)rs@rr r s.:8-?0#&<&# &rr cZeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d d Zy )Processc||_||_||_|j|_|j|_|j |_|j |_yrN)r _protocolrrrrget_pidpid)rr1r+rs rrzProcess.__init__wsH#! ^^ oo oo $$&rcPd|jjd|jdS)N)rr"rZrIs rr'zProcess.__repr__s&4>>**+1TXXJa88rc6|jjSrN)rget_returncoderIs r returncodezProcess.returncodes--//rcRK|jjd{S7w)z?Wait until the process exit and return the process return code.N)r_waitrIs rwaitz Process.waits__**,,,,s '%'c:|jj|yrN)r send_signal)rsignals rrezProcess.send_signals ##F+rc8|jjyrN)r terminaterIs rrhzProcess.terminates !!#rc8|jjyrN)rkillrIs rrjz Process.kills rcK|jj} |=|jj||r t j d|t ||jjd{|rt j d||jjy77#ttf$r#}|rt j d||Yd}~bd}~wwxYww)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugrLdrainBrokenPipeErrorConnectionResetErrorr=)rinputrnrEs r _feed_stdinzProcess._feed_stdins $$& H    'LL?s5zS**""$ $ $  LL6 =  %!56 H ;T3G  HsAC)AB4:B2;B4?3C)2B44C&C!C)!C&&C)c KywrNrIs r_noopz Process._noops scK|jj|}|dk(r |j}n|dk(sJ|j}|jj r |dk(rdnd}t jd|||jd{}|jj r |dk(rdnd}t jd|||j|S7Pw)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrlr rnreadr=)rr9r1rOnameoutputs r _read_streamzProcess._read_streamsOO66r: 7[[F7N7[[F ::   !!Qw8HD LL2D$ ?{{}$ ::   !!Qw8HD LL3T4 @ %sBC#C!AC#NcK|j|j|}n|j}|j|j d}n|j}|j |j d}n|j}t j|||d{\}}}|jd{||fS7$7 wr7) rrsrvrr{rr gatherrc)rrrrrrs r communicatezProcess.communicates :: !$$U+EJJLE ;; "&&q)FZZ\F ;; "&&q)FZZ\F&+ll5&&&I Ivviik!Js$B%C'C (CC CCrN)r"rQrRrr'propertyr`rcrerhrjrsrvr{r~rurrrVrVvsH'900-,$(" rrVc Ktj  fd} j||f|||d|d{\}}t|| S7w)NctSNr)r r)srz)create_subprocess_shell..7e=A Crrrr)rget_running_loopsubprocess_shellrV) cmdrrrrkwdsprotocol_factoryr1r+rs ` @rrrsm  " " $DC 5 5 5 !!!Ix 9h -- s6AAA)rrrrc Ktj  fd} j||g||||d|d{\}} t|| S7w)NctSrrr)srrz(create_subprocess_exec..rrr)rrsubprocess_execrV) programrrrrargsrrr1r+rs ` @rrrsy  " " $DC 4 4 4!!F ! !Ix 9h -- s9AAA)__all__ subprocessrrrr logr PIPESTDOUTDEVNULLFlowControlMixinSubprocessProtocolr rV_DEFAULT_LIMITrrrurrrs =      b&w77(;;b&JU U p.2$t(/(>(> .8rsZ-         >>      ??   ==        ??  >>  ??      ==      ??         "<<7! ~%%%G {"""Gr__pycache__/log.cpython-312.opt-2.pyc000064400000000370152343231170013201 0ustar00 ֦i|2 ddlZejeZy)N)logging getLogger __package__logger$/usr/lib64/python3.12/asyncio/log.pyr s   ; 'r__pycache__/staggered.cpython-312.pyc000064400000014626152343231170013436 0ustar00 ֦iPdZdZddlZddlmZddlmZddlmZddlmZdd d Z y) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loopc  Kxstjt|ddgg t d fd d  f d d} t j }j  |d} j||j |jd} r j d{d r r td|| f ~S7##tj$r,}|} D]}|j|jYd}~[d}~wwxYw# ~wxYww)aRun coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. Ncj|#jssjd|jry|j }|yj |y)N)discarddone set_result cancelled exceptionappend)taskexcon_completed_fut running_tasksunhandled_exceptionss */usr/lib64/python3.12/asyncio/staggered.py task_donez!staggered_race..task_doneJscd#  ($))+!  ' ' - >>  nn ; ##C(c K|jd{|Xtjtj5t j |j d{ddd t \}}tj}tj}j||}j||j|j jdt! |dzk(sJ |d{}J||t j"}D]} | |us| j%y7N7#1swYxYw#t$rYywxYw7^#t&t(f$rt*$r} | |<|jYd} ~ yd} ~ wwxYww)Nr)wait contextlibsuppressexceptions_mod TimeoutErrorrwait_fornext StopIterationrEvent create_taskaddadd_done_callbacksetrlen current_taskcancel SystemExitKeyboardInterrupt BaseException) ok_to_startprevious_failed this_indexcoro_fn this_failednext_ok_to_start next_taskresultr)tedelay enum_coro_fnsrr run_one_cororr winner_index winner_results rr:z$staggered_race..run_one_coro[s    &$$^%@%@A nn_%9%9%;UCCC B "&}"5 Jkkm  ;;=$$\2BK%PQ )$##I. $:*q.000 "9_F ' ''%L"M!--d3L"L(HHJ#a !D BA    %-.   %&Jz " OO   sGE%)G(E*)E(*E*.G7E6BG F&F'F+&GG(E**E3/G6 F?GFGFF>F94G9F>>Gzstaggered race failed)returnN)rget_running_loop enumerater'rr#r$r%r& create_futurerCancelledErrorr*argsExceptionGroup)coro_fnsr8r propagate_cancellation_errorr. first_taskexrr9rrr:rrrr;r<s `` @@@@@@@@@rrr s`h  ,6**,Dh'MMLJEM)"66p$( Kkkm %%l;&EF *%$$Y/'+$#113  *&&& $ .!!8:NO O ' 3. .lJ6 46J'!00 */1,)DDKK)* * 46JsaAEA2D=C;C9C;D=D=5E9C;;D:"D50D=5D::D==EE) __doc____all__rrrrrrrrrrLs(L *37aKr__pycache__/unix_events.cpython-312.opt-2.pyc000064400000171054152343231170014777 0ustar00 ֦i ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZdZe j4dk(reddZdZGddej<ZGddej@Z!GddejDejFZ$GddejJZ&GddZ'Gdde'Z(Gdd e'Z)Gd!d"e)Z*Gd#d$e)Z+Gd%d&e'Z,Gd'd(e'Z-d)Z.Gd*d+ej^Z0eZ1e0Z2y),N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherPidfdChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on Windowsc yN)signumframes ,/usr/lib64/python3.12/asyncio/unix_events.py_sighandler_noopr*scP tj|S#t$r|cYSwxYwr)oswaitstatus_to_exitcode ValueError)statuss rr"r"/s.((00  s  %%ceZdZ dfd ZfdZdZdZdZdZdZ dd Z dd Z dd Z d Z ddddddd dZ dddddddddZdZdZdZdZxZS)_UnixSelectorEventLoopNc2t||i|_yr)super__init___signal_handlers)selfselector __class__s rr)z_UnixSelectorEventLoop.__init__?s " "rc0t|tjs,t |j D]}|j |y|j r;tjd|dt||j jyy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) r(closesys is_finalizinglistr*remove_signal_handlerwarningswarnResourceWarningclear)r+sigr-s rr1z_UnixSelectorEventLoop.closeCs    "D112**3/3$$ 1$:HI.%) + %%++- %rc:|D]}|s|j|yr)_handle_signal)r+datars r_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs F    ' rcT tj|stj|r td|j ||j  t j|jjtj|||d}||j |< t j |t"t j$|dy#ttf$r}tt|d}~wwxYw#t$r}|j |=|j sI t jdn2#ttf$r }t'j(d|Yd}~nd}~wwxYw|j*t*j,k(rtd|dd}~wwxYw)Nz3coroutines cannot be used with add_signal_handler()Fset_wakeup_fd(-1) failed: %ssig  cannot be caught)r iscoroutineiscoroutinefunction TypeError _check_signal _check_closedsignal set_wakeup_fd_csockfilenor#OSError RuntimeErrorstrrHandler*r siginterruptrinfoerrnoEINVAL)r+r:callbackargsexchandlenexcs radd_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsv  " "8 ,..x889 9 3  )  !3!3!5 6xtT:%+c"  MM#/ 0   U +G$ )s3x( ( ) %%c*((F((,"G,FKK >EEFyyELL("T#.?#@AA sZ-C.0D D.DD F'F"-EF"E2E-(F"-E220F""F'c |jj|}|y|jr|j|y|j |yr)r*get _cancelledr5_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signalsH@&&**3/ >      & &s +  ) )& 1rc |j| |j|=|tjk(rtj }ntj } tj|||js tjdyy#t$rYywxYw#t$r2}|jtjk(rtd|dd}~wwxYw#ttf$r }tjd|Yd}~yd}~wwxYw)NFrBrCr@rAT)rGr*KeyErrorrISIGINTdefault_int_handlerSIG_DFLrMrSrTrNrJr#rrR)r+r:handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handlers  3 %%c* &-- 00GnnG  MM#w '$$ A$$R(-   yyELL("T#.?#@AA  ( A :C@@ AsA BB9C BB C(-CCD ,DD c t|tstd||tjvrt d|y)Nzsig must be an int, not zinvalid signal number ) isinstanceintrFrI valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signalsO #s#6sg>? ? f**, ,5cU;< < -rc t|||||Sr)_UnixReadPipeTransportr+pipeprotocolwaiterextras r_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transports%dD(FEJJrc t|||||Sr)_UnixWritePipeTransportrks r_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transports&tT8VUKKrc lKtj5tjdtt j } ddd 5| j s td|j} t||||||||f| |d| } | j| j|j|  | d{ ddd| S#1swYxYw7#ttf$rt$r+| j!| j#d{7wxYw#1swY SxYww)NignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6catch_warnings simplefilterDeprecationWarningrget_child_watcher is_activerN create_future_UnixSubprocessTransportadd_child_handlerget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr1_wait) r+rmrVshellstdinstdoutstderrbufsizerokwargswatcherrntransps r_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transports/ $ $ &  ! !(,> ?..0G'$$& #$GHH'')F-dHdE,16676396/56F  % %fnn&6$($@$@& J  !0 9' &( 12    lln$$ '0 seD4/C D4A-D'>C!CC! D4CD4C!!;D$DD$$D''D1,D4c<|j|j|yr)call_soon_threadsafe_process_exited)r+pid returncoders rrz._UnixSelectorEventLoop._child_watcher_callbacks !!&"8"8*Er)sslsockserver_hostnamessl_handshake_timeoutssl_shutdown_timeoutcK|r |2td| td| td| td|| tdtj|}tjtjtj d} |j d|j||d{nf| td|jtjk7s|jtj k7rtd ||j d|j|||||| d{\}} || fS7#|jxYw7#w) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl0ssl_shutdown_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rr) r#r!fspathsocketAF_UNIX SOCK_STREAM setblocking sock_connectr1familytype_create_connection_transport) r+protocol_factorypathrrrrr transportrms rcreate_unix_connectionz-_UnixSelectorEventLoop.create_unix_connections & EGG* !NOO$0 GII#/ FHH   IKK99T?D==1C1CQGD   '''d333 | !BCC v~~-II!3!33 DTHMOO   U #$($E$E "C"7!5%F%77 8(""%4  7s=BE#&E 7E 8E E# E EE#dT)rbacklogrrr start_servingc Kt|tr td| |s td| |s td|| tdt j |}t j t jt j}|ddvrH tjt j|jrt j| |j#|nU| td |j*t jk7s|j,t jk7rtd ||j/d t1j2||g|||||} |r-| j5t7j8dd{| S#t$rYt$r!} tj d|| Yd} ~ d} ~ wwxYw#t$rT} |j%| j&t&j(k(r!d|d } tt&j(| dd} ~ w|j%xYw7w) Nz*ssl argument must be an SSLContext or Nonerrrr)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrF)rfboolrFr#r!rrrrstatS_ISSOCKst_moderemoveFileNotFoundErrorrMrerrorbindr1rS EADDRINUSErrrrServer_start_servingr sleep) r+rrrrrrrrerrrWmsgservers rcreate_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7 c4 HI I ,SCE E +CBD D   IKK99T?D==1C1CDDAwk)6}}RWWT]%:%:; $  $| CEE v~~-II!3!33 DTHMOO ##D4&2B$'2G$8:   ! ! #++a.  S)6LL"*+/666  99 0 00%TH,>?C!%"2"2C8dB  & !siBIAF'"G3B-I I!I' G0I2G:GIGI I 'AH66I  Ic K tj |j } tj|j}|r|n|}|sy|j} |j| d|||||d| d{S#t$rtjdwxYw#tt jf$r}tjdd}~wwxYw#t$rtjdwxYw7~w)Nzos.sendfile() is not availableznot a regular filer) r!sendfileAttributeErrorr SendfileNotAvailableErrorrLioUnsupportedOperationfstatst_sizerMr{_sock_sendfile_native_impl) r+rfileoffsetcountrLrfsize blocksizefuts r_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs 2 KK M[[]F MHHV$,,E#E   " ''T4(.y! Ey% 26602 2 2  7 78 M667KL L M M667KL L MsVC<BB"C6C<;C:<C<BC<"C;CCC<C77C<c |j} ||j||jr|j|||y|r/||z }|dkr%|j||||j |y t j | |||} | dk(r%|j||||j |y|| z }|| z }||j|||j| |j|| |||||| y#ttf$r;||j|||j| |j|| |||||| Yyt$r} |Q| jtjk(r4t| t ur#t!dtj} | | _| } |dk(r:t%j&d} |j||||j)| n)|j||||j)| Yd} ~ yYd} ~ yd} ~ wt*t,f$rt.$r.} |j||||j)| Yd} ~ yd} ~ wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL remove_writer cancelled_sock_sendfile_update_filepos set_resultr!r_sock_add_cancellation_callback add_writerrBlockingIOErrorInterruptedErrorrMrSENOTCONNrConnectionError __cause__r r set_exceptionrrr)r+r registered_fdrrLrrr total_sentfdsentrWnew_excrs rrz1_UnixSelectorEventLoop._sock_sendfile_native_implysT [[]  $   } - ==?  . .vvz J   *IA~2266:Nz*1 F;;r669=DJqy2266:Nz*$d"  (88dCD$C$CS "D& &y*F[ !12 B$44S$? OOB ? ?f"E9j B ')II/I_4 *-u~~?$'!Q !::-/2266:N!!#&2266:N!!#&&'-.   #  . .vvz J   c " " #s,:C??AIIB6HI+$IIcZ|dkDr&tj||tjyyNr)r!lseekSEEK_SET)r+rLrrs rrz4_UnixSelectorEventLoop._sock_sendfile_update_fileposs" > HHVVR[[ 1 rc6fd}|j|y)Ncv|jr(j}|dk7rj|yyy)Nr@)rrLr)rrr+rs rcbzB_UnixSelectorEventLoop._sock_add_cancellation_callback..cbs6}}[[]8&&r*r)add_done_callback)r+rrrs` ` rrz6_UnixSelectorEventLoop._sock_add_cancellation_callbacks + b!rrNN)__name__ __module__ __qualname__r)r1r>rZr<r5rGrprsrrrrrrrr __classcell__r-s@rr&r&9s # .(+Z2@ =@D(,KAE)-L 04BF*.0#4 "&!% 0#f*.Gs"&!% GR.DFL2"rr&ceZdZdZdfd ZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZddZdZdZxZS)rjic4t||||jd<||_||_|j |_||_d|_d|_ tj|j j}tj|sJtj|s5tj |s d|_d|_d|_t#dtj$|j d|jj'|jj(||jj'|j*|j |j,|,|jj't.j0|dyy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)_extra_loop_piperL_fileno _protocol_closing_pausedr!rrrS_ISFIFOrS_ISCHRr# set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r+looprlrmrnromoder-s rr)z_UnixReadPipeTransport.__init__s. " F  {{} !  xx %-- d# d# T"DJDL!DNHI I  e, T^^;;TB T--!\\4+;+; =   JJ !E!E!' / rc^|jsy|jj||yr) is_readingrr)r+rrUs rrz"_UnixReadPipeTransport._add_readers#  r8,rc:|j xr |j Sr)rrr+s rrz!_UnixReadPipeTransport.is_readings<<5 $55rct|jjg}|j|jdn|jr|jd|jd|j t |jdd}|jW|Utj||j tj}|r|jdnA|jdn/|j|jdn|jddjd j|S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r-rrappendrrgetattrrr _test_selector_event selectors EVENT_READformatjoin)r+rRr,r s r__repr__z_UnixReadPipeTransport.__repr__s''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (<(<>G I& F# ZZ # KK  KK !}}SXXd^,,rch tj|j|j}|r|jj |y|j jrtjd|d|_ |j j|j|j j|jj|j j|jdy#tt f$rYyt"$r}|j%|dYd}~yd}~wwxYw)N%r was closed by peerTz"Fatal read error on pipe transport)r!readrmax_sizer data_receivedr get_debugrrRr_remove_readerr eof_received_call_connection_lostrrrM _fatal_error)r+r=rWs rrz"_UnixReadPipeTransport._read_ready s G774<<7D ,,T2::'')KK 7> $  ))$,,7 $$T^^%@%@A $$T%?%?F !12   I   c#G H H Is*C<<D1 D1D,,D1c|jsyd|_|jj|j|jj rt jd|yy)NTz%r pauses reading)rrrrrrrdebugrs r pause_readingz$_UnixReadPipeTransport.pause_readingsP   !!$,,/ ::   ! LL,d 3 "rc|js |jsyd|_|jj|j|j |jj rtjd|yy)NFz%r resumes reading) rrrrrrrrr"rs rresume_readingz%_UnixReadPipeTransport.resume_reading%s[ ==   t||T-=-=> ::   ! LL-t 4 "rc||_yrrr+rms r set_protocolz#_UnixReadPipeTransport.set_protocol- !rc|jSrr'rs r get_protocolz#_UnixReadPipeTransport.get_protocol0 ~~rc|jSrrrs r is_closingz!_UnixReadPipeTransport.is_closing3 }}rc@|js|jdyyr)r_closers rr1z_UnixReadPipeTransport.close6s}} KK rcv|j-|d|t||jjyyNzunclosed transport r/rr8r1r+_warns r__del__z_UnixReadPipeTransport.__del__:5 :: ! 'x0/$ O JJ    "rc<t|trQ|jtjk(r4|jj rDt jd||dn*|jj||||jd|j|yNz%r: %sTexc_info)message exceptionrrm) rfrMrSEIOrrrr"call_exception_handlerrr3r+rWr?s rr z#_UnixReadPipeTransport._fatal_error?sr sG $eii)?zz##% XtWtD JJ - -" ! NN /  Crcd|_|jj|j|jj |j |yNT)rrrrrrr+rWs rr3z_UnixReadPipeTransport._closeMs9  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwrrconnection_lostrr1rrFs rrz,_UnixReadPipeTransport._call_connection_lostRg  NN * *3 / JJ   DJ!DNDJ JJ   DJ!DNDJ A 1A>rzFatal error on pipe transport)rrrrr)rrrrr#r%r)r,r0r1r6r7r9r r3rrrs@rrjrjs]H/<- 6-*G$45"%MM > rrjceZdZdfd ZdZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZdZddZddZdZxZS)rrct |||||jd<||_|j |_||_t|_d|_ d|_ tj|j j}tj|}tj |}tj"|} |s$|s"| s d|_d|_d|_t%dtj&|j d|j(j+|j j,|| s!|rdt.j0j3dsE|j(j+|j(j4|j |j6|,|j(j+t8j:|dyy)NrlrFz?Pipe transport is only for pipes, sockets and character devicesaix)r(r)rrrLrr bytearray_buffer _conn_lostrr!rrrrrrr#rrrrr2platform startswithrrr r) r+rrlrmrnroris_charis_fifo is_socketr-s rr)z _UnixWritePipeTransport.__init___si %" F {{} ! {  xx %--,,t$--%MM$' 7iDJDL!DNDE E  e, T^^;;TB )@)@)G JJ !7!7!%t/?/? A   JJ !E!E!' / rc|jjg}|j|jdn|jr|jd|jd|j t |jdd}|j{|ytj||j tj}|r|jdn|jd|j}|jd|n/|j|jdn|jdd jd j|S) Nrrrr r r zbufsize=r r r)r-rrrrrrrr rr EVENT_WRITEget_write_buffer_sizerr)r+rRr,r rs rrz _UnixWritePipeTransport.__repr__s ''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (=(=?G I& F#002G KK(7), - ZZ # KK  KK !}}SXXd^,,rc,t|jSr)lenrQrs rrZz-_UnixWritePipeTransport.get_write_buffer_sizes4<<  rc|jjrtjd||jr|j t y|j y)Nr)rrrrRrQr3BrokenPipeErrorrs rrz#_UnixWritePipeTransport._read_readys@ ::   ! KK/ 6 << KK) * KKMrct|tr t|}|sy|js |jrH|jt j k\rtjd|xjdz c_y|jss tj|j|}|t'|k(ry|dkDrt||d}|j(j+|j|j,|xj|z c_ |j/y#ttf$rd}Ytt f$rt"$r1}|xjdz c_|j%|dYd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr#Fatal write error on pipe transport)rfrP memoryviewrRrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrQr!writerrrrrrr r\r _add_writer _write_ready_maybe_pause_protocol)r+r=nrWs rrdz_UnixWritePipeTransport.writes7 dI &d#D  ??dmm)"M"MM HI OOq O || HHT\\40CI~Q!$'+ JJ " "4<<1B1B C   ""$$%56  12   1$!!#'LM s D$$E?7E?'E::E?c tj|j|j}|t |jk(r|jj |j j|j|j|jr6|j j|j|jdy|dkDr|jd|=yy#ttf$rYyttf$rt $rp}|jj |xj"dz c_|j j|j|j%|dYd}~yd}~wwxYw)Nrrr`)r!rdrrQr\r9r_remove_writer_maybe_resume_protocolrrrrrrrrrRr )r+rhrWs rrfz$_UnixWritePipeTransport._write_readys. %t||4AC %% ""$ ))$,,7++-==JJ--dll;..t4QLL!$) !12  -.   J LL   OOq O JJ % %dll 3   c#H I I  Js*C,,F=FA&E??FcyrErrs r can_write_eofz%_UnixWritePipeTransport.can_write_eofrc|jryd|_|jsL|jj|j|jj |j dyyrE)rrQrrrrrrs r write_eofz!_UnixWritePipeTransport.write_eofsO ==  || JJ % %dll 3 JJ !;!;T Brc||_yrr'r(s rr)z$_UnixWritePipeTransport.set_protocolr*rc|jSrr'rs rr,z$_UnixWritePipeTransport.get_protocolr-rc|jSrr/rs rr0z"_UnixWritePipeTransport.is_closingr1rcX|j|js|jyyyr)rrrprs rr1z_UnixWritePipeTransport.closes$ :: !$-- NN +8 !rcv|j-|d|t||jjyyr5r6r7s rr9z_UnixWritePipeTransport.__del__r:rc&|jdyr)r3rs rabortz_UnixWritePipeTransport.aborts Drct|tr4|jjrDt j d||dn*|jj ||||jd|j|yr<) rfrMrrrr"rBrr3rCs rr z$_UnixWritePipeTransport._fatal_error sc c7 #zz##% XtWtD JJ - -" ! NN /  Crc>d|_|jr%|jj|j|jj |jj |j|jj|j|yrE) rrQrrjrr9rrrrFs rr3z_UnixWritePipeTransport._closesf << JJ % %dll 3  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwrrHrFs rrz-_UnixWritePipeTransport._call_connection_lostrJrKrrLr)rrrr)rrZrrdrfrmrpr)r,r0r1r6r7r9rwr r3rrrs@rrrrr\sd#/J-0!!%F%8C" %MM  >rrrceZdZdZy)r|c d}|tjk(r6tjj drt j \}} tj|f||||d|d||_|=|jt|jd||j_ d}|!|j|jyy#|!|j|jwwxYw)NrOF)rrrruniversal_newlinesrwb) buffering) subprocessPIPEr2rSrTr socketpairPopen_procr1r detachr) r+rVrrrrrrstdin_ws r_startz_UnixSubprocessTransport._start+s JOO # (?(?(F $..0NE7 #))E!vf#('E=CEDJ" #'(8$'#R  "  #w"  #s A!C%C7N)rrrrrrrr|r|)s rr|c@eZdZ d dZdZdZdZdZdZdZ d Z y) rNc\|jtk7rtjdddyy)NrP{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.r)rrr6 _deprecated)clss r__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs, >>X %  !7;%, . &rc trNotImplementedErrorr+rrUrVs rr}z&AbstractChildWatcher.add_child_handler_s "##rc trrr+rs rremove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs 1 "##rc trrr+rs r attach_loopz AbstractChildWatcher.attach_looprs "##rc trrrs rr1zAbstractChildWatcher.close|s "##rc trrrs rrzzAbstractChildWatcher.is_actives "##rc trrrs r __enter__zAbstractChildWatcher.__enter__s *"##rc trrr+abcs r__exit__zAbstractChildWatcher.__exit__s(!##r)returnN) rrrrr}rrr1rzrrrrrrrAs/,. $$$$$$ $rrc>eZdZ dZdZdZdZdZdZdZ dZ y ) rc|Srrrs rrzPidfdChildWatcher.__enter__ rcyrr)r+exc_type exc_value exc_tracebacks rrzPidfdChildWatcher.__exit__ rcyrErrs rrzzPidfdChildWatcher.is_activernrcyrrrs rr1zPidfdChildWatcher.closerrcyrrrs rrzPidfdChildWatcher.attach_looprrctj}tj|}|j ||j ||||yr)rget_running_loopr! pidfd_openr_do_wait)r+rrUrVrpidfds rr}z#PidfdChildWatcher.add_child_handlers:&&( c"  sE8TJrc$tj}|j| tj|d\}}t |}tj||||g|y#t $rd}tjd|YCwxYw)NrzJchild process pid %d exit status already read: will report returncode 255) rrrr!waitpidr"ChildProcessErrorrrcr1) r+rrrUrVr_r$rs rrzPidfdChildWatcher._do_waits&&( E" 8 3*IAv07J j(4(! J NN.   sA++!BBcyrErrs rrz&PidfdChildWatcher.remove_child_handlerrN) rrrrrrzr1rr}rrrrrrrs0    K )&rrc6eZdZdZdZdZdZdZdZdZ y) BaseChildWatcherc d|_i|_yr)r _callbacksrs rr)zBaseChildWatcher.__init__s rc&|jdyr)rrs rr1zBaseChildWatcher.closes rcV|jduxr|jjSr)r is_runningrs rrzzBaseChildWatcher.is_actives#zz%A$***?*?*AArctrr)r+ expected_pids r _do_waitpidzBaseChildWatcher._do_waitpid !##rctrrrs r_do_waitpid_allz BaseChildWatcher._do_waitpid_allrrc^|j(|&|jrtjdt|j)|jj t j||_|;|jt j|j|jyy)NzCA loop is being detached from a child watcher with pending handlers) rrr6r7RuntimeWarningr5rISIGCHLDrZ _sig_chldrrs rrzBaseChildWatcher.attach_loops :: !dlt MM= :: ! JJ , ,V^^ <    # #FNNDNN C  " rc |jy#ttf$rt$r(}|jj d|dYd}~yd}~wwxYw)N$Unknown exception in SIGCHLD handler)r?r@)rrrrrrBrFs rrzBaseChildWatcher._sig_chldsX   "-.    JJ - -A /    sAAAN) rrrr)r1rzrrrrrrrrrs&B$$#( rrcNeZdZ fdZfdZdZdZdZdZdZ dZ xZ S) rcRt|tjdddy)Nrrrr)r(r)r6rr+r-s rr)zSafeChildWatcher.__init__s' /;%, .rcV|jjt| yr)rr9r(r1rs rr1zSafeChildWatcher.closes   rc|Srrrs rrzSafeChildWatcher.__enter__rrcyrrrs rrzSafeChildWatcher.__exit__rrcH||f|j|<|j|yr)rrrs rr}z"SafeChildWatcher.add_child_handler"s% ($/ rc> |j|=y#t$rYywxYwNTFrr`rs rrz%SafeChildWatcher.remove_child_handler(( $    cZt|jD]}|j|yrr4rrrs rrz SafeChildWatcher._do_waitpid_all/s#(C   S !)rc tj|tj\}}|dk(ryt|}|jj rt jd|| |jj|\}}|||g|y#t$r|}d}t jd|YOwxYw#t$r7|jj rt jd|dYyYywxYw)Nr$process %s exited with returncode %sr8Unknown child process pid %d, will report returncode 255'Child watcher got an unexpected pid: %rTr=) r!rWNOHANGr"rrrr"rrcrpopr`)r+rrr$rrUrVs rrzSafeChildWatcher._do_waitpid4s 7**\2::>KCax/7Jzz##% C):7 -!__005NHd S* ,t ,7! CJ NNJ   ( 3zz##%H"T3& 3s#'B-B?#B<;B<?;C?>C?) rrrr)r1rrr}rrrrrs@rrrs0.  " -rrcHeZdZ fdZfdZdZdZdZdZdZ xZ S)rct|tj|_i|_d|_tjdddy)Nrrrrr) r(r) threadingLock_lock_zombies_forksr6rrs rr)zFastChildWatcher.__init__asC ^^%   /;%, .rc|jj|jjt|yr)rr9rr(r1rs rr1zFastChildWatcher.closeks,    rct|j5|xjdz c_|cdddS#1swYyxYw)Nr)rrrs rrzFastChildWatcher.__enter__ps$ ZZ KK1 KZZs.7c>|j5|xjdzc_|js |js dddyt|j}|jj dddt j dy#1swY xYw)Nrz5Caught subprocesses termination from unknown pids: %s)rrrrOr9rrc)r+rrrcollateral_victimss rrzFastChildWatcher.__exit__vsp ZZ KK1 K{{$-- Z "%T]]!3  MM   !  C  Zs/B/BBc|j5 |jj|} ddd||g|y#t$r||f|j|<YdddywxYw#1swYA#A&"A##A&&A/c> |j|=y#t$rYywxYwrrrs rrz%FastChildWatcher.remove_child_handlerrrc tjdtj\}}|dk(ryt|}|j 5 |j j|\}}|jjrtjd|| dddtjd||n |||g#t$rYywxYw#t$r\|jrK||j|<|jjrtjd||Yddd4d}YwxYw#1swYxYw)Nr@rrz,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!rrr"rrrrrrrr"r`rrrc)r+rr$rrUrVs rrz FastChildWatcher._do_waitpid_alls8 < jjRZZ8 V !83F; 6%)__%8%8%=NHdzz++- %K%(*6!& #Z1j040K%   ${{-7 c*:://1"LL*>),j:! $H $sN'CD= C'2D= CCAD:*D=5D:7D=9D::D==E) rrrr)r1rrr}rrrrs@rrrWs+.    )(1rrcPeZdZ dZdZdZdZdZdZdZ dZ d Z d Z d Z y ) rcPi|_d|_tjdddy)Nrrrr)r_saved_sighandlerr6rrs rr)zMultiLoopChildWatcher.__init__s*!%4;%, .rc|jduSr)rrs rrzzMultiLoopChildWatcher.is_actives%%T11rcZ|jj|jytjtj }||j k7rtjdd|_ytjtj |jd|_y)Nz+SIGCHLD handler was changed by outside code) rr9rrI getsignalrrrrc)r+rds rr1zMultiLoopChildWatcher.closesz   ! ! ) ""6>>2 dnn $ NNH I"& MM&..$*@*@ A!%rc|Srrrs rrzMultiLoopChildWatcher.__enter__rrcyrrr+rexc_valexc_tbs rrzMultiLoopChildWatcher.__exit__rrcrtj}|||f|j|<|j|yr)rrrr)r+rrUrVrs rr}z'MultiLoopChildWatcher.add_child_handlers5&&( $h5 rc> |j|=y#t$rYywxYwrrrs rrz*MultiLoopChildWatcher.remove_child_handlerrrc8|jytjtj|j|_|j*t j dtj |_tjtjdy)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rrIrrrrcrcrQrs rrz!MultiLoopChildWatcher.attach_loopso  ! ! - !'v~~t~~!N  ! ! ) NNJ K%+^^D " FNNE2rcZt|jD]}|j|yrrrs rrz%MultiLoopChildWatcher._do_waitpid_alls#(C   S !)rc* tj|tj\}}|dk(ryt|}d} |jj|\}}}|jrt j d||y|r'|jrt jd|||j|||g|y#t$r|}d}t j d|d}YwxYw#t$rt j d|d YywxYw) NrTrrF%Loop %r that handles pid %r is closedrrr=)r!rrr"rrrcrr is_closedrr"rr`) r+rrr$r debug_logrrUrVs rrz!MultiLoopChildWatcher._do_waitpids  **\2::>KCax/7JI L#'??#6#6s#; D(D~~FcR!1LL!G!-z;)))(CKdK=! CJ NNJ I $ / NND / /s"'CC.%C+*C+.!DDc |jy#ttf$rt$rt j ddYywxYw)NrTr=)rrrrrrc)r+rrs rrzMultiLoopChildWatcher._sig_chld<sE R  "-.   R NNAD Q Rs/AAN)rrrr)rzr1rrr}rrrrrrrrrrsA $.2 & 3""#LJRrrcbeZdZ dZdZdZdZdZejfdZ dZ dZ d Z d Zy ) rcFtjd|_i|_yr) itertoolsr _pid_counter_threadsrs rr)zThreadedChildWatcher.__init__Rs%OOA. rcyrErrs rrzzThreadedChildWatcher.is_activeVrnrcyrrrs rr1zThreadedChildWatcher.closeYrrc|Srrrs rrzThreadedChildWatcher.__enter__\rrcyrrrs rrzThreadedChildWatcher.__exit___rrct|jjDcgc]}|jr|}}|r||jdt |yycc}w)Nz0 has registered but not finished child processesr/)r4r valuesis_aliver-r8)r+r8threadthreadss rr9zThreadedChildWatcher.__del__bse(,T]]-A-A-C(D)(Dfoo'(D)  T^^$$TU!  )sA!ctj}tj|jdt |j ||||fd}||j|<|jy)Nzasyncio-waitpid-T)targetnamerVdaemon) rrrThreadrnextr r start)r+rrUrVrrs rr}z&ThreadedChildWatcher.add_child_handlerjsf&&(!!)9)9)9$t?P?P:Q9R'S(,c8T'B)-/$ c rcyrErrs rrz)ThreadedChildWatcher.remove_child_handlersrrcyrrrs rrz ThreadedChildWatcher.attach_loopyrrc tj|d\}}t|}|jrt j d|| |jrt jd||n|j|||g||jj|y#t $r|}d}t jd|Y~wxYw)Nrrrrr) r!rr"rrr"rrcrrr r)r+rrrUrVrr$rs rrz ThreadedChildWatcher._do_waitpid|s 7**\15KC07J~~ C):7 >>  NNBD# N %D % %hZ G$ G ,''! CJ NNJ   sB''#C  C N)rrrr)rzr1rrr6r7r9r}rrrrrrrrEsB   %MM  (rrcttdsy tj}tjtj|dy#t $rYywxYw)NrFrT)hasattrr!getpidr1rrM)rs r can_use_pidfdr"sO 2| $iik sA&'  s=A AAc@eZdZ eZfdZdZfdZdZdZ xZ S)_UnixDefaultEventLoopPolicyc0t|d|_yr)r(r)_watcherrs rr)z$_UnixDefaultEventLoopPolicy.__init__s  rctj5|j)trt |_nt |_dddy#1swYyxYwr)rrr&r"rrrs r _init_watcherz)_UnixDefaultEventLoopPolicy._init_watchers6 \\}}$ ?$5$7DM$8$:DM \\s 6AAc t|||jEtjtj ur|jj |yyyr)r(set_event_loopr&rcurrent_thread main_threadr)r+rr-s rr*z*_UnixDefaultEventLoopPolicy.set_event_loopsX  t$ MM %((*i.C.C.EE MM % %d +F &rc |j|jtjddd|jS)Nryrrr)r&r(r6rrs rryz-_UnixDefaultEventLoopPolicy.get_child_watchersE  ==    0:BI K}}rc |j|jj||_tjdddy)Nset_child_watcherrrr)r&r1r6r)r+rs rr/z-_UnixDefaultEventLoopPolicy.set_child_watchersB2 == $ MM   ! 0:BI Kr) rrrr& _loop_factoryr)r(r*ryr/rrs@rr$r$s%D*M; ,  Krr$)3rSrr r!rrIrrrr2rr6rrrrrr r r r r logr__all__rS ImportErrorrr"BaseSelectorEventLoopr& ReadTransportrj_FlowControlMixinWriteTransportrrBaseSubprocessTransportr|rrrrrrrr"BaseDefaultEventLoopPolicyr$rrrrrr;se8     <<7 C DD P"_BBP"f MZ55M`Jj::(77JZ FF 0S$S$l7,7t2+2jN-'N-bj1'j1Z~R0~RBO(/O(b 6K&"C"C6Kr+4r__pycache__/sslproto.cpython-312.pyc000064400000121646152343231170013357 0ustar00 ֦i|zddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl m Z eejejfZGdd ejZGd d ejZd Zd ZGdde j(e j*ZGddej.Zy#e$rdZYwxYw)N) constants) exceptions) protocols) transports)loggerc eZdZdZdZdZdZdZy)SSLProtocolState UNWRAPPED DO_HANDSHAKEWRAPPEDFLUSHINGSHUTDOWNN)__name__ __module__ __qualname__r r r rr)/usr/lib64/python3.12/asyncio/sslproto.pyr r sI!LGHHrr ceZdZdZdZdZdZy)AppProtocolState STATE_INITSTATE_CON_MADE STATE_EOFSTATE_CON_LOSTN)rrrrrrrrrrrrsJ%NI%NrrcZ|r tdtj}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslcreate_default_contextcheck_hostname) server_sideserver_hostname sslcontexts r_create_transport_contextr$/s2CDD ++-J $) ! rc|||dz}n |}d|z}n|}||dz}n|}||cxk\rdk\sntd|d|d||fS)Nirzhigh (z) must be >= low (z) must be >= 0)r)highlowkbhilos radd_flowcontrol_defaultsr,=sh | ;dBBRB  { 1W  =q=b"# # r6MrceZdZdZej j ZdZddZ dZ dZ dZ dZ efd Zd Zd Zd Zdd ZdZdZddZdZdZedZdZdZdZdZdZdZ dZ!y)_SSLProtocolTransportTc.||_||_d|_y)NF)_loop _ssl_protocol_closed)selfloop ssl_protocols r__init__z_SSLProtocolTransport.__init__Xs ) rNc:|jj||S)z#Get optional transport information.)r1_get_extra_infor3namedefaults rget_extra_infoz$_SSLProtocolTransport.get_extra_info]s!!11$@@rc:|jj|yN)r1_set_app_protocol)r3protocols r set_protocolz"_SSLProtocolTransport.set_protocolas ,,X6rc.|jjSr>)r1 _app_protocolr3s r get_protocolz"_SSLProtocolTransport.get_protocolds!!///rcR|jxs|jjSr>)r2r1_is_transport_closingrDs r is_closingz _SSLProtocolTransport.is_closinggs ||It11GGIIrcn|js"d|_|jjyd|_y)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)r2r1_start_shutdownrDs rclosez_SSLProtocolTransport.closejs,||DL    . . 0!%D rcX|jsd|_|jdtyy)NTz9unclosed transport )r2warnResourceWarning)r3 _warningss r__del__z_SSLProtocolTransport.__del__xs)||DL NN* ,rc0|jj Sr>)r1_app_reading_pausedrDs r is_readingz _SSLProtocolTransport.is_readings%%9999rc8|jjy)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r1_pause_readingrDs r pause_readingz#_SSLProtocolTransport.pause_readings ))+rc8|jjy)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r1_resume_readingrDs rresume_readingz$_SSLProtocolTransport.resume_readings **,rcp|jj|||jjy)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1_set_write_buffer_limits_control_app_writingr3r'r(s rset_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limitss,& 33D#> //1rcZ|jj|jjfSr>)r1_outgoing_low_water_outgoing_high_waterrDs rget_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits*""66""779 9rc6|jjS)z-Return the current size of the write buffers.)r1_get_write_buffer_sizerDs rget_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_sizes!!88::rcp|jj|||jjy)aSet the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1_set_read_buffer_limits_control_ssl_readingr]s rset_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limitss,& 224= //1rcZ|jj|jjfSr>)r1_incoming_low_water_incoming_high_waterrDs rget_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limitsrcrc6|jjS)z+Return the current size of the read buffer.)r1_get_read_buffer_sizerDs rget_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_sizes!!7799rc.|jjSr>)r1_app_writing_pausedrDs r_protocol_pausedz&_SSLProtocolTransport._protocol_pauseds!!555rct|tttfs!t dt |j |sy|jj|fy)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearray memoryview TypeErrortyperr1_write_appdatar3datas rwritez_SSLProtocolTransport.writesX $ : >?##':#6#6"79: :  ))4'2rc:|jj|y)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)r1r|)r3 list_of_datas r writelinesz _SSLProtocolTransport.writeliness )),7rct)zuClose the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. )NotImplementedErrorrDs r write_eofz_SSLProtocolTransport.write_eofs "!rcy)zAReturn True if this transport supports write_eof(), False if not.FrrDs r can_write_eofz#_SSLProtocolTransport.can_write_eofsrc&|jdy)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N) _force_closerDs rabortz_SSLProtocolTransport.aborts $rcbd|_|j|jj|yyNT)r2r1_abortr3excs rrz"_SSLProtocolTransport._force_closes.    )    % %c * *rc|jjj||jxjt |z c_yr>)r1_write_backlogappend_write_buffer_sizelenr}s r_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7 ))006 --T:-rr>NN)"rrr_start_tls_compatibler _SendfileModeFALLBACK_sendfile_compatibler6r<rArErHrKwarningsrPrSrVrYr^rbrfrjrnrqpropertyrtrrrrrrrrrrr.r.Rs!$22;; A70J &!),:,-2,9;2,9:66 38" + ;rr.c eZdZdZdZdZdZ d+dZdZd,dZ dZ dZ dZ d Z d Zd Zd Zd,d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d-d"Z&d#Z'd$Z(d%Z)d-d&Z*d'Z+d(Z,d)Z-d.d*Z.y)/ SSLProtocoliNc t tdt|j|_t |j|_|tj}n|dkrtd|| tj} n| dkrtd| |s t||}||_ |r |s||_ nd|_ ||_t||_t#j$|_d|_||_||_|j/|d|_d|_d|_||_| |_tj:|_tj:|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j|_)d|_*d|_+d|_,d|_-d|_.|j_d|_0d|_1d|_2d|_3|ji|jky)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r RuntimeErrorrxmax_size _ssl_bufferry_ssl_buffer_viewrSSL_HANDSHAKE_TIMEOUTrSSL_SHUTDOWN_TIMEOUTr$ _server_side_server_hostname _sslcontextdict_extra collectionsdequerr_waiterr0r?_app_transport_app_transport_created _transport_ssl_handshake_timeout_ssl_shutdown_timeout MemoryBIO _incoming _outgoingr r _state _conn_lostrr _app_staterwrap_bio_sslobj_ssl_writing_pausedrR_ssl_reading_pausedrmrlrh _eof_receivedrsrar`r[_get_app_transport) r3r4 app_protocolr#waiterr!r"call_connection_madessl_handshake_timeoutssl_shutdown_timeouts rr6zSSLProtocol.__init__sE ;@A A$T]]3 *4+;+; < ($-$C$C ! "a ',-/0 0 '#,#A#A !Q &+,./ /2_.J( ;$3D !$(D !%j1 *//1"#   |,"&+#&;#%9"&00  .99DO.==DO''00 NNDNN)) 1113 $) #( #( $%!#$  $$&"#( $%!#$  %%' !rc||_t|drDt|tjr*|j |_|j|_d|_ yd|_ y)N get_bufferTF) rChasattrrvrBufferedProtocolr_app_protocol_get_bufferbuffer_updated_app_protocol_buffer_updated_app_protocol_is_buffer)r3rs rr?zSSLProtocol._set_app_protocolasP) L, /<)C)CD,8,C,CD )0<0K0KD -+/D (+0D (rc|jy|jjs@|#|jj|d|_y|jjdd|_yr>)r cancelled set_exception set_resultrs r_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ <<  ||%%' **3/  ''- rc|j9|jr tdt|j||_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)rrrr.r0rDs rrzSSLProtocol._get_app_transportvsJ    &**"#IJJ"7 D"ID *.D '"""rcV|jduxr|jjSr>)rrHrDs rrGz!SSLProtocol._is_transport_closing~s#d*Kt/I/I/KKrc2||_|jy)zXCalled when the low-level connection is made. Start the SSL handshake. N)r_start_handshake)r3 transports rconnection_madezSSLProtocol.connection_mades $ rcH|jj|jj|xjdz c_|j d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$||j'tj(d|_d|_d|_|j-||j.r!|j.j1d|_|j2r"|j2j1d|_yy)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). rNT)rclearrreadrrr2rr r rrrrrr0 call_soonrCconnection_lost _set_stater rr_shutdown_timeout_handlecancel_handshake_timeout_handlers rrzSSLProtocol.connection_losts9 !!#  1    **.D   ' ;;*77 7#3#B#BB#3#=#=="2"A"A $$T%7%7%G%GM (223"! C  ( (  ) ) 0 0 2,0D )  ) )  * * 1 1 3-1D * *rc|}|dks||jkDr |j}t|j|kr*t||_t |j|_|j SNr)rrrrxryr)r3nwants rrzSSLProtocol.get_buffers` 19t}},==D t 4 '(D $.t/?/?$@D !$$$rc|jj|jd||jtj k(r|j y|jtjk(r|jy|jtjk(r|jy|jtjk(r|jyyr>) rrrrr r _do_handshaker _do_readr _do_flushr _do_shutdown)r3nbytess rrzSSLProtocol.buffer_updateds T227F;< ;;*77 7    [[,44 4 MMO [[,55 5 NN  [[,55 5    6rcd|_ |jjrtjd||j t jk(r|jty|j t jk(r=|jt j|jry|jy|j t jk(r@|j|jt j |j#y|j t j k(r|j#yy#t$$r|j&j)wxYw)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Tz%r received EOFN)rr0 get_debugrdebugrr r _on_handshake_completeConnectionResetErrorr rrrRr _do_writerr ExceptionrrKrDs r eof_receivedzSSLProtocol.eof_receiveds" zz##% .5{{.;;;++,@A 0 8 88 0 9 9:++NN$ 0 9 99  0 9 9:!!# 0 9 99!!#:  OO ! ! #  s&A"E,AE5EAE#-E%E7c||jvr|j|S|j|jj||S|Sr>)rrr<r9s rr8zSSLProtocol._get_extra_infosC 4;; ;;t$ $ __ (??11$@ @Nrc&d}|tjk(rd}n|jtjk(r|tjk(rd}n|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tj k(rd}|r||_ytdj|j|)NFTz!cannot switch state from {} to {}) r r rr r rrrformat)r3 new_statealloweds rrzSSLProtocol._set_states (22 2G KK+55 5 )66 6G KK+88 8 )11 1G KK+33 3 )22 2G KK+44 4 )22 2G #DK3::KK,- -rcnjjr6tjdjj _nd_j tjjjjfd_ jy)Nz%r starts SSL handshakec$jSr>)_check_handshake_timeoutrDsrz.SSLProtocol._start_handshake..$s$*G*G*Ir) r0rrrtime_handshake_start_timerr r call_laterrrrrDs`rrzSSLProtocol._start_handshakes ::   ! LL2D 9)-):D &)-D & (556 JJ ! !$"="="I K & rc|jtjk(r+d|jd}|j t |yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)rr r r _fatal_errorConnectionAbortedError)r3msgs rrz$SSLProtocol._check_handshake_timeout(sN ;;*77 76../0*+    4S9 : 8rc |jj|jdy#t$r|j Yyt j $r}|j|Yd}~yd}~wwxYwr>)r do_handshakerSSLAgainErrors_process_outgoingrSSLErrorrs rrzSSLProtocol._do_handshake1sb . LL % % '  ' ' -  %  " " $|| -  ' ' , , -s.A6 A6A11A6c|j!|jjd|_|j} | |jtj n||j }|jjrA|jj!|j"z }t%j&d||dz|j(j+||j-|j/||j0t2j4k(r>t2j6|_|j8j;|j=|j|j?y#t$rm}d}|jtjt|tjrd}nd}|j|||j|Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compression ssl_object) rrrrr r getpeercertrr rvrCertificateErrorrrr0rrrrrrupdater r rrrrrCrrr)r3 handshake_excsslobjrrrdts rrz"SSLProtocol._on_handshake_complete;s  ) ) 5  * * 1 1 3-1D * $ 0 8 89##))+H ::   !"T%?%??B LL94c J H"(--/'-'9'9';&,  . ??.99 9.==DO    . .t/F/F/H I  1  M OO,66 7#s334I,   c3 '    $  s4F G7 A#G22G7cjtjtjtjfvryj dj _jtjk(rjdyjtjjjjfd_ jy)NTc$jSr>)_check_shutdown_timeoutrDsrrz-SSLProtocol._start_shutdown..us446r)rr rrr rr2r rrr0rrrrrDs`rrJzSSLProtocol._start_shutdownds KK )) )) **      **.D   ' ;;*77 7 KK  OO,55 6,0JJ,A,A**6-D ) NN rc|jtjtjfvr/|jj t jdyy)NzSSL shutdown timed out)rr rrrrr TimeoutErrorrDs rrz#SSLProtocol._check_shutdown_timeoutysN KK )) ))  OO ( (''(@A C  rc|j|jtj|j yr>)rrr rrrDs rrzSSLProtocol._do_flushs*  (112 rcJ |js|jj|j|j |j dy#t $r|jYytj$r}|j |Yd}~yd}~wwxYwr>) rrunwrapr_call_eof_received_on_shutdown_completerrrrs rrzSSLProtocol._do_shutdowns -%% ##%  " " $  # # %  & &t , %  " " $|| ,  & &s + + ,s&AB"5B"BB"c|j!|jjd|_|r|j|y|jj |j j yr>)rrrr0rrrK)r3 shutdown_excs rrz!SSLProtocol._on_shutdown_completesU  ( ( 4  ) ) 0 0 2,0D )    l + JJ !6!6 7rc|jtj|j|jj |yyr>)rr r rrrs rrzSSLProtocol._aborts6 (223 ?? & OO ( ( - 'rc8|jtjtjtjfvrH|j t jk\rtjd|xj dz c_y|D];}|jj||xjt|z c_ = |jtjk(r|jyy#t $r}|j#|dYd}~yd}~wwxYw)NzSSL connection is closedrFatal error on SSL protocol)rr rrr rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrrrr rrr)r3rr~exs rr|zSSLProtocol._write_appdatas KK )) )) **  )"M"MM9: OOq O  D    & &t ,  # #s4y 0 #! A{{.666 7 A   b"? @ @ As-C44 D=DDc~ |jr|jd}|jj|}t|}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr|j y#t $rYwxYwr)rrrrrrr)r3r~countdata_lens rrzSSLProtocol._do_writes %%**1- **40t98#-1%&\D''*++u4+++A.++x7+%%     sBB00 B<;B<c|js@|jj}t|r|jj ||j yr>)rrrrrrr\r}s rrzSSLProtocol._process_outgoingsB''>>&&(D4y%%d+ !!#rc|jtjtjfvry |jsZ|j r|j n|j|jr|jn|j|jy#t$r}|j|dYd}~yd}~wwxYw)Nr )rr r rrRr_do_read__buffered_do_read__copiedrrrrirr)r3r#s rrzSSLProtocol._do_reads KK (( ))    A++//++-))+&&NN$**,  % % ' A   b"? @ @ AsA6B&& C /CC cd}d}jj}t|} jj ||}|dkDrY|}||kr4jj ||z ||d}|dkDr||z }nn$||kr4j j fd|dkDrj||s!jjyy#t$rYEwxYw)Nrrc$jSr>)rrDsrrz0SSLProtocol._do_read__buffered..s r) rrprrrr0rrrrrJ)r3offsetr%bufwantss` rr)zSSLProtocol._do_read__buffereds++D,F,F,HIC LL%%eS1Eqyun LL--efnc&'lKEqy% unJJ(()@A A:  - -f 5  # # %  "    sAC% C%% C10C1cd}d}d} |jj|j}|sn$|rd}d}|}n|rd}|g}nj|L |r|j j n,|s*|j j dj|s!|j|jyy#t$rYywxYw)N1TFr) rrrrrrC data_receivedjoinrrJ)r3chunkzeroonefirstr~s rr*zSSLProtocol._do_read__copied s  ))$--8 DC!EC!5>DKK&     , ,U 3    , ,SXXd^ <  # # %  "    sA C CCc> |jtjk(rHtj|_|jj }|rt jdyyy#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received()) rrrrrCrrr"KeyboardInterrupt SystemExit BaseExceptionr)r3 keep_openr#s rrzSSLProtocol._call_eof_received(s B"2"A"AA"2"<"< ..;;= NN$BCB ":.   B   b"@ A A BsA#A((BBBcZ|j}||jk\r/|js#d|_ |jj y||jkr0|jr#d|_ |jjyyy#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exceptionrr@Fz protocol.resume_writing() failed) rerarsrC pause_writingr9r:r;r0call_exception_handlerrr`resume_writing)r3sizers rr\z SSLProtocol._control_app_writing7s$**, 4,, ,T5M5M'+D $ ""002T-- -$2J2J',D $ ""1133K -&z2    11@!$!%!4!4 $ 3 &z2    11A!$!%!4!4 $ 3 s/B2CC'*CCD*6*D%%D*cH|jj|jzSr>)rpendingrrDs rrez"SSLProtocol._get_write_buffer_sizeTs~~%%(?(???rc\t||tj\}}||_||_yr>)r,r!FLOW_CONTROL_HIGH_WATER_SSL_WRITErar`r]s rr[z$SSLProtocol._set_write_buffer_limitsWs., #yBBD c$(!#& rcd|_yr)rRrDs rrUzSSLProtocol._pause_reading_s #' rcnjr(d_fd}jj|yy)NFcjtjk(rjyjtjk(rj yjtj k(rjyyr>)rr r rrrrrrDsrresumez+SSLProtocol._resume_reading..resumefs`;;"2":"::MMO[[$4$=$==NN$[[$4$=$==%%'>r)rRr0r)r3rLs` rrXzSSLProtocol._resume_readingbs2  # #',D $ ( JJ  ( $rc|j}||jk\r.|js"d|_|jj y||j kr/|jr"d|_|jj yyy)NTF)rprmrrrVrlrY)r3rDs rriz SSLProtocol._control_ssl_readingqsu))+ 4,, ,T5M5M'+D $ OO ) ) + T-- -$2J2J',D $ OO * * ,3K -rc\t||tj\}}||_||_yr>)r,r FLOW_CONTROL_HIGH_WATER_SSL_READrmrlr]s rrhz#SSLProtocol._set_read_buffer_limitszs., #yAAC c$(!#& rc.|jjSr>)rrFrDs rrpz!SSLProtocol._get_read_buffer_sizes~~%%%rc.|jrJd|_y)z\Called when the low-level transport's buffer goes over the high-water mark. TN)rrDs rrAzSSLProtocol.pause_writings++++#' rcN|jsJd|_|jy)z^Called when the low-level transport's buffer drains below the low-water mark. FN)rrrDs rrCzSSLProtocol.resume_writings'''''#(   rcf|jr|jj|t|tr5|jj rt jd||dyyt|tjs+|jj|||j|dyy)Nz%r: %sT)exc_infor>) rrrvOSErrorr0rrrrCancelledErrorrB)r3rr?s rrzSSLProtocol._fatal_errors ?? OO ( ( - c7 #zz##% XtWtD&C!:!:; JJ - -" !__ / r)zFatal error on transport)/rrrrrrrr6r?rrrGrrrrrr8rrrrrrJrrrrrr|rrrr)r*rr\rer[rUrXrirhrprArCrrrrrrsH  $#59&*'+&* Q"f 1#L "2H%  !F$-P ;.%R*C -8.A0! $A,#:#< B:@'( )-' & (! rr)renumrr ImportErrorrrrrlogrSSLWantReadErrorSSLSyscallErrorrEnumr rr$r,_FlowControlMixin Transportr.rrrrrr`s  ?**C,?,?@Ntyy &tyy & *r;J88&00r;jZ ),,Z { CsB00B:9B:__pycache__/trsock.cpython-312.opt-2.pyc000064400000011335152343231170013730 0ustar00 ֦i  ddlZGddZy)NceZdZ dZdejfdZedZedZedZ dZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZy)TransportSocket_socksockc||_yNr)selfrs '/usr/lib64/python3.12/asyncio/trsock.py__init__zTransportSocket.__init__s  c.|jjSr )rfamilyr s r rzTransportSocket.familyszz   r c.|jjSr )rtypers r rzTransportSocket.typeszzr c.|jjSr )rprotors r rzTransportSocket.protoszzr crd|jd|jd|jd|j}|jdk7r4 |j }|r|d|} |j}|r|d|}|dS#t j $rY4wxYw#t j $rY3wxYw) Nz)filenorrr getsocknamesocketerror getpeername)r sladdrraddrs r __repr__zTransportSocket.__repr__s*4;;=/:kk_GDII=9ZZL " ;;=B  ((*#XeW-A ((*#XeW-AAw<<   <<  s$B)B BB B65B6ctd)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrs r __getstate__zTransportSocket.__getstate__5sIJJr c6|jjSr )rrrs r rzTransportSocket.fileno8szz  ""r c6|jjSr )rduprs r r&zTransportSocket.dup;szz~~r c6|jjSr )rget_inheritablers r r(zTransportSocket.get_inheritable>szz))++r c:|jj|yr )rshutdown)r hows r r*zTransportSocket.shutdownAs C r c:|jj|i|Sr )r getsockoptr argskwargss r r-zTransportSocket.getsockoptFs$tzz$$d5f55r c<|jj|i|yr )r setsockoptr.s r r2zTransportSocket.setsockoptIs t.v.r c6|jjSr )rrrs r rzTransportSocket.getpeernameLzz%%''r c6|jjSr )rrrs r rzTransportSocket.getsocknameOr4r c6|jjSr )r getsockbynamers r r7zTransportSocket.getsockbynameRszz''))r c$|dk(rytd)Nrzr r rrsIV]]!!  .K# ,! 6/((*L Cr r)rrr>r r rHs ^C^Cr __pycache__/tasks.cpython-312.opt-2.pyc000064400000075231152343231170013555 0ustar00 ֦i dZddlZddlZddlZddlZddlZddlZddlZddl Z ddlm Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZej$dj&Zd.d Zd.d Zd ZGddej0ZeZ ddlZej2xZZddddZej j>Zej j@Z ej jBZ!de!ddZ"dZ#dZ$dZ%dZ&dddZ'ejPdZ)d.dZ*dddZ+GddejXZ-d d!d"Z.d#Z/d$Z0d%Z1e1eZ2e jfZ4e5Z6iZ7d&Z8d'Z9d(Z:d)Z;d*ZeZ?e8Z@e9ZAe=ZBe>ZCe:ZDe;ZEeZ>m:Z:m;Z;mZKe:ZLe;ZMeD!  #t+AFFH D >>   FADy   >sB0B#BBc| |j}||yy#t$rtjdtdYywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.) stacklevel)set_nameAttributeErrorwarningswarnDeprecationWarning)tasknamer9s r'_set_task_namer@FsM  }}H TN 8 MM9)Q 8 8s %AAceZdZ dZdddddfd ZfdZeeZdZ dZ d Z d Z d Z d Zd ZdddZddddZddZdZdZdZddZfdZdZxZS)rTNFr&r?context eager_startcFt|||jr |jd=tj|sd|_t d||dt|_nt||_d|_ d|_ d|_ ||_ |tj|_n||_|r+|j"j%r|j'y|j"j)|j*|j t-|y)Nr%Fza coroutine was expected, got zTask-rrC)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr_num_cancels_requested _must_cancel _fut_waiter_coro contextvars copy_context_context_loop is_running_Task__eager_start call_soon _Task__stepr)selfcoror&r?rCrD __class__s r'rIz Task.__init__os d#  ! !&&r*%%d+).D %messagesource_traceback) _stater_PENDINGrLrJrXcall_exception_handlerrH__del__)r]rCr_s r'rfz Task.__del__sb ;;'** *t/H/HBG%%.2.D.D*+ JJ - -g 6 r(c,tj|Sr!)r _task_reprr]s r'__repr__z Task.__repr__s$$T**r(c|jSr!)rTris r'get_coroz Task.get_coro zzr(c|jSr!)rWris r' get_contextzTask.get_contexts }}r(c|jSr!)rOris r'get_namez Task.get_namermr(c$t||_yr!)rPrO)r]values r'r9z Task.set_names Z r(ctd)Nz*Task does not support set_result operationr-)r]results r' set_resultzTask.set_resultsGHHr(ctd)Nz-Task does not support set_exception operationru)r] exceptions r' set_exceptionzTask.set_exceptionsJKKr()limitc0 tj||Sr!)r_task_get_stack)r]r{s r' get_stackzTask.get_stacks ())$66r()r{filec2 tj|||Sr!)r_task_print_stack)r]r{rs r' print_stackzTask.print_stacks ++D%>>r(c d|_|jry|xjdz c_|j|jj |ryd|_||_y)NFrmsgT)_log_tracebackr1rQrScancelrR_cancel_message)r]rs r'rz Task.cancelsk *$ 99; ##q(#    '&&3&/ "r(c |jSr!rQris r' cancellingzTask.cancellings ***r(cd |jdkDr|xjdzc_|jS)Nrrrris r'uncancelz Task.uncancels4   & & *  ' '1 , '***r(cpt|j|} t| |jj |j dt | t|j|}|jr d|_d}yt|y#t |wxYw#|jr d|_d}wt|wxYw# t|j|}|jr d|_d}wt|w#|jr d|_d}wt|wxYwxYwr!) _swap_current_taskrX_register_eager_taskrWrun!_Task__step_run_and_handle_result_unregister_eager_taskr1rTr)r] prev_taskcurtasks r' __eager_startzTask.__eager_starts&tzz48  )  & - !!$"C"CTJ&t, ),TZZC99;!%DJD"4('t, 99;!%DJD"4( ),TZZC99;!%DJD"4( 99;!%DJD"4(sF C &B C B# B  C #'C  D5D %&D5 'D22D5c|jrtjd|d||jr1t |tj s|j }d|_d|_t|j| |j|t|j|d}y#t|j|d}wxYw)Nz_step(): already done: z, F) r1rInvalidStateErrorrR isinstanceCancelledError_make_cancelled_errorrSrrXrr)r]excs r'__stepz Task.__step#s 99;..)$C7;= =   c:#<#<=002 %D DJJ%   - -c 2  D )D  D )Ds B11C c|j} ||jd}n|j|}t|dd}|lt j ||j urGtd|d|d}|j j|j||jd}y|r||urCtd|}|j j|j||jd}yd|_ |j|j|j||_|jrN|jj!|j"r'd|_ d}ytd |d |}|j j|j||j d}y|4|j j|j|jd}yt%j&|rFtd |d |}|j j|j||jd}ytd |}|j j|j||j d}yd}y#t($rS}|jr"d|_t*|A|j"nt*|Y|j.Yd}~d}yd}~wt0j2$r!}||_t*|AYd}~d}yd}~wt6t8f$r}t*|u|d}~wt<$r}t*|u|Yd}~d}yd}~wwxYw#d}wxYw) N_asyncio_future_blockingzTask z got Future z attached to a different looprGzTask cannot await on itself: Frz-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rTsendthrowgetattrrr0rXr-r[r\rWradd_done_callback _Task__wakeuprSrRrrinspect isgenerator StopIterationrHrwrsrr_cancelled_excKeyboardInterrupt SystemExitrz BaseException)r]rr^rvblockingnew_excr_s r'__step_run_and_handle_resultz!Task.__step_run_and_handle_result4sezzG {4C$v'A4HH#$$V,DJJ>*x|!*$ACDGJJ(( Wdmm)EPDM~".;D8D#F ,, KK$---IDD?;@700 MM4==1B+1(,,#//66(,(<(< 7 >49 10D-+##'(& <=GJJ(( Wdmm)E&D! $$T[[$--$HD$$V,&))-vjBC $$KK$--%AD ')=fZ'HI $$KK$--%AD4DA .  $)!4#7#78"399-tDs(( "%D  GN  lDk":.  G !# &  ' G !# & &bDe 'dDs%JA5M,AM5A0M)AM03M&AMAM MAKMM5L MM#L33 M?MMMMM!c |j|jd}y#t$r}|j|Yd}~d}yd}~wwxYwr!)rvr\r)r]futurers r'__wakeupz Task.__wakeupsH  MMO KKM  KK   s% A AA r!)__name__ __module__ __qualname__rLrIrf classmethodr__class_getitem__rjrlrorqr9rwrzr~rrrrrZr\rr __classcell__r_s@r'rrSs+. %)d"!> $L1+ IL"&7.$(d ?(T+ +)&"IVr(rr?rCc tj}||j|}n|j||}t|||S)NrG)rr"rr@)r^r?rCr&r>s r'rrsP  " " $D%g64 Kr()timeout return_whencK tj|stj|r!t dt |j |s td|tttfvrtd|t|}td|Dr t dtj}t||||d{S7w)Nzexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3FK|]}tj|ywr!)rrK).0fs r' zwait..s 1b: ! !! $bs!z6Passing coroutines is forbidden, use tasks explicitly.)risfuturerrKrMtyper ValueErrorrrrsetanyrr"_wait)fsrrr&s r'rrsz55b98b9J9J8KLMM 9::?O]KK6{mDEE RB 1b 11PQQ  " " $Dr7K6 66 6sCC C CcH|js|jdyyr!)r1rw)waiterargss r'_release_waiterrs ;;=$ r(cK |T|dkrOt|}|jr|jSt|d{ |jStj|4d{|d{cdddd{S7N#tj $r }t |d}~wwxYw7C7;7-#1d{7swYyxYwwNr) r r1rv_cancel_and_waitrr TimeoutErrorrr)futrrs r'rrsDw!|C  88:::< s### (::< ((y)(( $(( (C ' ())(((sACBC BC3B74C7B==B9>B= C B;CB4(B//B44C9B=;C=CC C Cc2 K |j d ||j|t  t| fd}|D]}|j | d{  j |D]}|j | tt}}|D]5}|jr|j|%|j|7||fS7#  j |D]}|j |wxYww)Ncdzdks2tk(s)tk(rW|jsF|j5j j sj dyyyyy)Nrr)rr cancelledryrr1rw)rcounterrtimeout_handlers r'_on_completionz_wait.._on_completionst1  qL ? * ? *AKKM01 0I)%%';;=!!$'!1J5B *r() create_future call_laterrlenrrremove_done_callbackrr1add) rrrr&rrr1pendingrrrs ` @@@r'rr s     !FN/6J"gG ( N+3  %  ! ! #A " "> 2E35'D  668 HHQK KKN  =   %  ! ! #A " "> 2s1ADC($C&%C()A=D&C((,DDc4K tj}|j}tjt |}|j | |j|d{|j|y7#|j|wxYwwr!) rr"r functoolspartialrrrr)rr&rcbs r'rr6s~F  " " $D    !F   ?F 3B"%     $    $s0ABB)B*B.BBBB)rc#  K tj|stj|r!t dt |j ddlm}| tj}t|Dchc]}t||c} d  fd} fd fd} D]}|j r||j|| tt! D] }| ycc}ww)Nz#expect an iterable of futures, not r)Queuer%cxD]$}|jjd&jyr!)r put_nowaitclear)rrr1todos r' _on_timeoutz!as_completed.._on_timeoutds2A " "> 2 OOD ! r(c|syj|j|sjyyyr!)removerr)rr1rrs r'rz$as_completed.._on_completionjs;  A 2  ! ! #3tr(cKjd{}|tj|jS7&wr!)r$rrrv)rr1s r' _wait_for_onez#as_completed.._wait_for_oners7((*  9)) )xxz sA>'A)rrrrKrMrrqueuesrrget_event_looprr rrranger) rrrr&rrr_rr1rrs @@@@r'r r Hs"z55b9=d2h>O>O=PQRR 7D  "D14R 9AM!$ ' 9DN $ N+ #+> 3t9 o9 :sA;DC>A.Dc#K dywr!rr(r'__sleep0rs s c2K |dkrtd{|Stj}|j}|j |t j ||} |d{|jS7g7#|jwxYwwr)rrr"rrr_set_result_unless_cancelledr)delayrvr&rhs r'r r sC zj  " " $D    !F << (A|     s:BA>A B$B)B*B-BBBBr%c tj|r&|"|tj|ur td|Sd}t j |s.t j|rd}||}d}n td|tj} |j|S#t$r|r|jwxYw)NzRThe future belongs to a different loop than the one specified as the loop argumentTc"K|d{S7wr!r) awaitables r'_wrap_awaitablez&ensure_future.._wrap_awaitables&&s  Fz:An asyncio.Future, a coroutine or an awaitable is required)rrr0rrrKr isawaitablerMrrrr-close)coro_or_futurer& should_closers r'r r s'  G,=,=n,M MEF FL  ! !. 1   ~ . '-^._done_callbacks,Q =EJJL==?   }}//1##C(mmo?'',  G==?%33!119++-C--/C{!jjls# "&&//1##C(  ); r(rr%Fr) rrrrwr rr0rLr1r rr) r coros_or_futuresr&r arg_to_fut done_futsargrrrrrs ` @@@@r'r r s%: $$&""$  5*5*nJH EII D E j $/C|((-#~ ,1( QJE!JsOxxz  %%%n5S/C/ 2 XD 1E s Lr(c t|jrStj}|j fdfd}j j |S)Nc0jr!|js|jy|jrjy|j}|j|yj |j yr!)rryrrzrwrv)innerrrs r'_inner_done_callbackz$shield.._inner_done_callbacksj ?? ??$!  ??  LLN//#C##C(  0r(cJjsjyyr!)r1r)rrrs r'_outer_done_callbackz$shield.._outer_done_callbacks zz|  & &'; <r()r r1rr0rr)rr&rrrrs @@@r'r r asp@ # E zz|   U #D    E1"= 01 01 Lr(c tjs tdtjj fd}j |S)NzA coroutine object is requiredc tjty#ttf$rt $r'}j rj|d}~wwxYw)Nr%)r _chain_futurer rrrset_running_or_notify_cancelrz)rr^rr&s r'callbackz*run_coroutine_threadsafe..callbacks]   ! !-4"@& I-.   224$$S)  s!%A$"AA$)rrKrM concurrentrFuturecall_soon_threadsafe)r^r&r"rs`` @r'rrsR  ! !$ '899    & & (F h' Mr(c dddfd }|S)Nrc||||dS)NTrBr)r&r^r?rCcustom_task_constructors r'factoryz*create_eager_task_factory..factorys& t$TK Kr(r)r(r)s` r'rrs $%)$K Nr(c0 tj|yr!)r,rr>s r'rrsEr(c0 tj|yr!)r+rr+s r'rrs@Tr(chtj|}|td|d|d|t|<y)NzCannot enter into task z while another task z is being executed.r#r$r-r&r>rs r'rrsL!%%d+L4TH=##/"22EGH HN4r(chtj|}||urtd|d|dt|=y)Nz Leaving task z! does not match the current task .r.r/s r'rrsJ!%%d+L4]4(3//;.>aAB Btr(cXtj|}| t|=|S|t|<|Sr!)r#r$)r&r>rs r'rrs9""4(I | 4   $t r(c0 tj|yr!)r,discardr+s r'rrs1T"r(c0 tj|yr!)r+r4r+s r'rr s@r() rrrrrrrr,r+r#rr!)O__all__concurrent.futuresr#rUrrr.typesr;weakrefrr rrrrrrcount__next__rNrrr@ _PyFuturer_PyTask_asyncio_CTask ImportErrorrrrrrrrrrr coroutinerr r r$rr r rrrWeakSetr,rr+r#rrrrrrr_py_current_task_py_register_task_py_register_eager_task_py_unregister_task_py_unregister_eager_task_py_enter_task_py_leave_task_py_swap_current_task_c_current_task_c_register_task_c_register_eager_task_c_unregister_task_c_unregister_eager_task _c_enter_task _c_leave_task_c_swap_current_taskrr(r'rSsM6   %Y__Q'00$>6 z7  zz " MM!D6#D $$$44$$44""00 # 7@ 0d)X%$!%6r  "+/@w~~:16CL?D.4/t4 #7??$u    #   ".&2*.((((#O%1)5MM-i  T  s$ F4 G4F=<F=GG__pycache__/protocols.cpython-312.opt-1.pyc000064400000021120152343231170014437 0ustar00 ֦i-~dZdZGddZGddeZGddeZGdd eZGd d eZd Zy )zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc,eZdZdZdZdZdZdZdZy)ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cy)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)self transports */usr/lib64/python3.12/asyncio/protocols.pyconnection_madezBaseProtocol.connection_madecy)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrr excs r connection_lostzBaseProtocol.connection_lostrrcy)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrr s r pause_writingzBaseProtocol.pause_writing%rrcy)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrrs r resume_writingzBaseProtocol.resume_writing;rrN) __name__ __module__ __qualname____doc__ __slots__r rrrrrr rr s"I   , rrc eZdZdZdZdZdZy)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcy)zTCalled when some data is received. The argument is a bytes object. Nr)r datas r data_receivedzProtocol.data_received^rrcyzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrrs r eof_receivedzProtocol.eof_receiveddrrN)rrrrrr!r$rrr rrBs2I  rrc&eZdZdZdZdZdZdZy)ra:Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcy)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)r sizehints r get_bufferzBufferedProtocol.get_bufferrrcy)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)r nbytess r buffer_updatedzBufferedProtocol.buffer_updatedrrcyr#rrs r r$zBufferedProtocol.eof_receivedrrN)rrrrrr(r+r$rrr rrms.I    rrc eZdZdZdZdZdZy)rz Interface for datagram protocol.rcy)z&Called when some datagram is received.Nr)r r addrs r datagram_receivedz"DatagramProtocol.datagram_receivedrrcy)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrrs r error_receivedzDatagramProtocol.error_receivedrrN)rrrrrr0r2rrr rrs*I5 rrc&eZdZdZdZdZdZdZy)rz,Interface for protocol for subprocess calls.rcy)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)r fdr s r pipe_data_receivedz%SubprocessProtocol.pipe_data_receivedrrcy)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)r r5rs r pipe_connection_lostz'SubprocessProtocol.pipe_connection_lostrrcy)z"Called when subprocess has exited.Nrrs r process_exitedz!SubprocessProtocol.process_exitedrrN)rrrrrr6r8r:rrr rrs6I  1rrct|}|rr|j|}t|}|s td||k\r||d||j|y|d||d||j|||d}t|}|rqyy)Nz%get_buffer() returned an empty buffer)lenr( RuntimeErrorr+)protor data_lenbufbuf_lens r _feed_data_to_buffered_protorBs4yH x(c(FG G h !C N   *  'NCM   )>D4yH rN)r__all__rrrrrrBrrr rDsQ%  6 6 r( |( V2 |2 j  |  11.!r__pycache__/runners.cpython-312.opt-1.pyc000064400000023410152343231170014113 0ustar00 ֦i>dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z Gd d ejZ Gd d Zddd dZdZy))RunnerrunN) coroutines)events) exceptions)tasks) constantsceZdZdZdZdZy)_Statecreated initializedclosedN)__name__ __module__ __qualname__CREATED INITIALIZEDCLOSED(/usr/lib64/python3.12/asyncio/runners.pyr r sGK Frr cNeZdZdZddddZdZdZdZdZdd d Z d Z d Z y) ra5A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. Ndebug loop_factoryctj|_||_||_d|_d|_d|_d|_y)NrF) r r_state_debug _loop_factory_loop_context_interrupt_count_set_event_loop)selfrrs r__init__zRunner.__init__0s:nn  )  !$rc&|j|SN) _lazy_initr%s r __enter__zRunner.__enter__9s  rc$|jyr()close)r%exc_typeexc_valexc_tbs r__exit__zRunner.__exit__=s  rcF|jtjury |j}t ||j |j |j |jtj|jrtjd|jd|_tj|_y#|jrtjdjd|_tj|_wxYw)zShutdown and close event loop.N)rr rr!_cancel_all_tasksrun_until_completeshutdown_asyncgensshutdown_default_executorr THREAD_JOIN_TIMEOUTr$rset_event_loopr-r)r%loops rr-z Runner.close@s ;;f00 0  (::D d #  # #D$;$;$= >  # #..y/L/LM O##%%d+ JJLDJ --DK ##%%d+ JJLDJ --DKs A$CAD c:|j|jS)zReturn embedded event loop.)r)r!r*s rget_loopzRunner.get_loopQs zzrcontextctj|stdj|t j t d|j| |j}|jj||}tjtjurztjtj tj"urGt%j&|j(|} tjtj |nd}d|_ |jj-||Ytjtj |ur3tjtj tj"SSS#t$rd}YwxYw#t.j0$r4|j*dkDr#t3|dd}||dk(r t5wxYw#|Ytjtj |ur3tjtj tj"wwwxYw)z/Run a coroutine inside the embedded event loop.z"a coroutine was expected, got {!r}Nz7Runner.run() cannot be called from a running event loopr<) main_taskruncancel)r iscoroutine ValueErrorformatr_get_running_loop RuntimeErrorr)r"r! create_task threadingcurrent_thread main_threadsignal getsignalSIGINTdefault_int_handler functoolspartial _on_sigintr#r4rCancelledErrorgetattrKeyboardInterrupt)r%coror=tasksigint_handlerr@s rrz Runner.runVs%%d+AHHNO O  # # % 1IK K  ?mmGzz%%dG%<  $ $ &)*?*?*A A  /63M3MM&..t$ON & fmm^<"N ! I::006*$$V]]3~E fmmV-G-GHF+% &"&  &(( $$q("4T:'HJ!O+--   *$$V]]3~E fmmV-G-GHF+s,$F,6F=, F:9F:=AHHAI$c$|jtjur td|jtjury|j Lt j|_|jsz#Runner._on_sigint..sDr)r#donecancelr!call_soon_threadsaferS)r%signumframer?s rrPzRunner._on_sigintsT "  A %inn.>     JJ + +L 9 !!r) rrr__doc__r&r+r1r-r;rr)rPrrrrrs=6!%4%(" $(+IZ)&"rrrctj tdt||5}|j |cdddS#1swYyxYw)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)mainrrrunners rrrsK:!- FH H e, 76zz$ 8 7 7s AAcBtj|}|sy|D]}|j|jtj|ddi|D]G}|j r|j %|jd|j |dIy)Nreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)message exceptionrU)r all_tasksr`r4gather cancelledrkcall_exception_handler)r9 to_cancelrUs rr3r3s%I   ELL)LtLM >>   >>  '  ' 'N!^^-)  r)__all__rZenumrNrGrJrrrr r Enumr rrr3rrrrusW   TYY I"I"X$# Lr__pycache__/taskgroups.cpython-312.opt-2.pyc000064400000016766152343231170014642 0ustar00 ֦iW%@dZddlmZddlmZddlmZGddZy)) TaskGroup)events) exceptions)taskscVeZdZ dZdZdZdZdZddddZd e d e fd Z d Z d Z y)rcd|_d|_d|_d|_d|_d|_t |_g|_d|_ d|_ y)NF) _entered_exiting _aborting_loop _parent_task_parent_cancel_requestedset_tasks_errors _base_error_on_completed_futselfs +/usr/lib64/python3.12/asyncio/taskgroups.py__init__zTaskGroup.__init__sN    (-%e  !%cxdg}|jr'|jdt|j|jr'|jdt|j|jr|jdn|j r|jddj |}d|dS) Nztasks=zerrors= cancellingentered z )rappendlenrr r join)rinfoinfo_strs r__repr__zTaskGroup.__repr__(st ;; KK&T[[!1 23 4 << KK'#dll"3!45 6 >> KK % ]] KK "88D>H:Q''rcK|jrtd|d|jtj|_t j |j|_|jtd|dd|_|Sw)N TaskGroup z has already been enteredz! cannot determine the parent taskT)r RuntimeErrorr rget_running_loopr current_taskr rs r __aenter__zTaskGroup.__aenter__6s ==TH$=>@ @ :: 002DJ!..tzz:    $TH$EFH H  sB B cKd} |j||d{d|_d|_d|_d}S7#d|_d|_d|_d}wxYwwN)_aexitr rr)retexctbs r __aexit__zTaskGroup.__aexit__Dsc  R-- !%D DL#D C. !%D DL#D Cs%A979A9AAcKd|_|$|j|r|j||_|tjur|nd}|j r|j jdk(rd}||js|j|jrT|j|jj|_ |jd{d|_ |jrT|j |j |r|js |d}|-|tjur|jj||jr t!d|jdy7#tj$r(}|js|}|jYd}~d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYww)NTzunhandled errors in a TaskGroup)r _is_base_errorrrCancelledErrorrr uncancelr _abortrrr create_futurerrBaseExceptionGroup)rr.r/propagate_cancellation_errorexs rr-zTaskGroup._aexitRs O##C(  ("D 222C %  ( (  ))+q004, >>> kk%%-)-)A)A)C& ",,,,&*D "'kk.    ' &&&  0+DLL66,0 ( >b (A(AA LL   $ << (5LL M-,, "~~460KKM "*C+/ (sCG E2E0E2G / G < F0 F>F7=G G/G 0E22F-F(#G (F--G 0F44G 7F;;F>>GG G  G N)namecontextc |jstd|d|jr|jstd|d|jrtd|d||j j |}n|j j ||}tj|||jj||j|j |~S#~wxYw)Nr&z has not been enteredz is finishedz is shutting down)r=) r r'r rr r create_taskr_set_task_nameaddadd_done_callback _on_task_done)rcoror<r=tasks rr?zTaskGroup.create_tasks }}D83HIJ J ==D8<@A A >>D83DEF F ?::))$/D::))$)@D T4(  t112 s 'C**C-r/returnc.t|ttfSr,) isinstance SystemExitKeyboardInterrupt)rr/s rr4zTaskGroup._is_base_errors# ,=>??rcvd|_|jD]#}|jr|j%y)NT)r rdonecancel)rts rr7zTaskGroup._aborts)A668 rc|jj||jA|js5|jjs|jj d|j ry|j }|y|jj||j|r|j||_ |jjr1|jjd|d|jd||dy|js?|js2|j!d|_|jj#yyy)NTzTask z% has errored out but its parent task z is already completed)message exceptionrE)rdiscardrrL set_result cancelledrQrrr4rr r call_exception_handlerr rr7rM)rrEr/s rrCzTaskGroup._on_task_dones3 D!  ! ! -dkk))..0&&11$7 >>  nn ;  C   s #(8(8(@"D     ! ! # JJ - -"4(+##'#4#4"55JL  /  ~~d&C&C& KKM,0D )    $ $ &+'D~r)__name__ __module__ __qualname__rr$r*r1r-r? BaseExceptionboolr4r7rCrrrr sO & (  Wt)-dF@-@D@2'rrN)__all__rrrrrr[rrr]s! @'@'r__pycache__/mixins.cpython-312.opt-2.pyc000064400000001747152343231170013740 0ustar00 ֦iP ddlZddlmZejZGddZy)N)eventsceZdZdZdZy)_LoopBoundMixinNctj}|j"t5|j||_ddd||jurt |d|S#1swY'xYw)Nz# is bound to a different event loop)r_get_running_loop_loop _global_lock RuntimeError)selfloops '/usr/lib64/python3.12/asyncio/mixins.py _get_loopz_LoopBoundMixin._get_loop sa'') :: ::%!%DJ tzz !$)LMN N s A!!A*)__name__ __module__ __qualname__r rrrr s E rr) threadingrLockr rrrrrs&y~~   r__pycache__/proactor_events.cpython-312.opt-1.pyc000064400000126012152343231170015636 0ustar00 ֦i܂dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZdZGddej*ej,ZGddeej0ZGddeej4ZGddeZGddeej:ZGddeeej>Z Gddeeej>Z!Gdde jDZ#y)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggerctj||jd< |j|jd<d|jvr |j|jd<yy#tj $r5|j jrtjd|dYuwxYw#tj $rd|jd<YywxYw)Nsocketsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extra getsocknamererror_loop get_debugr warning getpeername) transportsocks 0/usr/lib64/python3.12/asyncio/proactor_events.py_set_socket_extrars!'!7!7!=IXC'+'7'7'9 $ ))) 0+/+;+;+=I  Z (* <<C ?? $ $ & NN,dT CC|| 0+/I  Z ( 0s$A/B:/AB76B7:"CCceZdZdZ dfd ZdZdZdZdZdZ dZ e jfd Z dd Zd Zd Zd ZxZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.ct||||j|||_|j |||_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ |j |j j|jj!|j"j$||,|jj!t&j(|dyy)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing_called_connection_lost _eof_written_attachr call_soon _protocolconnection_mader_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__s rr$z#_ProactorBasePipeTransport.__init__2s %   (#   ',$! << # LL " T^^;;TB   JJ !E!E!' / c|jjg}|j|jdn|jr|jd|j,|jd|jj |j |jd|j |j|jd|j|jr'|jdt|j|jr|jddjd j|S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r=__name__r&appendr.filenor*r+r)lenr0formatjoin)r7infos r__repr__z#_ProactorBasePipeTransport.__repr__Is''( ::  KK ! ]] KK " :: ! KK#djj//123 4 >> % KK%12 3 ?? & KK& 34 5 << KK.T\\):(;< =    KK &}}SXXd^,,r>c"||jd<y)Npipe)rr7rs rr%z%_ProactorBasePipeTransport._set_extra[s" Fr>c||_yNr3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s !r>c|jSrOrPr7s r get_protocolz'_ProactorBasePipeTransport.get_protocolas ~~r>c|jSrO)r.rRs r is_closingz%_ProactorBasePipeTransport.is_closingds }}r>c.|jryd|_|xjdz c_|js2|j&|jj |j d|j"|jjd|_yy)NTr) r.r-r)r+rr2_call_connection_lostr*cancelrRs rclosez _ProactorBasePipeTransport.closegsq ==   1|| 7 JJ !;!;T B >> % NN ! ! #!DN &r>cv|j-|d|t||jjyy)Nzunclosed transport )source)r&ResourceWarningrY)r7_warns r__del__z"_ProactorBasePipeTransport.__del__rs5 :: ! 'x0/$ O JJ    "r>c0 t|tr4|jjrDt j d||dn*|jj ||||jd|j|y#|j|wxYw)Nz%r: %sTr)message exceptionrr9) isinstanceOSErrorrrr debugcall_exception_handlerr3 _force_close)r7excr`s r _fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy ##w'::'')LL44H 11&!$!% $ 3   c "D  c "s A.BBcH|jS|jjs9||jjdn|jj||jr |j ryd|_|xj dz c_|jr!|jjd|_|jr!|jjd|_ d|_ d|_ |jj|j|y)NTrr) _empty_waiterdone set_result set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_closes    )$2D2D2I2I2K{""--d3""005 ==T99   1 ?? OO " " $"DO >> NN ! ! #!DN  T77=r>c|jry |jj|t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_y#t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_wxYw)NshutdownT) r/r3connection_losthasattrr&rEror SHUT_RDWRrYr(_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_losts  ' '  0 NN * *3 / tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (s CB+E?cf|j}|j|t|jz }|SrO)r,r)rF)r7sizes rget_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_sizes/"" << # C % %D r>NNN)zFatal error on pipe transport)rC __module__ __qualname____doc__r$rJr%r'rSrUrYwarningswarnr^rhrfrWrw __classcell__r=s@rr!r!.sQ448$(/.-$#" "%MM #>(0(r>r!cNeZdZdZ d fd ZdZdZdZdZdZ d dZ xZ S) _ProactorReadPipeTransportzTransport for read pipes.cd|_d|_t| ||||||t ||_|j j|jd|_y)NrpTF) _pending_data_length_pausedr#r$ bytearray_datarr2 _loop_reading) r7r8rr9r:r;r< buffer_sizer=s rr$z#_ProactorReadPipeTransport.__init__sT$&!  tXvufE{+  T//0 r>c:|j xr |j SrO)rr.rRs r is_readingz%_ProactorReadPipeTransport.is_readings<<5 $55r>c|js |jryd|_|jjrt j d|yy)NTz%r pauses reading)r.rrrr rdrRs r pause_readingz(_ProactorReadPipeTransport.pause_readings? ==DLL   ::   ! LL,d 3 "r>c|js |jsyd|_|j&|jj |j d|j }d|_|dkDr4|jj |j|jd|||jjrtjd|yy)NFrpz%r resumes reading) r.rr*rr2rr_data_receivedrrr rd)r7lengths rresume_readingz)_ProactorReadPipeTransport.resume_readings ==  >> ! JJ !3!3T :**$&! B; JJ !4!4djj&6I6 R ::   ! LL-t 4 "r>c.|jjrtjd| |jj }|s|jyy#t tf$rt$r}|j|dYd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rdr3 eof_received SystemExitKeyboardInterrupt BaseExceptionrhrY)r7 keep_openrgs r _eof_receivedz(_ProactorReadPipeTransport._eof_receiveds ::   ! LL*D 1 335I JJL-.      H J  sA B8BBc|jr||_y|dk(r|jyt|jt j r" t j|j|y|jj|y#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nrz3Fatal error: protocol.buffer_updated() call failed.) rrrrbr3r BufferedProtocol_feed_data_to_buffered_protorrrrh data_received)r7datarrgs rrz)_ProactorReadPipeTransport._data_receiveds <<)/D %  Q;     dnni&@&@ A 66t~~tL NN ( ( . 12   !!##12  s B C%B<<CcJd}d} |xd|_|jrQ|j}|dk(r |dkDr|j||yyt t |j d|}n|j|jr |dkDr|j||yy|js?|jjj|j|j |_|js&|jj|j |dkDr|j||yy#t $rZ}|js|j#|dn1|jj%rt'j(ddYd}~wd}~wt*$r}|j-|Yd}~d}~wt.$r}|j#|dYd}~d}~wt0j2$r|jsYwxYw#|dkDr|j||wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*rkresultrbytes memoryviewrrXr.rr _proactor recv_intor&add_done_callbackrConnectionAbortedErrorrhrr rdConnectionResetErrorrfrcrCancelledError)r7futrrrgs rrz(_ProactorReadPipeTransport._loop_readings. 2"&88: ZZ\F{F{##D&1A!DJJ!7!@ADJJL}}2{##D&1)<D<&A D<12H< HAFH H&F<7H< HGH#HHHHH")NNNirO) rCryrzr{r$rrrrrrr~rs@rrrs/#486;64&5$ /212r>rcReZdZdZdZfdZdZd dZdZdZ dZ d Z d Z xZ S) _ProactorBaseWritePipeTransportzTransport for write pipes.Tc2t||i|d|_yrO)r#r$rjr7argskwr=s rr$z(_ProactorBaseWritePipeTransport.__init__Ns $%"%!r>ct|tttfs!t dt |j |jr td|j td|sy|jrH|jtjk\rtjd|xjdz c_ y|j|j!t|y|j"s!t||_|j%y|j"j'||j%y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r)rbrrr TypeErrortyperCr0 RuntimeErrorrjr-r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+ _loop_writingr)_maybe_pause_protocolextend)r7rs rwritez%_ProactorBaseWritePipeTransport.writeRs$ : >?Dz**+-. .   ;< <    )IJ J  ??)"M"MM@A OOq O  ?? "   E$K  0$T?DL  & & ( LL   %  & & (r>c  ||j |jryd|_d|_|r|j||j}d|_|sx|jr&|j j |jd|jr)|jjtj|jn|j jj|j||_|jj!sFt#||_|jj%|j&|j)n%|jj%|j&|j*)|j|j*j-dyyy#t.$r}|j1|Yd}~yd}~wt2$r}|j5|dYd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,rr)rr2rWr0r&rorSHUT_WR_maybe_resume_protocolrsendrkrFrrrrjrlrrfrcrh)r7frrgs rrz-_ProactorBaseWritePipeTransport._loop_writingxs& J}!8T]]"DO"#D  |||# ==JJ(()C)CTJ$$JJ''7 ++-"&**"6"6";";DJJ"M++-*-d)D'OO55d6H6HI..0OO55d6H6HI!!-$//2I""--d33J-# #   c " " J   c#H I I Js)F<FF<< HG H'G>>HcyNTrRs r can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eofr>c$|jyrO)rYrRs r write_eofz)_ProactorBaseWritePipeTransport.write_eofs  r>c&|jdyrOrfrRs rabortz%_ProactorBaseWritePipeTransport.abort $r>c|j td|jj|_|j|jj d|jS)NzEmpty waiter is already set)rjrr create_futurer+rlrRs r_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waitersY    )<= =!ZZ557 ?? "    ) )$ /!!!r>cd|_yrO)rjrRs r_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiters !r>NN)rCryrzr{_start_tls_compatibler$rrrrrrrr~rs@rrrHs7$ "$)L'JR ""r>rc$eZdZfdZdZxZS)_ProactorWritePipeTransportct||i||jjj |j d|_|j j|jy)N) r#r$rrrecvr&r*r _pipe_closedrs rr$z$_ProactorWritePipeTransport.__init__sO $%"%--224::rB (():):;r>c|jry|jryd|_|j|j t y|j yrO) cancelledr.r*r+rfBrokenPipeErrorrY)r7rs rrz(_ProactorWritePipeTransport._pipe_closedsC ==?  ==  ?? &   o/ 0 JJLr>)rCryrzr$rr~rs@rrrs < r>rcReZdZdZ d fd ZdZdZdZd dZd dZ d dZ xZ S) _ProactorDatagramTransportic||_d|_d|_t||||||t j |_|jj|jy)Nr)r:r;) _addressrj _buffer_sizer#r$ collectionsdequer)rr2r)r7r8rr9addressr:r;r=s rr$z#_ProactorDatagramTransport.__init__s^ ! tXfEJ#((*  T//0r>ct||yrOrrMs rr%z%_ProactorDatagramTransport._set_extra $%r>c|jSrO)rrRs rrwz0_ProactorDatagramTransport.get_write_buffer_sizes   r>c&|jdyrOrrRs rrz _ProactorDatagramTransport.abortrr>crt|tttfst dt ||sy|j (|d|j fvrtd|j |jrT|j rH|jtjk\rtjd|xjdz c_y|jjt||f|xjt!|z c_|j"|j%|j'y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbrrrrrr ValueErrorr-rrr rr)rDrrFr+rr)r7raddrs rsendtoz!_ProactorDatagramTransport.sendtos$ : >?J J( (  == $dDMM5J)J3DMM?CE E ??t}})"M"MMBC OOq O  U4[$/0 SY& ?? "     ""$r>cz |jryd|_|r|j|jr|jr?|jr3|j r&|j j|jdy|jj\}}|xjt|zc_ |j6|j jj|j||_n7|j jj|j|||_|jj!|j"|j%y#t&$r%}|j(j+|Yd}~yd}~wt,$r}|j/|dYd}~yd}~wwxYw)N)rz'Fatal write error on datagram transport)r-r+rr)rr.rr2rWpopleftrrFrrr&rrrrrcr3error_received Exceptionrh)r7rrrrgs rrz(_ProactorDatagramTransport._loop_writingsT *#DO <!>tzz?C}}"N~~)001C1CD00t< / NN ) )# . .(( ==! 00t<sM F#'F#9,F#B F#2G5# G2,G G5 #G2/G51G22G55!HrxrO) rCryrzrr$r%rwrrrrr~rs@rrrs2H59$( 1&! %: *D)=r>rceZdZdZdZdZy)_ProactorDuplexPipeTransportzTransport for duplex pipes.cy)NFrrRs rrz*_ProactorDuplexPipeTransport.can_write_eofUsr>ctrO)NotImplementedErrorrRs rrz&_ProactorDuplexPipeTransport.write_eofXs!!r>N)rCryrzr{rrrr>rrrPs&"r>rcfeZdZdZej j Z dfd ZdZ dZ dZ xZ S)_ProactorSocketTransportz Transport for connected sockets.cXt|||||||tj|yrO)r#r$r _set_nodelayr6s rr$z!_ProactorSocketTransport.__init__cs( tXvufE  &r>ct||yrOrrMs rr%z#_ProactorSocketTransport._set_extrahrr>cyrrrRs rrz&_ProactorSocketTransport.can_write_eofkrr>c|js |jryd|_|j*|jj t j yyr)r.r0r+r&rorrrRs rrz"_ProactorSocketTransport.write_eofnsA ==D--   ?? " JJ   / #r>rx) rCryrzr{r _SendfileMode TRY_NATIVE_sendfile_compatibler$r%rrr~rs@rrr\s4+$22==48$(' &0r>rceZdZfdZ ddZ dddddddddZ ddZ d dZ d d Z d d Z fd Z d Z d Z dZ d!dZdZdZdZdZdZdZdZdZddZdZ d"dZdZdZdZxZS)#rct|tjd|jj ||_||_d|_i|_ |j||jtjtjur.tj |j"j%yy)NzUsing proactor: %s)r#r$r rdr=rCr _selector_self_reading_future_accept_futuresset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockrE)r7proactorr=s rr$zBaseProactorEventLoop.__init__xs  )8+=+=+F+FG!!$(!!$   # # %)>)>)@ @  !3!3!5 6 Ar>Nc"t||||||SrO)r)r7rr9r:r;r<s r_make_socket_transportz,BaseProactorEventLoop._make_socket_transports'dHf(-v7 7r>F) server_sideserver_hostnamer;r<ssl_handshake_timeoutssl_shutdown_timeoutc ttj||||||| | } t||| ||| jS)N)rrr;r<)r SSLProtocolr_app_transport) r7rawsockr9 sslcontextr:rrr;r<rr ssl_protocols r_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transportsI  ++h F_&;%9 ; !w ',V =***r>c"t||||||SrO)r)r7rr9rr:r;s r_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transports)$h*0%9 9r>c t|||||SrO)rr7rr9r:r;s r_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transports+D,0(FEK Kr>c t|||||SrO)rrs r_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transports)$hNNr>c t|||||SrO)rrs r_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transports+4+/65J Jr>c|jr td|jrytjtj urt jd|j|j|jjd|_ d|_ t|-y)Nz!Cannot close a running event looprp) is_runningr is_closedrrr r r _stop_accept_futures_close_self_piperrYrr#)r7r=s rrYzBaseProactorEventLoop.closes ?? BC C >>    # # %)>)>)@ @   $ !!#    r>cVK|jj||d{S7wrO)rr)r7rns r sock_recvzBaseProactorEventLoop.sock_recvs#^^((q1111 )')cVK|jj||d{S7wrO)rr)r7rbufs rsock_recv_intoz$BaseProactorEventLoop.sock_recv_intos#^^--dC8888r-cVK|jj||d{S7wrO)rr)r7rbufsizes r sock_recvfromz#BaseProactorEventLoop.sock_recvfroms#^^,,T7;;;;r-crK|s t|}|jj|||d{S7wrO)rFr recvfrom_into)r7rr/nbytess rsock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_intos1XF^^11$VDDDDs .757cVK|jj||d{S7wrO)rr)r7rrs r sock_sendallz"BaseProactorEventLoop.sock_sendalls#^^((t4444r-cZK|jj||d|d{S7w)Nr)rr)r7rrrs r sock_sendtoz!BaseProactorEventLoop.sock_sendtos'^^**4q'BBBBs "+)+cK|jr|jdk7r td|jj ||d{S7w)Nrzthe socket must be non-blocking)_debug gettimeoutrrconnect)r7rrs r sock_connectz"BaseProactorEventLoop.sock_connectsD ;;4??,1>? ?^^++D'::::sA A A AcTK|jj|d{S7wrO)racceptrMs r sock_acceptz!BaseProactorEventLoop.sock_accepts!^^**40000s (&(cK |j} t j|j}|r|n|}|syt|d}|rt||z|n|} t||}d} t| |z |}|dkr| | dkDr|j|SS|jj||||d{||z }| |z } ^#ttjf$r}t j dd}~wwxYw#t$rt j dwxYw7g#| dkDr|j|wwxYww)Nznot a regular filerl)rEAttributeErrorioUnsupportedOperationrSendfileNotAvailableErrorosfstatst_sizercminseekrsendfile) r7rfileoffsetcountrEerrfsize blocksizeend_pos total_sents r_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_natives_ M[[]F MHHV$,,E#E  ;/ 05#fune,5VU#  "& 0)< >% A~ &! nn--dD&)LLL)#i'  7 78 M667KL L M M667KL L MMA~ &!shEC D6E+D$E!D$:D";D$ C=#C88C==EDE"D$$D==EcjK|j}|j|jd{ |j|j|||dd{|j |r|j SS7P7)#|j |r|j wwxYww)NF)fallback)rrr sock_sendfiler&rr)r7transprOrPrQrs r_sendfile_nativez&BaseProactorEventLoop._sendfile_natives**,''))) (++FLL$5:,<<  & & (%%' *<  & & (%%'s84B3BB3#B B  B #%B3 B %B00B3c |j!|jjd|_|jjd|_|jjd|_|xj dzc_y)Nr)rrX_ssockrYr  _internal_fdsrRs rr)z&BaseProactorEventLoop._close_self_pipesg  $ $ 0  % % , , .(,D %     ar>ctj\|_|_|jj d|jj d|xj dz c_y)NFr)r socketpairr^r  setblockingr_rRs rrz%BaseProactorEventLoop._make_self_pipesN#)#4#4#6  T[ & & ar>ct ||j|j|ury|jj|jd}||_|j |j y#tj$rYyttf$rt$r}|jd||dYd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) rrrrr^r_loop_self_readingrrrrrre)r7rrgs rrdz(BaseProactorEventLoop._loop_self_readings 9} ((1##DKK6A)*D %   7 7 8((  -.     ' 'K )   s" A,&A,,B7B7B22B7c|j}|y |jdy#t$r(|jrt j ddYyYywxYw)Nz3Fail to write a null byte into the self-pipe socketTr)r rrcr=r rd)r7csocks r_write_to_selfz$BaseProactorEventLoop._write_to_self4sU   =  , JJu  ,{{ 0&*, ,s#,AAc Pdfd jy)Nc  |s|j\}}jrtjd||} j || dd|i nj ||d|ij ryjj }|j j<|jy#t$r} jdk7r9jd|tj d j!n.jrtjd d Yd}~yYd}~yYd}~yd}~wt"j$$r j!YywxYw) Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)rr=r rdrrr'rrBrrErrcrer rrYrr) rconnrr9rgr8protocol_factoryr7r<rrrrs rr8z2BaseProactorEventLoop._start_serving..loopKsw# *=!"JD${{ %J%+T49/1H!-00 (JD#-t"4V2G1E 1G 33 (#-t"4V4E>>#NN))$/78$$T[[]3##D) 6;;=B&//#>%("("8"8">1 JJL[[LL!=!%66!!,,   s%BC C FA0E&FFrO)r2) r7rlrrr<backlogrrr8s ````` ``@r_start_servingz$BaseProactorEventLoop._start_servingFs $ *$ *L tr>cyrOr)r7 event_lists r_process_eventsz%BaseProactorEventLoop._process_eventsss r>c|jjD]}|j|jjyrO)rvaluesrXclear)r7futures rr(z*BaseProactorEventLoop._stop_accept_futuresws6**113F MMO4 ""$r>c|jj|jd}|r|j|jj ||j yrO)rpoprErXr _stop_servingrY)r7rrus rrxz#BaseProactorEventLoop._stop_serving|sG%%))$++->  MMO $$T* r>rxrOr)r)NNdNN)rCryrzr$rrrr r"r$rYr,r0r3r7r9r;r@rCrWr\r)rrdrhrnrqr(rxr~rs@rrrvs 7=A267 9= + $t"&!% + CG9 BF*.K @D(,OAE)-J (29<E 5C; 1": (  98,&>A-1,0+Z % r>r)$r{__all__rFrIrr|r rrrrrrr r r r logr r_FlowControlMixin BaseTransportr! ReadTransportrWriteTransportrrDatagramTransportr Transportrr BaseEventLooprrr>rrs #  0$D!=!=!+!9!9DNP2!;!+!9!9P2fk"&@&0&?&?k"\"A,A=!;!+!=!=A=H "#=#B#-#7#7 "09>)3304KK55Kr>__pycache__/locks.cpython-312.opt-2.pyc000064400000047435152343231170013550 0ustar00 ֦i3J^ dZddlZddlZddlmZddlmZGddZGdd eejZGd d ejZ Gd d eejZ GddeejZ Gdde Z GddejZGddejZy))LockEvent Condition SemaphoreBoundedSemaphoreBarrierN) exceptions)mixinsceZdZdZdZy)_ContextManagerMixinc@K|jd{y7wN)acquireselfs &/usr/lib64/python3.12/asyncio/locks.py __aenter__z_ContextManagerMixin.__aenter__ slln s c,K|jywr)release)rexc_typeexctbs r __aexit__z_ContextManagerMixin.__aexit__s sN)__name__ __module__ __qualname__rrrr r s  rr c>eZdZ dZfdZdZdZdZdZxZ S)rc d|_d|_yNF)_waiters_lockedrs r__init__z Lock.__init__Ms  rct|}|jrdnd}|jr|dt |j}d|ddd|dS Nlockedunlocked , waiters:)super__repr__r$r#lenrresextra __class__s rr0z Lock.__repr__QsYg  LLj ==gZDMM(:';zLock.acquire..cs9=aAKKM=sT) r$r#all collectionsdeque _get_loop create_futureappendremover CancelledError_wake_up_firstrfuts rrz Lock.acquire\s  $--"794==99DL == '--/DMnn,,. S!   *  $$S)   $$S)(( <<##%  sBBD$ C%C&C*C0D$CC--C001D!!D$cb |jrd|_|jytd)NFzLock is not acquired.)r$rG RuntimeErrorrs rrz Lock.release|s/  << DL    !67 7rc |jsy tt|j}|j s|j dyy#t$rYywxYwNT)r#nextiter StopIterationdone set_resultrHs rrGzLock._wake_up_firstsW8}}  tDMM*+Cxxz NN4     sA AA) rrrr%r0r(rrrG __classcell__r5s@rrrs(3j*@8" !rrc>eZdZ dZfdZdZdZdZdZxZ S)rcDtj|_d|_yr")r@rAr#_valuers rr%zEvent.__init__s#))+  rct|}|jrdnd}|jr|dt |j}d|ddd|dS) Nsetunsetr*r+r r,r-r.)r/r0rWr#r1r2s rr0zEvent.__repr__sYg ' ==gZDMM(:'; ))+  [F  s31 33c |js tdd}|jD]0}||k\ry|jr|dz }|j d2y)Nz!cannot notify on un-acquired lockrr F)r(rKr#rQrR)rnidxrIs rnotifyzCondition.notify)sY {{}BC C==Cax88:qu% !rcN |jt|jyr)rqr1r#rs r notify_allzCondition.notify_allAs C &'rrr ) rrrr%r0rbrmrqrsrSrTs@rrrs' ,*#0J &0(rrc@eZdZ ddZfdZdZdZdZdZxZ S)rc@|dkr tdd|_||_y)Nrz$Semaphore initial value must be >= 0) ValueErrorr#rW)rvalues rr%zSemaphore.__init__Ys# 19CD D  rct|}|jrdnd|j}|jr|dt |j}d|ddd|dS) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s rr0zSemaphore.__repr___sgg  KKM1A$++/O ==gZDMM(:';K|]}|j ywrr9r;s rr>z#Semaphore.locked..isA,?aAKKM!,?sr)rWanyr#rs rr(zSemaphore.lockedfs7G{{aC ADMM,?R,?A A CrcK |js|xjdzc_y|jtj|_|j j }|jj| |d{|jj| |jdkDr|jy7@#|jj|wxYw#tj$r7|js%|xjdz c_|jwxYww)Nr Tr) r(rWr#r@rArBrCrDrEr rFr: _wake_up_nextrHs rrzSemaphore.acquireks {{} KK1 K == '--/DMnn,,. S!  *  $$S) ;;?     $$S)(( ==? q ""$   sCBD? CCCC2/!D?CC//C22A D<<D?cP |xjdz c_|jyNr )rWr~rs rrzSemaphore.releases# q  rc |jsy|jD]:}|jr|xjdzc_|jdyy)Nr T)r#rQrWrRrHs rr~zSemaphore._wake_up_nextsC7}} ==C88: q t$ !rrt) rrrr%r0r(rrr~rSrTs@rrrJs(  *C "H rrc,eZdZ dfd ZfdZxZS)rc2||_t| |yr) _bound_valuer/r%)rrxr5s rr%zBoundedSemaphore.__init__s! rcj|j|jk\r tdt|y)Nz(BoundedSemaphore released too many times)rWrrwr/r)rr5s rrzBoundedSemaphore.releases+ ;;$++ +GH H rrt)rrrr%rrSrTs@rrrs  rrceZdZdZdZdZdZy) _BarrierStatefillingdraining resettingbrokenN)rrrFILLINGDRAINING RESETTINGBROKENrrrrrsGHI FrrceZdZ dZfdZdZdZdZdZdZ dZ d Z d Z d Z ed Zed ZedZxZS)rc |dkr tdt|_||_tj |_d|_y)Nr zparties must be >= 1r)rwr_cond_partiesrr_state_count)rpartiess rr%zBarrier.__init__s<? Q;34 4[  #++  rct|}|jj}|js|d|j d|j z }d|ddd|dS)Nr*/r+r r,r-r.)r/r0rrxr n_waitingrr2s rr0zBarrier.__repr__sdg ;;$$%{{ z$..!14<<.A AE3q9+Rwb))rc>K|jd{S7wrrjrs rrzBarrier.__aenter__sYY[   s c Kywrr)rargss rrzBarrier.__aexit__s  sc2K |j4d{|jd{ |j}|xjdz c_|dz|jk(r|j d{n|j d{||xjdzc_|j cdddd{S777Y7B7 #|xjdzc_|j wxYw#1d{7swYyxYwwr)r_blockrr_release_wait_exit)rindexs rrbz Barrier.waits :::++-     q 19 ---/))**,&& q  ::  *& q  ::sDCDDCDAC8C9CCC%D< DC DDCCD'C??DDD DDcKjjfdd{jtjurt j dy76w)Nc\jtjtjfvSr)rrrrrsrz Barrier._block..s$DKK&& (?(?(rzBarrier aborted)rrmrrrr BrokenBarrierErrorrs`rrzBarrier._blocksZ jj!!     ;;-.. .//0AB B / s"AA7AcjKtj|_|jj ywr)rrrrrsrs rrzBarrier._releases% $,,  s13cKjjfdd{jtjtj fvrt jdy7Fw)Nc<jtjuSr)rrrrsrrzBarrier._wait..s$++]=R=R*RrzAbort or reset of barrier)rrmrrrrr rrs`rrz Barrier._waits] jj!!"RSSS ;;=//1H1HI I//0KL L J Ts"A.A,AA.c|jdk(r\|jtjtjfvrtj |_|j jyyNr)rrrrrrrrsrs rrz Barrier._exitsO ;;! {{}66 8N8NOO+33 JJ ! ! # rcjK |j4d{|jdkDr2|jtjur+tj|_ntj |_|jj dddd{y77#1d{7swYyxYwwr)rrrrrrrsrs rresetz Barrier.reset"sp :::{{Q;;m&=&=="/"9"9DK+33 JJ ! ! #::::::sEB3BB3A1B B3BB3B3B0$B' %B0,B3cK |j4d{tj|_|jj dddd{y7D7#1d{7swYyxYwwr)rrrrrsrs rabortz Barrier.abort1sF :::'..DK JJ ! ! #::::::sDA2AA20A A2AA2A2A/#A& $A/+A2c |jSr)rrs rrzBarrier.parties;sF}}rcV |jtjur |jSyr)rrrrrs rrzBarrier.n_waiting@s$J ;;-// /;; rc< |jtjuSr)rrrrs rrzBarrier.brokenGs>{{m2222r)rrrr%r0rrrbrrrrrrpropertyrrrrSrTs@rrrs} *!  .C   M$ $$ 33rr)__all__r@enumr r r _LoopBoundMixinrrrrrEnumrrrrrrs! * C! !7!7C!L:&F " ":&zm($f&<&<m(`W$f&<&<Wty$DIIM3f$$M3r__pycache__/events.cpython-312.pyc000064400000107610152343231170012771 0ustar00 ֦irdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z GddZ Gdd e Z Gd d Z Gd d ZGddZGddeZdaej$ZGddej(ZeZdZdZdZdZdZdZdZdZdZdZ dZ!eZ"eZ#eZ$eZ% ddl&mZmZmZmZeZ'eZ(eZ)eZ*e,ed rd!Z-ej\e-"yy#e+$rY(wxYw)#z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpersc@eZdZdZdZd dZdZdZdZdZ d Z d Z y) rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNc"|tj}||_||_||_||_d|_d|_|jjr.tjtjd|_ yd|_ y)NFr) contextvars copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontexts '/usr/lib64/python3.12/asyncio/events.py__init__zHandle.__init__$sx ?!..0G  !  ::   !%3%A%A a &"D "&*D "ch|jjg}|jr|jd|j9|jt j |j|j|jr,|jd}|jd|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r$infoframes r) _repr_infozHandle._repr_info3s''( ?? KK $ >> % KK>> , -  ! !**2.E KK+eAhZqq ; < r+c|j |jS|j}djdj|S)Nz<{}> )rr6formatjoin)r$r4s r)__repr__zHandle.__repr__?s9 :: !::  }}SXXd^,,r+c|jSN)rr$s r) get_contextzHandle.get_contextEs }}r+c|js@d|_|jjrt||_d|_d|_yy)NT)rrr reprrrrr>s r)cancelz Handle.cancelHs@"DOzz##%"$Z !DNDJr+c|jSr=)rr>s r)r-zHandle.cancelledSs r+c |jj|jg|jd}y#tt f$rt $rw}tj|j|j}d|}|||d}|jr|j|d<|jj|Yd}~d}yd}~wwxYw)NzException in callback )message exceptionhandlesource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr3rrcall_exception_handler)r$exccbmsgr(s r)_runz Handle._runVs 7 DMM  dnn :tzz :-.   777 ,B*2$/C G %%.2.D.D*+ JJ - -g 6 6 7s16CA+CCr=) r1 __module__ __qualname____doc__ __slots__r*r6r;r?rBr-rQr+r)rrs/;I * -  r+rcjeZdZdZddgZdfd ZfdZdZdZdZ d Z d Z d Z fd Z d ZxZS)rz7Object returned by timed callback registration methods. _scheduled_whencxt||||||jr |jd=||_d|_y)Nr.F)superr*rrYrX)r$whenr%r&r'r(r0s r)r*zTimerHandle.__init__os; 4w7  ! !&&r* r+ct|}|jrdnd}|j|d|j|S)Nrzwhen=)r[r6rinsertrY)r$r4posr0s r)r6zTimerHandle._repr_infovs;w!#??a C5 -. r+c,t|jSr=)hashrYr>s r)__hash__zTimerHandle.__hash__|sDJJr+c`t|tr|j|jkStSr= isinstancerrYNotImplementedr$others r)__lt__zTimerHandle.__lt__% e[ ):: + +r+ct|tr,|j|jkxs|j|StSr=rfrrY__eq__rgrhs r)__le__zTimerHandle.__le__3 e[ ):: +At{{5/A Ar+c`t|tr|j|jkDStSr=rerhs r)__gt__zTimerHandle.__gt__rkr+ct|tr,|j|jkDxs|j|StSr=rmrhs r)__ge__zTimerHandle.__ge__rpr+ct|trj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(St Sr=)rfrrYrrrrgrhs r)rnzTimerHandle.__eq__sl e[ )JJ%++-8NNeoo58JJ%++-8OOu'7'77 9r+cp|js|jj|t|yr=)rr_timer_handle_cancelledr[rB)r$r0s r)rBzTimerHandle.cancels& JJ . .t 4 r+c|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). )rYr>s r)r\zTimerHandle.whens zzr+r=)r1rRrSrTrUr*r6rcrjrorrrtrnrBr\ __classcell__)r0s@r)rrjsBAw'I        r+rc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) rz,Abstract server returned by create_server().ct)z5Stop serving. This leaves existing connections open.NotImplementedErrorr>s r)closezAbstractServer.close!!r+ct)z4Get the event loop the Server object is attached to.r|r>s r)get_loopzAbstractServer.get_looprr+ct)z3Return True if the server is accepting connections.r|r>s r) is_servingzAbstractServer.is_servingrr+cKtw)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. r|r>s r) start_servingzAbstractServer.start_serving "! cKtw)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. r|r>s r) serve_foreverzAbstractServer.serve_forever "!rcKtw)z*Coroutine to wait until service is closed.r|r>s r) wait_closedzAbstractServer.wait_closed !!rcK|Swr=rVr>s r) __aenter__zAbstractServer.__aenter__s  sc`K|j|jd{y7wr=)r~r)r$rNs r) __aexit__zAbstractServer.__aexit__s!    s $.,.N) r1rRrSrTr~rrrrrrrrVr+r)rrs-6""""""!r+rc eZdZdZdZdZdZdZdZdZ dZ d Z d Z d d d Z d d dZd d dZdZdZd d ddZd d dZdZdZddddddZdJdZ dKd dddd d d d d d d d dZ dKej4ej6d dd d d d d dd d ZdLdd!d"Zd#d d d d$d%Z dMd d d d d d&d'Z dMd dd d d dd(d)Z d d d d*d+Z! dKdddd d d d d,d-Z"d.Z#d/Z$e%jLe%jLe%jLd0d1Z'e%jLe%jLe%jLd0d2Z(d3Z)d4Z*d5Z+d6Z,d7Z-d8Z.d9Z/dJd:Z0d;Z1d<Z2d=Z3d>Z4dLd d!d?Z5d@Z6dAZ7dBZ8dCZ9dDZ:dEZ;dFZdIZ?y )NrzAbstract event loop.ct)z*Run the event loop until stop() is called.r|r>s r) run_foreverzAbstractEventLoop.run_foreverrr+ct)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. r|)r$futures r)run_until_completez$AbstractEventLoop.run_until_completes "!r+ct)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. r|r>s r)stopzAbstractEventLoop.stops "!r+ct)z3Return whether the event loop is currently running.r|r>s r) is_runningzAbstractEventLoop.is_runningrr+ct)z*Returns True if the event loop was closed.r|r>s r) is_closedzAbstractEventLoop.is_closedrr+ct)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. r|r>s r)r~zAbstractEventLoop.closes "!r+cKtw)z,Shutdown all active asynchronous generators.r|r>s r)shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgensrrcKtw)z.Schedule the shutdown of the default executor.r|r>s r)shutdown_default_executorz+AbstractEventLoop.shutdown_default_executorrrct)z3Notification that a TimerHandle has been cancelled.r|)r$rGs r)rwz)AbstractEventLoop._timer_handle_cancelledrr+N)r(c0|jd|g|d|iS)Nrr() call_laterr$r%r(r&s r) call_soonzAbstractEventLoop.call_soon stq(CTC7CCr+ctr=r|)r$delayr%r(r&s r)rzAbstractEventLoop.call_later!!r+ctr=r|)r$r\r%r(r&s r)call_atzAbstractEventLoop.call_atrr+ctr=r|r>s r)timezAbstractEventLoop.timerr+ctr=r|r>s r) create_futurezAbstractEventLoop.create_futurerr+)namer(ctr=r|)r$cororr(s r) create_taskzAbstractEventLoop.create_taskrr+ctr=r|rs r)call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"rr+ctr=r|)r$executorfuncr&s r)run_in_executorz!AbstractEventLoop.run_in_executor%rr+ctr=r|)r$rs r)set_default_executorz&AbstractEventLoop.set_default_executor(rr+r)familytypeprotoflagscKtwr=r|)r$hostportrrrrs r) getaddrinfozAbstractEventLoop.getaddrinfo-rrcKtwr=r|)r$sockaddrrs r) getnameinfozAbstractEventLoop.getnameinfo1 !!r) sslrrrsock local_addrserver_hostnamessl_handshake_timeoutssl_shutdown_timeouthappy_eyeballs_delay interleavec Ktwr=r|)r$protocol_factoryrrrrrrrrrrrrrs r)create_connectionz#AbstractEventLoop.create_connection4s"!rdT) rrrbacklogr reuse_address reuse_portrrrc Ktw)a#A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|)r$rrrrrrrrrrrrrs r) create_serverzAbstractEventLoop.create_server>sp"!r)fallbackcKtw)zRSend a file through a transport. Return an amount of sent bytes. r|)r$ transportfileoffsetcountrs r)sendfilezAbstractEventLoop.sendfilexrrF) server_siderrrcKtw)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. r|)r$rprotocol sslcontextrrrrs r) start_tlszAbstractEventLoop.start_tlss"!r)rrrrrcKtwr=r|)r$rpathrrrrrs r)create_unix_connectionz(AbstractEventLoop.create_unix_connectionrr)rrrrrrcKtw)aWA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|) r$rrrrrrrrs r)create_unix_serverz$AbstractEventLoop.create_unix_serversD"!r)rrrcKtw)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r|)r$rrrrrs r)connect_accepted_socketz)AbstractEventLoop.connect_accepted_sockets"!r)rrrrrallow_broadcastrcKtw)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. r|) r$rr remote_addrrrrrrrrs r)create_datagram_endpointz*AbstractEventLoop.create_datagram_endpointsB"!rcKtw)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.r|r$rpipes r)connect_read_pipez#AbstractEventLoop.connect_read_pipe"!rcKtw)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.r|rs r)connect_write_pipez$AbstractEventLoop.connect_write_piperr)stdinstdoutstderrcKtwr=r|)r$rcmdrrrkwargss r)subprocess_shellz"AbstractEventLoop.subprocess_shellrrcKtwr=r|)r$rrrrr&rs r)subprocess_execz!AbstractEventLoop.subprocess_exec rrctr=r|r$fdr%r&s r) add_readerzAbstractEventLoop.add_readerrr+ctr=r|r$rs r) remove_readerzAbstractEventLoop.remove_readerrr+ctr=r|rs r) add_writerzAbstractEventLoop.add_writerrr+ctr=r|rs r) remove_writerzAbstractEventLoop.remove_writer"rr+cKtwr=r|)r$rnbytess r) sock_recvzAbstractEventLoop.sock_recv'rrcKtwr=r|)r$rbufs r)sock_recv_intoz AbstractEventLoop.sock_recv_into*rrcKtwr=r|)r$rbufsizes r) sock_recvfromzAbstractEventLoop.sock_recvfrom-rrcKtwr=r|)r$rrr s r)sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0rrcKtwr=r|)r$rdatas r) sock_sendallzAbstractEventLoop.sock_sendall3rrcKtwr=r|)r$rraddresss r) sock_sendtozAbstractEventLoop.sock_sendto6rrcKtwr=r|)r$rrs r) sock_connectzAbstractEventLoop.sock_connect9rrcKtwr=r|)r$rs r) sock_acceptzAbstractEventLoop.sock_accept<rrcKtwr=r|)r$rrrrrs r) sock_sendfilezAbstractEventLoop.sock_sendfile?rrctr=r|)r$sigr%r&s r)add_signal_handlerz$AbstractEventLoop.add_signal_handlerErr+ctr=r|)r$r$s r)remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHrr+ctr=r|)r$factorys r)set_task_factoryz"AbstractEventLoop.set_task_factoryMrr+ctr=r|r>s r)get_task_factoryz"AbstractEventLoop.get_task_factoryPrr+ctr=r|r>s r)get_exception_handlerz'AbstractEventLoop.get_exception_handlerUrr+ctr=r|)r$handlers r)set_exception_handlerz'AbstractEventLoop.set_exception_handlerXrr+ctr=r|r$r(s r)default_exception_handlerz+AbstractEventLoop.default_exception_handler[rr+ctr=r|r3s r)rMz(AbstractEventLoop.call_exception_handler^rr+ctr=r|r>s r)r zAbstractEventLoop.get_debugcrr+ctr=r|)r$enableds r) set_debugzAbstractEventLoop.set_debugfrr+)rNN)rNr=)@r1rRrSrTrrrrrr~rrrwrrrrrrrrrrrrsocket AF_UNSPEC AI_PASSIVErrrrrrrrr subprocessPIPErrrrr r rrrrrrrr r"r%r'r*r,r.r1r4rMr r9rVr+r)rrs?""""" """ "26D:>"6:""" )-d" =A""" "#!1""59"$4 "&!%!%$"598"&&##$DT"&!%8"t"#'"%*(,.2-1 "*."4 "&!% "*.""s"&!% ""L"&!% " EI!"./q59d7;$ !"J " "&0__&0oo&0oo"%/OO%/__%/__""""" """""""""(," "" "" """" ""r+rc.eZdZdZdZdZdZdZdZy)rz-Abstract policy for accessing the event loop.ct)a>Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.r|r>s r)r z&AbstractEventLoopPolicy.get_event_loopms "!r+ct)z3Set the event loop for the current context to loop.r|r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwrr+ct)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.r|r>s r)r z&AbstractEventLoopPolicy.new_event_loop{s "!r+ct)z$Get the watcher for child processes.r|r>s r)r z)AbstractEventLoopPolicy.get_child_watcherrr+ct)z$Set the watcher for child processes.r|)r$watchers r)r z)AbstractEventLoopPolicy.set_child_watcherrr+N) r1rRrSrTr r r r r rVr+r)rrjs7"""""r+rcVeZdZdZdZGddej ZdZdZ dZ dZ y) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). NceZdZdZdZy)!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr _set_calledrVr+r)_LocalrKs  r+rMc.|j|_yr=)rM_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__skkm r+c|jj|jjstjtj urd} t jd}|rG|jjd}|dk(s|jdsn|j}|dz }|rF ddl }|jdt| |j!|j#|jj*t%d tjj&z|jjS#t$rYwxYw) zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nr^rr1asynciozasyncio.rzThere is no current event loop) stacklevelz,There is no current event loop in thread %r.)rOrrL threadingcurrent_thread main_threadr"r# f_globalsget startswithf_backAttributeErrorwarningswarnDeprecationWarningr r RuntimeErrorr)r$rRfmoduler[s r)r z)BaseDefaultEventLoopPolicy.get_event_loops/ KK   %KK++((*i.C.C.EEJ $MM!$ [[__Z8F"i/63D3DZ3PA!OJ   MM:,  E    3 3 5 6 ;;   $M!*!9!9!;!@!@ AB B{{   )"  sE EEcd|j_|2t|ts"t dt |j d||j_y)zSet the event loop.TNzs r)r z)BaseDefaultEventLoopPolicy.new_event_loops !!##r+) r1rRrSrTrerSlocalrMr*r r r rVr+r)rIrIs3 M$!B!$r+rIceZdZdZy) _RunningLoopr:N)r1rRrSloop_pidrVr+r)rhrhsHr+rhc4t}| td|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. zno running event loop)rr^r's r)rrs"  D |233 Kr+cbtj\}}||tjk(r|Syy)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_loopriosgetpid) running_looppids r)rrs5&..L#C299;$6%7r+cB|tjft_y)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rnrormrirks r)rrs#BIIK0Mr+c`t5t ddlm}|adddy#1swYyxYw)NrDefaultEventLoopPolicy)_lock_event_loop_policyrurts r)_init_event_loop_policyrys!   % 0!7!9  s$-c.t ttS)z"Get the current event loop policy.)rwryrVr+r)rrs!! r+cp|2t|ts"tdt|jd|ay)zZSet the current event loop policy. If policy is None, the default policy is restored.NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'rb)rfrrcrr1rw)policys r)rrs> *V5L"M^_cdj_k_t_t^uuvwxxr+cNt}||StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. )rrr ) current_loops r)r r s*%&L " 1 1 33r+c6tj|y)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rks r)r r 0s**40r+c2tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr rVr+r)r r 5s " 1 1 33r+c2tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr rVr+r)r r :s " 4 4 66r+c4tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rGs r)r r ?s ! " 4 4W ==r+)rrrr forkcttjt_t dt j dy)Nr.)rwrIrMrOrsignal set_wakeup_fdrVr+r)on_forkr]s0  )(B(I(I(K  %$R r+)after_in_child)/rT__all__rrnrr;r>r"rSrxrrrrrrrIrwLockrvrfrhrmrrrryrrr r r r r _py__get_running_loop_py__set_running_loop_py_get_running_loop_py_get_event_loop_asyncio_c__get_running_loop_c__set_running_loop_c_get_running_loop_c_get_event_loop ImportErrorhasattrrregister_at_forkrVr+r)rs]'   JJZ<&<~'!'!TT"T"n ""DD$!8D$V  9??   1:  4 1 4 7 >*)'# '<< -,*& 2v!Bw/  s> C33C;:C;__pycache__/queues.cpython-312.opt-1.pyc000064400000027247152343231170013742 0ustar00 ֦i&dZddlZddlZddlmZddlmZddlmZGddeZ Gd d eZ Gd d ejZ Gd de Z Gdde Zy))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN) GenericAlias)locks)mixinsceZdZdZy)rz;Raised when Queue.get_nowait() is called on an empty Queue.N__name__ __module__ __qualname____doc__'/usr/lib64/python3.12/asyncio/queues.pyrr sErrceZdZdZy)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrsNrrceZdZdZddZdZdZdZdZdZ dZ e e Z d Zd Zed Zd Zd ZdZdZdZdZdZdZy)raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. c ||_tj|_tj|_d|_t j|_|jj|j|y)Nr) _maxsize collectionsdeque_getters_putters_unfinished_tasksr Event _finishedset_initselfmaxsizes r__init__zQueue.__init__!s\ $))+ #))+ !"  7rc6tj|_yN)rr_queuer"s rr!z Queue._init/s!'') rc6|jjSr')r(popleftr#s r_getz Queue._get2s{{""$$rc:|jj|yr'r(appendr#items r_putz Queue._put5 4 rct|r6|j}|js|jdy|r5yyr')r*done set_result)r#waiterswaiters r _wakeup_nextzQueue._wakeup_next:s0__&F;;=!!$' rcpdt|jdt|dd|jdS)N)typerid_formatr+s r__repr__zQueue.__repr__Bs54:&&'tBtHR=$,,.9IKKrcVdt|jd|jdS)Nr;r<r=)r>rr@r+s r__str__z Queue.__str__Es)4:&&'q(8::rcPd|j}t|ddr|dt|jz }|jr|dt |jdz }|j r|dt |j dz }|jr|d|jz }|S)Nzmaxsize=r(z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr(rlenrr)r#results rr@z Queue._formatJsDMM,- 44 ( dkk!2 56 6F ==  3t}}#5"6a8 8F ==  3t}}#5"6a8 8F  ! !  6 678 8F rc,t|jS)zNumber of items in the queue.)rHr(r+s rqsizez Queue.qsizeVs4;;rc|jS)z%Number of items allowed in the queue.)rr+s rr$z Queue.maxsizeZs}}rc|j S)z3Return True if the queue is empty, False otherwise.r(r+s remptyz Queue.empty_s;;rc\|jdkry|j|jk\S)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rF)rrKr+s rfullz Queue.fullcs( ==A ::<4==0 0rcK|jrU|jj}|jj | |d{|jrU|j|S7&#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYww)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rQ _get_loop create_futurerr/cancelremove ValueError cancelledr9 put_nowait)r#r1putters rputz Queue.putns iik^^%335F MM  (  iik&t$$  MM((0!yy{6+;+;+=%%dmm4sZA C8 A;A9A;C8(C89A;;C5B*)C5* B63C55B66?C55C8c|jrt|j||xjdz c_|jj |j |jy)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. r N)rQrr2rrclearr9rr0s rrYzQueue.put_nowaitsP 99;O $ !#  $--(rcK|jrU|jj}|jj | |d{|jrU|jS7%#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYww)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rOrSrTrr/rUrVrWrXr9 get_nowait)r#getters rgetz Queue.gets jjl^^%335F MM  (  jjl&    MM((0!zz|F,<,<,>%%dmm4sZA C7 A:A8A:C7(C78A::C4 B)(C4) B52C44B55?C44C7c|jrt|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rOrr,r9rr0s rr_zQueue.get_nowaits5 ::< yy{ $--( rc|jdkr td|xjdzc_|jdk(r|jjyy)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesr N)rrWrr r+s r task_donezQueue.task_donesR  ! !Q &@A A !#  ! !Q & NN    'rctK|jdkDr#|jjd{yy7w)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwaitr+s rjoinz Queue.joins4  ! !A %..%%' ' ' & 's -868N)r)rrrrr%r!r,r2r9rArC classmethodr__class_getitem__r@rKpropertyr$rOrQr[rYrar_rdrgrrrrrs~  *%! L;$L1   1%6 )!4 !( (rrcReZdZdZdZej fdZejfdZ y)rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cg|_yr'rNr"s rr!zPriorityQueue._init  rc*||j|yr'rN)r#r1heappushs rr2zPriorityQueue._putsd#rc&||jSr'rN)r#heappops rr,zPriorityQueue._getst{{##rN) rrrrr!heapqror2rqr,rrrrrs( #(..$!==$rrc"eZdZdZdZdZdZy)rzEA subclass of Queue that retrieves most recently added entries first.cg|_yr'rNr"s rr!zLifoQueue._initrmrc:|jj|yr'r.r0s rr2zLifoQueue._putr3rc6|jjSr')r(popr+s rr,zLifoQueue._gets{{  rN)rrrrr!r2r,rrrrrsO!!rr)__all__rrrtypesrr r Exceptionrr_LoopBoundMixinrrrrrrr}s^ L     B(F " "B(J $E $ ! !r__pycache__/__main__.cpython-312.opt-2.pyc000064400000012521152343231170014141 0ustar00 ֦i jddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z GddejZGddejZedk(rej$d ej&Zej*ed eiZd D]Zeeee<eeeZdad a ddlZeZd e_ejA ejCyy#e$rY9wxYw#e"$r3t4r*t4jGst4jId aYVwxYw)N)futuresc$eZdZfdZdZxZS)AsyncIOInteractiveConsolect|||jjxjt j zc_||_tj|_ y)N) super__init__compilecompilerflagsastPyCF_ALLOW_TOP_LEVEL_AWAITloop contextvars copy_contextcontext)selflocalsr __class__s )/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH   ##s'E'EE# "//1 c8tjjfd}tj |j  j S#t$rt$r,trjdYyjYywxYw)Nc&dadatjj} |}tj|sj|y jj|jatj ty#t $rt $r}daj|Yd}~yd}~wt$r}j|Yd}~yd}~wwxYw#t$r}j|Yd}~yd}~wwxYw)NFTr) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterrupt set_exception BaseExceptioninspect iscoroutine set_resultr create_taskrr _chain_future)funccoroexexccodefuturers rcallbackz3AsyncIOInteractiveConsole.runcode..callbacksK&+ #%%dDKK8D v&&t,!!$' *"ii33D$,,3O %%k6:! $ *.'$$R(  $$R( ! *$$S)) *s<BAC,C)*C C)C$$C), D5D  Drz KeyboardInterrupt ) concurrentrFuturercall_soon_threadsaferresultrr"rwrite showtraceback)rr,r.r-s`` @rruncodez!AsyncIOInteractiveConsole.runcodes|##**, *< !!(DLL!A %==? "   %& 23""$  %s A)BBB)__name__ __module__ __qualname__r r5 __classcell__)rs@rrrs 2 +%rrceZdZdZy) REPLThreadc  dtjdtjdttddd}tj |dt jd d t tjtjy#t jd d t tjtjwxYw) Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. ps1z>>> zimport asynciozexiting asyncio REPL...)bannerexitmsgignorez ^coroutine .* was never awaited$)messagecategory) sysversionplatformgetattrconsoleinteractwarningsfilterwarningsRuntimeWarningrr1stop)rr>s rrunzREPLThread.runGs 1 }D?*3v./~ ?    1  3  # #;' )  % %dii 0  # #;' )  % %dii 0s ABACN)r6r7r8rMrrr;r;Es1rr;__main__zcpython.run_stdinasyncio>__file__r6__spec__ __loader__ __package__ __builtins__FT)%r rPr,concurrent.futuresr/rr#rC threadingrrIrInteractiveConsolerThreadr;r6auditnew_event_looprset_event_loop repl_localskeyrrGrrreadline ImportError repl_threaddaemonstart run_foreverr donecancelrNrrrhsP    3% 7 73%l1!!10 z CII!" !7 ! ! #DG4 g&K,"8C= C, ( T:GK# ,KK       G&    ! ;#3#3#5""$*.'   s$9C/C:/C76C7:5D21D2__pycache__/format_helpers.cpython-312.opt-1.pyc000064400000007435152343231170015442 0ustar00 ֦id ZddlZddlZddlZddlZddlZddlmZdZdZdZ d dZ d dZ y) N) constantsc\tj|}tj|r$|j}|j|j fSt |tjrt|jSt |tjrt|jSyN) inspectunwrap isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcodes //usr/lib64/python3.12/asyncio/format_helpers.pyrr s >>$ D$}}  $"5"566$ ))*#DII..$ //0#DII.. c\t||d}t|}|r|d|dd|dz }|S)Nz at r:r)_format_callbackr)rargs func_reprsources r_format_callback_sourcersB tT2I !$ 'F tF1I;aq {33 rcg}|r|jd|D|r&|jd|jDdjdj|S)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). c3FK|]}tj|ywrreprlibrepr).0args r z*_format_args_and_kwargs..&s7$3W\\#&$s!c3VK|]!\}}|dtj|#yw)=Nr)r"kvs rr$z*_format_args_and_kwargs..(s)I.$!Qs!GLLO,-.s')z({})z, )extenditemsformatjoin)rkwargsr*s r_format_args_and_kwargsr.sQ E  7$77  I&,,.II ==5) **rct|tjr;t|||z}t |j |j |j|St|dr|jr |j}n0t|dr|jr |j}n t|}|t||z }|r||z }|S)N __qualname____name__) r rrr.rrrkeywordshasattrr0r1r!)rrr-suffixrs rrr,s$ ))*(v6? 499dmmVLLt^$):):%% z "t}}MM J  (v66I V rc|tjj}|tj}t j jt j||d}|j|S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. F)limit lookup_lines) sys _getframef_backrDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr6stacks r extract_stackrC>sj y MMO " " }++  " " * *9+?+?+B168= + ?E MMO Lr))NN) rrr r8r<rDrrrr.rrCrrrFs0   +$r__pycache__/locks.cpython-312.pyc000064400000065435152343231170012610 0ustar00 ֦i3J`dZdZddlZddlZddlmZddlmZGddZGd d eejZ Gd d ejZ Gd deejZ GddeejZ Gdde Z GddejZGddejZy)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreBarrierN) exceptions)mixinsceZdZdZdZy)_ContextManagerMixinc@K|jd{y7wN)acquireselfs &/usr/lib64/python3.12/asyncio/locks.py __aenter__z_ContextManagerMixin.__aenter__ slln s c,K|jywr)release)rexc_typeexctbs r __aexit__z_ContextManagerMixin.__aexit__s sN)__name__ __module__ __qualname__rrrr r s  rr c@eZdZdZdZfdZdZdZdZdZ xZ S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... c d|_d|_yNF)_waiters_lockedrs r__init__z Lock.__init__Ms  rct|}|jrdnd}|jr|dt |j}d|ddd|dS Nlockedunlocked , waiters:)super__repr__r$r#lenrresextra __class__s rr0z Lock.__repr__QsYg  LLj ==gZDMM(:';zLock.acquire..cs9=aAKKM=sT) r$r#all collectionsdeque _get_loop create_futureappendremover CancelledError_wake_up_firstrfuts rrz Lock.acquire\s  $--"794==99DL == '--/DMnn,,. S!   *  $$S)   $$S)(( <<##%  sBBD#C$C %C)C/D# CC,,C//1D  D#c`|jrd|_|jytd)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r$rG RuntimeErrorrs rrz Lock.release|s* << DL    !67 7rc|jsy tt|j}|j s|j dyy#t$rYywxYw)z*Wake up the first waiter if it isn't done.NT)r#nextiter StopIterationdone set_resultrHs rrGzLock._wake_up_firstsT}}  tDMM*+Cxxz NN4     sA AA) rrr__doc__r%r0r(rrrG __classcell__r5s@rrrs(3j*@8" !rrc@eZdZdZdZfdZdZdZdZdZ xZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. cDtj|_d|_yr")r@rAr#_valuers rr%zEvent.__init__s#))+  rct|}|jrdnd}|jr|dt |j}d|ddd|dS) Nsetunsetr*r+r r,r-r.)r/r0rWr#r1r2s rr0zEvent.__repr__sYg ' ==gZDMM(:';= 0) ValueErrorr#rW)rvalues rr%zSemaphore.__init__Ys# 19CD D  rct|}|jrdnd|j}|jr|dt |j}d|ddd|dS) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s rr0zSemaphore.__repr___sgg  KKM1A$++/O ==gZDMM(:';K|]}|j ywrr9r;s rr>z#Semaphore.locked..isA,?aAKKM!,?sr)rWanyr#rs rr(zSemaphore.lockedfs4{{aC ADMM,?R,?A A CrcK|js|xjdzc_y|jtj|_|j j }|jj| |d{|jj| |jdkDr|jy7@#|jj|wxYw#tj$r7|js%|xjdz c_|jwxYww)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. r TNr) r(rWr#r@rArBrCrDrEr rFr: _wake_up_nextrHs rrzSemaphore.acquireks{{} KK1 K == '--/DMnn,,. S!  *  $$S) ;;?     $$S)(( ==? q ""$   sCBD> CCCC1.!D>CC..C11A D;;D>cN|xjdz c_|jy)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. r N)rWr~rs rrzSemaphore.releases q  rc|jsy|jD]:}|jr|xjdzc_|jdyy)z)Wake up the first waiter that isn't done.Nr T)r#rPrWrQrHs rr~zSemaphore._wake_up_nexts@}} ==C88: q t$ !rrt) rrrrRr%r0r(rrr~rSrTs@rrrJs(  *C "H rrc.eZdZdZdfd ZfdZxZS)rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. c2||_t| |yr) _bound_valuer/r%)rrxr5s rr%zBoundedSemaphore.__init__s! rcj|j|jk\r tdt|y)Nz(BoundedSemaphore released too many times)rWrrwr/r)rr5s rrzBoundedSemaphore.releases+ ;;$++ +GH H rrt)rrrrRr%rrSrTs@rrrs  rrceZdZdZdZdZdZy) _BarrierStatefillingdraining resettingbrokenN)rrrFILLINGDRAINING RESETTINGBROKENrrrrrsGHI FrrceZdZdZdZfdZdZdZdZdZ dZ d Z d Z d Z d Zed ZedZedZxZS)ra Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. c|dkr tdt|_||_tj |_d|_y)z1Create a barrier, initialised to 'parties' tasks.r zparties must be >= 1rN)rwr_cond_partiesrr_state_count)rpartiess rr%zBarrier.__init__s9 Q;34 4[  #++  rct|}|jj}|js|d|j d|j z }d|ddd|dS)Nr*/r+r r,r-r.)r/r0rrxr n_waitingrr2s rr0zBarrier.__repr__sdg ;;$$%{{ z$..!14<<.A AE3q9+Rwb))rc>K|jd{S7wrrjrs rrzBarrier.__aenter__sYY[   s c Kywrr)rargss rrzBarrier.__aexit__s  sc0K|j4d{|jd{ |j}|xjdz c_|dz|jk(r|j d{n|j d{||xjdzc_|j cdddd{S777Y7B7 #|xjdzc_|j wxYw#1d{7swYyxYww)zWait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. Nr )r_blockrr_release_wait_exit)rindexs rrbz Barrier.waits:::++-     q 19 ---/))**,&& q  ::  *& q  ::sDC DDCDAC7C8CCC%D; DCDDCCD'C>>DDD DDcKjjfdd{jtjurt j dy76w)Nc\jtjtjfvSr)rrrrrsrz Barrier._block..s$DKK&& (?(?(rzBarrier aborted)rrmrrrr BrokenBarrierErrorrs`rrzBarrier._blocksZ jj!!     ;;-.. .//0AB B / s"AA7AcjKtj|_|jj ywr)rrrrrsrs rrzBarrier._releases% $,,  s13cKjjfdd{jtjtj fvrt jdy7Fw)Nc<jtjuSr)rrrrsrrzBarrier._wait..s$++]=R=R*RrzAbort or reset of barrier)rrmrrrrr rrs`rrz Barrier._waits] jj!!"RSSS ;;=//1H1HI I//0KL L J Ts"A.A,AA.c|jdk(r\|jtjtjfvrtj |_|j jyy)Nr)rrrrrrrrsrs rrz Barrier._exitsO ;;! {{}66 8N8NOO+33 JJ ! ! # rchK|j4d{|jdkDr2|jtjur+tj|_ntj |_|jj dddd{y77#1d{7swYyxYww)zReset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. Nr)rrrrrrrsrs rresetz Barrier.reset"sk :::{{Q;;m&=&=="/"9"9DK+33 JJ ! ! #::::::sEB2BB2A1B B2BB2B2B/#B& $B/+B2cK|j4d{tj|_|jj dddd{y7D7#1d{7swYyxYww)zPlace the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. N)rrrrrsrs rabortz Barrier.abort1sA :::'..DK JJ ! ! #::::::sDA1AA10A A1AA1A1A."A% #A.*A1c|jS)z8Return the number of tasks required to trip the barrier.)rrs rrzBarrier.parties;s}}rcT|jtjur |jSy)zrs! * C! !7!7C!L:&F " ":&zm($f&<&<m(`W$f&<&<Wty$DIIM3f$$M3r__pycache__/streams.cpython-312.pyc000064400000101130152343231170013132 0ustar00 ֦ikldZddlZddlZddlZddlZddlZeedredz ZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd l mZdd lmZd ZdeddZdeddZeedrdeddZdeddZGdde j,ZGddee j,ZGddZGddZy)) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)limitc Ktj}t||}t|| |j fd||fi|d{\}}t | ||}||fS7w)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) rlooprcSNprotocols(/usr/lib64/python3.12/asyncio/streams.pyz!open_connection..1sN)r get_running_looprrcreate_connectionr) hostportrkwdsrreader transport_writerrs @rrrsx&  " " $D D 1F#F6H///$.(,..LIq )Xvt .sA A) A'A)cKtjfd}j|||fi|d{S7w)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. c>t}t|}|SNrrrrr%rclient_connected_cbrrs rfactoryzstart_server..factoryNs&E5'0C-13rN)r r create_server)r.r"r#rr$r/rs` ` @rrr6s@,  " " $D $##GT4@4@ @@ @s4A>AcKtj}t||}t|||jfd|fi|d{\}}t |||}||fS7w)z@Similar to `open_connection` but works with UNIX Domain Sockets.rrcSrrrsrrz&open_unix_connection..bsHrN)r r rrcreate_unix_connectionr) pathrr$rr%r&r'r(rs @rr r Zsv&&(E5'T:8T88 d,&*,, 1i64@v~,sA A( A& A(cKtjfd}j||fi|d{S7w)z=Similar to `start_server` but works with UNIX Domain Sockets.c>t}t|}|Sr+r,r-s rr/z"start_unix_server..factoryks&!D9F+F4G157HOrN)r r create_unix_server)r.r4rr$r/rs` ` @rr r fs>&&(  -T,,WdCdCCCCs 3?=?c6eZdZdZd dZdZdZdZdZdZ y) FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. Nc|tj|_n||_d|_t j |_d|_yNF)r get_event_loop_loop_paused collectionsdeque_drain_waiters_connection_lost)selfrs r__init__zFlowControlMixin.__init__~s> <..0DJDJ )//1 %rc|jrJd|_|jjrtjd|yy)NTz%r pauses writing)r>r= get_debugrdebugrCs r pause_writingzFlowControlMixin.pause_writings:<< ::   ! LL,d 3 "rc|jsJd|_|jjrtjd||j D]$}|j r|jd&y)NFz%r resumes writing)r>r=rFrrGrAdone set_resultrCwaiters rresume_writingzFlowControlMixin.resume_writings[||| ::   ! LL-t 4))F;;=!!$'*rcd|_|jsy|jD]8}|jr||j d(|j |:yNT)rBr>rArKrL set_exceptionrCexcrNs rconnection_lostz FlowControlMixin.connection_lostsN $|| ))F;;=;%%d+((- *rcNK|jr td|jsy|jj }|j j | |d{|j j|y7 #|j j|wxYww)NzConnection lost)rBConnectionResetErrorr>r= create_futurerAappendremoverMs r _drain_helperzFlowControlMixin._drain_helpers  &'89 9|| ))+ ""6* /LL    & &v .     & &v .s0AB%B"B#B'B%BB""B%ctr)NotImplementedErrorrCstreams r_get_close_waiterz"FlowControlMixin._get_close_waiters!!rr) __name__ __module__ __qualname____doc__rDrIrOrUr[r`rrrr9r9ts%&4 ( . /"rr9cfeZdZdZdZd fd ZedZdZdZ fdZ dZ d Z d Z d ZxZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Nc4t|||,tj||_|j |_nd|_|||_d|_d|_d|_ d|_ ||_ d|_ |jj|_y)NrF)superrDweakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer_task _transport_client_connected_cb _over_sslr=rX_closed)rC stream_readerr.r __class__s rrDzStreamReaderProtocol.__init__s d#  $%,[[%?D "%2%D%DD "%)D "  *#0D "'" $7!zz//1 rc<|jy|jSr)rjrHs r_stream_readerz#StreamReaderProtocol._stream_readers  ! ! )%%''rc|j}|j}||_||_|j ddu|_y)N sslcontext)r=r&rnrpget_extra_inforr)rCr(rr&s r_replace_writerz$StreamReaderProtocol._replace_writers<zz$$ $#"11,?tKrcxjrKddi}jrj|d<jj|j y_j }||jjddu_ jt|j_ j|j}tj|rAfd}jj|_j j#|d_yy)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.source_tracebackryc|jrjy|j}|0jj d|djyy)Nz*Unhandled exception in client_connected_cb)r} exceptionr&) cancelledcloserr=call_exception_handler)taskrTrCr&s rcallbackz6StreamReaderProtocol.connection_made..callbacks\~~'!)..*C 99'S),)2; ") 'r)rmrkr=rabortrprw set_transportrzrrrqrrnr iscoroutine create_taskroadd_done_callbackrl)rCr&contextr%resrs`` rconnection_madez$StreamReaderProtocol.connection_mades#  " "@G %%.2.D.D*+ JJ - -g 6 OO  #$$     +"11,?tK  $ $ 0".y$/5/3zz#;D ++F,0,?,?AC%%c* *"ZZ33C8  ,,X6"&D / 1rcf|j}|$||jn|j||jj s9||jj dn|jj|t ||d|_d|_ d|_ d|_ yr) rwfeed_eofrRrsrKrLrgrUrjrnrorp)rCrTr%rus rrUz$StreamReaderProtocol.connection_lost s$$  {!$$S)||  "{ ''- **3/ $!%" rcD|j}||j|yyr)rw feed_data)rCdatar%s r data_receivedz"StreamReaderProtocol.data_receiveds&$$     T " rcZ|j}||j|jryy)NFT)rwrrr)rCr%s r eof_receivedz!StreamReaderProtocol.eof_received!s,$$   OO  >>rc|jSr)rsr^s rr`z&StreamReaderProtocol._get_close_waiter,s ||rc |j}|jr"|js|jyyy#t$rYywxYwr)rsrKrrAttributeError)rCcloseds r__del__zStreamReaderProtocol.__del__/sM #\\F{{}V%5%5%7  "&8}   s A A  A NN)rarbrcrdrkrDpropertyrwr{rrUrrr`r __classcell__)rus@rrrsN2((( L('T$#  #rrczeZdZdZdZdZedZdZdZ dZ dZ d Z d Z d Zdd ZdZd d d ddZdZy )ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. c||_||_|t|tsJ||_||_|j j |_|jjdyr) rp _protocol isinstancer_readerr=rX _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__Es[#!~FL!AAA  !ZZ557 %%d+rc|jjd|jg}|j|j d|jdj dj |S)N transport=zreader=<{}> )rurarprrYformatjoinrCinfos r__repr__zStreamWriter.__repr__Os['':doo5H)IJ << # KK'$,,!12 3}}SXXd^,,rc|jSrrprHs rr&zStreamWriter.transportUs rc:|jj|yr)rpwriterCrs rrzStreamWriter.writeYs d#rc:|jj|yr)rp writelinesrs rrzStreamWriter.writelines\s ""4(rc6|jjSr)rp write_eofrHs rrzStreamWriter.write_eof_s((**rc6|jjSr)rp can_write_eofrHs rrzStreamWriter.can_write_eofbs,,..rc6|jjSr)rprrHs rrzStreamWriter.closees$$&&rc6|jjSr)rp is_closingrHs rrzStreamWriter.is_closinghs))++rcVK|jj|d{y7wr)rr`rHs r wait_closedzStreamWriter.wait_closedksnn..t444s )')Nc:|jj||Sr)rprz)rCnamedefaults rrzzStreamWriter.get_extra_infons--dG<>jjl"jj22 OOXz#_"7!5 377 (  & 7s!8BB 3B.B/BBc|jjsc|jjrt j dt y|jt j d|t yy)Nzloop is closedz unclosed )rprr= is_closedwarningswarnResourceWarningrrHs rrzStreamWriter.__del__sT))+zz##% .@  $2OD ,rr)rarbrcrdrDrrr&rrrrrrrrzrrrrrrrr;sh,- $)+/',5=-4)-.2-1' ErrceZdZdZedfdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZddZddZdZdZdZy)rNcl|dkr td||_|tj|_n||_t |_d|_d|_d|_ d|_ d|_ |jjr.tjtj d|_yy)NrzLimit cannot be <= 0Fr ) ValueError_limitr r<r= bytearray_buffer_eof_waiter _exceptionrpr>rFr extract_stacksys _getframerk)rCrrs rrDzStreamReader.__init__s A:34 4 <..0DJDJ {    ::   !%3%A%A a &"D " "rcdg}|jr'|jt|jd|jr|jd|jt k7r|jd|j|j r|jd|j |jr|jd|j|jr|jd|j|jr|jdd jd j|S) Nrz byteseofzlimit=zwaiter=z exception=rpausedrr) rrYlenrr_DEFAULT_LIMITrrrpr>rrrs rrzStreamReader.__repr__s << KK3t||,-V4 5 99 KK  ;;. ( KK& . / << KK'$,,!12 3 ?? KK*T__$78 9 ?? KK*T__$78 9 << KK !}}SXXd^,,rc|jSr)rrHs rrzStreamReader.exceptions rc||_|j}|*d|_|js|j|yyyr)rrrrRrSs rrRzStreamReader.set_exceptionsC  DL##%$$S)& rct|j}|*d|_|js|jdyyy)z1Wakeup read*() functions waiting for data or EOF.N)rrrLrMs r_wakeup_waiterzStreamReader._wakeup_waiters<  DL##%!!$'& rc8|jJd||_y)NzTransport already setr)rCr&s rrzStreamReader.set_transports&?(??&#rc|jrEt|j|jkr"d|_|jj yyyr;)r>rrrrpresume_readingrHs r_maybe_resume_transportz$StreamReader._maybe_resume_transports; <rr pause_readingr]rs rrzStreamReader.feed_datas99888}  D!  OO 'LLDLL!A O3 $--/ $ 4! ( ' '#'  'sB%%B87B8cRK|jt|d|jrJd|jr!d|_|jj |j j|_ |jd{d|_y7 #d|_wxYww)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataz_wait_for_data after EOFF)r RuntimeErrorrr>rprr=rX)rC func_names r_wait_for_datazStreamReader._wait_for_data s << #+456 699888} << DL OO * * ,zz//1  ,,  DL DLs0A:B'=B B BB'B B$$B'cKd}t|} |j|d{}|S7#tj$r}|jcYd}~Sd}~wtj $r}|j j||jr|j d|j|z=n|j j|jt|jdd}~wwxYww)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilrIncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)rCsepseplenlinees rreadlinezStreamReader.readline%s S (,,D --- 99 ++ (||&&sAJJ7LL!5!**v"5!56 ""$  ( ( *QVVAY' '  (sJC5.,.C5.C2 A C2 C5C2(BC--C22C5cKt|}|dk(r td|j |jd} t|j}||z |k\rO|jj ||}|dk7rn|dz|z }||j kDrt jd||jrEt|j}|jjt j|d|jdd{||j kDrt jd||jd||z}|jd||z=|jt|S7iw) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrrrrbytesrrrr)rC separatorroffsetbuflenisepchunks rrzStreamReader.readuntilDsz(Y Q;KL L ?? &// !*&F&(||((F;2: !f,DKK'$66L  yydll+ ""$ 44UDAA%%k2 2 2=@ $++ ..DdL L ^dVm, LL$- ( $$&U| 3sDE6 E4 A*E6cK|j |j|dk(ry|dkrLg} |j|jd{}|sn|j|8dj |S|j s%|j s|jdd{tt|j d|}|j d|=|j|S77Hw)aRead up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rr rrYrrrrr memoryviewr)rCnblocksblockrs rr zStreamReader.reads, ?? &// ! 6 q5 F"ii 44 e$  88F# #||DII%%f- - -Z -bq12 LL!  $$& 5 .s&AC)C%AC)C'AC)'C)cK|dkr td|j |j|dk(ryt|j|kr|jrEt |j}|jj tj|||jdd{t|j|krt|j|k(r0t |j}|jj n0t t|jd|}|jd|=|j|S7w)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrrrrr r)rCr  incompleters rrzStreamReader.readexactlys q5IJ J ?? &// ! 6$,,!#yy"4<<0  ""$ 44ZCC%%m4 4 4 $,,!# t||  !&D LL   DLL1"156D RaR  $$&  5sB,E.E/E B Ec|SrrrHs r __aiter__zStreamReader.__aiter__s rcXK|jd{}|dk(rt|S7w)Nr)rStopAsyncIteration)rCvals r __anext__zStreamReader.__anext__s+MMO# #:$ $ $s *(*)r)r)rarbrcrkrrDrrrRrrrrrrrrrr rrrrrrrrsf+$",-$*($- .$, 8>Yv1f'Rrrrr)__all__r?socketrrrhhasattrr r rrrlogrtasksrrrrr r Protocolr9rrrrrrr s '  69 <dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z Gd d ejZ Gd d Zddd dZdZy))RunnerrunN) coroutines)events) exceptions)tasks) constantsceZdZdZdZdZy)_Statecreated initializedclosedN)__name__ __module__ __qualname__CREATED INITIALIZEDCLOSED(/usr/lib64/python3.12/asyncio/runners.pyr r sGK Frr cLeZdZ ddddZdZdZdZdZddd Zd Z d Z y) rNdebug loop_factoryctj|_||_||_d|_d|_d|_d|_y)NrF) r r_state_debug _loop_factory_loop_context_interrupt_count_set_event_loop)selfrrs r__init__zRunner.__init__0s:nn  )  !$rc&|j|SN) _lazy_initr%s r __enter__zRunner.__enter__9s  rc$|jyr()close)r%exc_typeexc_valexc_tbs r__exit__zRunner.__exit__=s  rcH |jtjury |j}t ||j |j |j |jtj|jrtjd|jd|_tj|_y#|jrtjdjd|_tj|_wxYwr()rr rr!_cancel_all_tasksrun_until_completeshutdown_asyncgensshutdown_default_executorr THREAD_JOIN_TIMEOUTr$rset_event_loopr-r)r%loops rr-z Runner.close@s, ;;f00 0  (::D d #  # #D$;$;$= >  # #..y/L/LM O##%%d+ JJLDJ --DK ##%%d+ JJLDJ --DKs A$CAD!c< |j|jSr()r)r!r*s rget_loopzRunner.get_loopQs) zzrcontextc tj|stdj|t j t d|j| |j}|jj||}tjtjurztjtj tj"urGt%j&|j(|} tjtj |nd}d|_ |jj-||Ytjtj |ur3tjtj tj"SSS#t$rd}YwxYw#t.j0$r4|j*dkDr#t3|dd}||dk(r t5wxYw#|Ytjtj |ur3tjtj tj"wwwxYw)Nz"a coroutine was expected, got {!r}z7Runner.run() cannot be called from a running event loopr<) main_taskruncancel)r iscoroutine ValueErrorformatr_get_running_loop RuntimeErrorr)r"r! create_task threadingcurrent_thread main_threadsignal getsignalSIGINTdefault_int_handler functoolspartial _on_sigintr#r4rCancelledErrorgetattrKeyboardInterrupt)r%coror=tasksigint_handlerr@s rrz Runner.runVs=%%d+AHHNO O  # # % 1IK K  ?mmGzz%%dG%<  $ $ &)*?*?*A A  /63M3MM&..t$ON & fmm^<"N ! I::006*$$V]]3~E fmmV-G-GHF+% &"&  &(( $$q("4T:'HJ!O+--   *$$V]]3~E fmmV-G-GHF+s,$F-7F>- F;:F;>AHHAI%c$|jtjur td|jtjury|j Lt j|_|jsz#Runner._on_sigint..sDr)r#donecancelr!call_soon_threadsaferS)r%signumframer?s rrPzRunner._on_sigintsT "  A %inn.>     JJ + +L 9 !!r) rrrr&r+r1r-r;rr)rPrrrrrs=6!%4%(" $(+IZ)&"rrrc tj tdt||5}|j |cdddS#1swYyxYw)Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)mainrrrunners rrrsP8!- FH H e, 76zz$ 8 7 7s A  AcBtj|}|sy|D]}|j|jtj|ddi|D]G}|j r|j %|jd|j |dIy)Nreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)message exceptionrU)r all_tasksr`r4gather cancelledrjcall_exception_handler)r9 to_cancelrUs rr3r3s%I   ELL)LtLM >>   >>  '  ' 'N!^^-)  r)__all__rZenumrNrGrJrrrr r Enumr rrr3rrrrtsW   TYY I"I"X$# Lr__pycache__/staggered.cpython-312.opt-2.pyc000064400000010264152343231170014370 0ustar00 ֦iN dZddlZddlmZddlmZddlmZddlmZddd Zy) )staggered_raceN)events) exceptions)locks)tasks)loopc v K xstjt|ddgg t d fd d  f d d} t j }j  |d} j||j |jd} r j d{d r || f ~S7#tj$r,}|} D]}|j|jYd}~Nd}~wwxYw# ~wxYww)Ncj|#jssjd|jry|j }|yj |yN)discarddone set_result cancelled exceptionappend)taskexcon_completed_fut running_tasksunhandled_exceptionss */usr/lib64/python3.12/asyncio/staggered.py task_donez!staggered_race..task_doneJscd#  ($))+!  ' ' - >>  nn ; ##C(cX K|jd{|Xtjtj5t j |j d{ddd t \}}tj}tj}j||}j||j|j jd |d{}||t j }D]} | |us| j#y777#1swYxYw#t$rYywxYw7Z#t$t&f$rt($r} | |<|jYd} ~ yd} ~ wwxYwwr )wait contextlibsuppressexceptions_mod TimeoutErrorrwait_fornext StopIterationrEvent create_taskaddadd_done_callbacksetr current_taskcancel SystemExitKeyboardInterrupt BaseException) ok_to_startprevious_failed this_indexcoro_fn this_failednext_ok_to_start next_taskresultr)tedelay enum_coro_fnsrr run_one_cororr winner_index winner_results rr:z$staggered_race..run_one_coro[s    &$$^%@%@A nn_%9%9%;UCCC B "&}"5 Jkkm  ;;=$$\2BK%PQ )$##I. $ "9_F&L"M!--d3L"L(HHJ#a !D BA    %-.   %&Jz " OO   sF*E)F*(E)E*E.F*7EBF* E0E.E0"F*;F*EEF* E+(F**E++F*.E00F'F"F*"F''F*)returnN)rget_running_loop enumerater(rr$r%r&r' create_futurerCancelledErrorr*argsExceptionGroup)coro_fnsr8r propagate_cancellation_errorr. first_taskexrr9rrr:rrrr;r<s `` @@@@@@@@@rrr sV1f  ,6**,Dh'MMLJEM)"66p$( Kkkm %%l;&EF *%$$Y/'+$#113  *&&& $   ( 3. .lJ6 46J'!00 */1,)DDKK)* * 46JsaAD9A2D1C/C-C/D1 D1)D9-C//D."D)$D1)D..D11D66D9) __all__rrrrrrrrrrKs(L *37aKr__pycache__/__main__.cpython-312.pyc000064400000012521152343231170013201 0ustar00 ֦i jddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z GddejZGddejZedk(rej$d ej&Zej*ed eiZd D]Zeeee<eeeZdad a ddlZeZd e_ejA ejCyy#e$rY9wxYw#e"$r3t4r*t4jGst4jId aYVwxYw)N)futuresc$eZdZfdZdZxZS)AsyncIOInteractiveConsolect|||jjxjt j zc_||_tj|_ y)N) super__init__compilecompilerflagsastPyCF_ALLOW_TOP_LEVEL_AWAITloop contextvars copy_contextcontext)selflocalsr __class__s )/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH   ##s'E'EE# "//1 c8tjjfd}tj |j  j S#t$rt$r,trjdYyjYywxYw)Nc&dadatjj} |}tj|sj|y jj|jatj ty#t $rt $r}daj|Yd}~yd}~wt$r}j|Yd}~yd}~wwxYw#t$r}j|Yd}~yd}~wwxYw)NFTr) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterrupt set_exception BaseExceptioninspect iscoroutine set_resultr create_taskrr _chain_future)funccoroexexccodefuturers rcallbackz3AsyncIOInteractiveConsole.runcode..callbacksK&+ #%%dDKK8D v&&t,!!$' *"ii33D$,,3O %%k6:! $ *.'$$R(  $$R( ! *$$S)) *s<BAC,C)*C C)C$$C), D5D  Drz KeyboardInterrupt ) concurrentrFuturercall_soon_threadsaferresultrr"rwrite showtraceback)rr,r.r-s`` @rruncodez!AsyncIOInteractiveConsole.runcodes|##**, *< !!(DLL!A %==? "   %& 23""$  %s A)BBB)__name__ __module__ __qualname__r r5 __classcell__)rs@rrrs 2 +%rrceZdZdZy) REPLThreadc  dtjdtjdttddd}tj |dt jd d t tjtjy#t jd d t tjtjwxYw) Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. ps1z>>> zimport asynciozexiting asyncio REPL...)bannerexitmsgignorez ^coroutine .* was never awaited$)messagecategory) sysversionplatformgetattrconsoleinteractwarningsfilterwarningsRuntimeWarningrr1stop)rr>s rrunzREPLThread.runGs 1 }D?*3v./~ ?    1  3  # #;' )  % %dii 0  # #;' )  % %dii 0s ABACN)r6r7r8rMrrr;r;Es1rr;__main__zcpython.run_stdinasyncio>__file__r6__spec__ __loader__ __package__ __builtins__FT)%r rPr,concurrent.futuresr/rr#rC threadingrrIrInteractiveConsolerThreadr;r6auditnew_event_looprset_event_loop repl_localskeyrrGrrreadline ImportError repl_threaddaemonstart run_foreverr donecancelrNrrrhsP    3% 7 73%l1!!10 z CII!" !7 ! ! #DG4 g&K,"8C= C, ( T:GK# ,KK       G&    ! ;#3#3#5""$*.'   s$9C/C:/C76C7:5D21D2__pycache__/streams.cpython-312.opt-2.pyc000064400000065042152343231170014105 0ustar00 ֦ikldZddlZddlZddlZddlZddlZeedredz ZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd l mZdd lmZd ZdeddZdeddZeedrdeddZdeddZGdde j,ZGddee j,ZGddZGddZy)) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)limitc K tj}t||}t|| |j fd||fi|d{\}}t | ||}||fS7w)NrlooprcSNprotocols(/usr/lib64/python3.12/asyncio/streams.pyz!open_connection..1s)r get_running_looprrcreate_connectionr) hostportrkwdsrreader transport_writerrs @rrrs}"  " " $D D 1F#F6H///$.(,..LIq )Xvt .sA A*A(A*cK tjfd}j|||fi|d{S7w)Nc>t}t|}|SNrrrrr%rclient_connected_cbrrs rfactoryzstart_server..factoryNs&E5'0C-13r)r r create_server)r.r"r#rr$r/rs` ` @rrr6sE(  " " $D $##GT4@4@ @@ @s5A?AcK tj}t||}t|||jfd|fi|d{\}}t |||}||fS7w)NrrcSrrrsrrz&open_unix_connection..bsHr)r r rrcreate_unix_connectionr) pathrr$rr%r&r'r(rs @rr r ZswN&&(E5'T:8T88 d,&*,, 1i64@v~,sA A) A'A)cK tjfd}j||fi|d{S7w)Nc>t}t|}|Sr+r,r-s rr/z"start_unix_server..factoryks&!D9F+F4G157HOr)r r create_unix_server)r.r4rr$r/rs` ` @rr r fs?K&&(  -T,,WdCdCCCCs4A>Ac4eZdZ ddZdZdZdZdZdZy) FlowControlMixinNc|tj|_n||_d|_t j |_d|_yNF)r get_event_loop_loop_paused collectionsdeque_drain_waiters_connection_lost)selfrs r__init__zFlowControlMixin.__init__~s> <..0DJDJ )//1 %rctd|_|jjrtjd|yy)NTz%r pauses writing)r>r= get_debugrdebugrCs r pause_writingzFlowControlMixin.pause_writings- ::   ! LL,d 3 "rcd|_|jjrtjd||j D]$}|j r|jd&y)NFz%r resumes writing)r>r=rFrrGrAdone set_resultrCwaiters rresume_writingzFlowControlMixin.resume_writingsO ::   ! LL-t 4))F;;=!!$'*rcd|_|jsy|jD]8}|jr||j d(|j |:yNT)rBr>rArKrL set_exceptionrCexcrNs rconnection_lostz FlowControlMixin.connection_lostsN $|| ))F;;=;%%d+((- *rcNK|jr td|jsy|jj }|j j | |d{|j j|y7 #|j j|wxYww)NzConnection lost)rBConnectionResetErrorr>r= create_futurerAappendremoverMs r _drain_helperzFlowControlMixin._drain_helpers  &'89 9|| ))+ ""6* /LL    & &v .     & &v .s0AB%B"B#B'B%BB""B%ctr)NotImplementedErrorrCstreams r_get_close_waiterz"FlowControlMixin._get_close_waiters!!rr) __name__ __module__ __qualname__rDrIrOrUr[r`rrrr9r9ts%&4 ( . /"rr9cdeZdZ dZd fd ZedZdZdZfdZ dZ dZ d Z d Z xZS) rNc4t|||,tj||_|j |_nd|_|||_d|_d|_d|_ d|_ ||_ d|_ |jj|_y)NrF)superrDweakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer_task _transport_client_connected_cb _over_sslr=rX_closed)rC stream_readerr.r __class__s rrDzStreamReaderProtocol.__init__s d#  $%,[[%?D "%2%D%DD "%)D "  *#0D "'" $7!zz//1 rc<|jy|jSr)rirHs r_stream_readerz#StreamReaderProtocol._stream_readers  ! ! )%%''rc|j}|j}||_||_|j ddu|_y)N sslcontext)r=r&rmroget_extra_inforq)rCr(rr&s r_replace_writerz$StreamReaderProtocol._replace_writers<zz$$ $#"11,?tKrcxjrKddi}jrj|d<jj|j y_j }||jjddu_ jt|j_ j|j}tj|rAfd}jj|_j j#|d_yy)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.source_tracebackrxc|jrjy|j}|0jj d|djyy)Nz*Unhandled exception in client_connected_cb)r| exceptionr&) cancelledcloserr=call_exception_handler)taskrTrCr&s rcallbackz6StreamReaderProtocol.connection_made..callbacks\~~'!)..*C 99'S),)2; ") 'r)rlrjr=rabortrorv set_transportryrqrprrmr iscoroutine create_taskrnadd_done_callbackrk)rCr&contextr%resrs`` rconnection_madez$StreamReaderProtocol.connection_mades#  " "@G %%.2.D.D*+ JJ - -g 6 OO  #$$     +"11,?tK  $ $ 0".y$/5/3zz#;D ++F,0,?,?AC%%c* *"ZZ33C8  ,,X6"&D / 1rcf|j}|$||jn|j||jj s9||jj dn|jj|t ||d|_d|_ d|_ d|_ yr) rvfeed_eofrRrrrKrLrfrUrirmrnro)rCrTr%rts rrUz$StreamReaderProtocol.connection_lost s$$  {!$$S)||  "{ ''- **3/ $!%" rcD|j}||j|yyr)rv feed_data)rCdatar%s r data_receivedz"StreamReaderProtocol.data_receiveds&$$     T " rcZ|j}||j|jryy)NFT)rvrrq)rCr%s r eof_receivedz!StreamReaderProtocol.eof_received!s,$$   OO  >>rc|jSr)rrr^s rr`z&StreamReaderProtocol._get_close_waiter,s ||rc |j}|jr"|js|jyyy#t$rYywxYwr)rrrKrrAttributeError)rCcloseds r__del__zStreamReaderProtocol.__del__/sM #\\F{{}V%5%5%7  "&8}   s A A  A NN)rarbrcrjrDpropertyrvrzrrUrrr`r __classcell__)rts@rrrsN2((( L('T$#  #rrcxeZdZ dZdZedZdZdZdZ dZ dZ d Z d Z dd Zd Zd d d ddZdZy )rc||_||_||_||_|jj |_|j j dyr)ro _protocol_readerr=rX _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__EsI#!  !ZZ557 %%d+rc|jjd|jg}|j|j d|jdj dj |S)N transport=zreader=<{}> )rtrarorrYformatjoinrCinfos r__repr__zStreamWriter.__repr__Os['':doo5H)IJ << # KK'$,,!12 3}}SXXd^,,rc|jSrrorHs rr&zStreamWriter.transportUs rc:|jj|yr)rowriterCrs rrzStreamWriter.writeYs d#rc:|jj|yr)ro writelinesrs rrzStreamWriter.writelines\s ""4(rc6|jjSr)ro write_eofrHs rrzStreamWriter.write_eof_s((**rc6|jjSr)ro can_write_eofrHs rrzStreamWriter.can_write_eofbs,,..rc6|jjSr)rorrHs rrzStreamWriter.closees$$&&rc6|jjSr)ro is_closingrHs rrzStreamWriter.is_closinghs))++rcVK|jj|d{y7wr)rr`rHs r wait_closedzStreamWriter.wait_closedksnn..t444s )')Nc:|jj||Sr)rory)rCnamedefaults rryzStreamWriter.get_extra_infons--dG<!B8B9BB)server_hostnamessl_handshake_timeoutssl_shutdown_timeoutc &K |jjdu}|j}|jd{|jj |j ||||||d{}||_|j |y7Q7w)N) server_siderrr)rrprr= start_tlsrorz)rCrxrrrrr new_transports rrzStreamWriter.start_tlss Bnn99E >>jjl"jj22 OOXz#_"7!5 377 (  & 7s!9BB 3B/B0BBc|jjsc|jjrt j dt y|jt j d|t yy)Nzloop is closedz unclosed )rorr= is_closedwarningswarnResourceWarningrrHs rrzStreamWriter.__del__sT))+zz##% .@  $2OD ,rr)rarbrcrDrrr&rrrrrrrryrrrrrrrr;sh,- $)+/',5=-4)-.2-1' ErrceZdZdZedfdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZddZddZdZdZdZy)rNcl|dkr td||_|tj|_n||_t |_d|_d|_d|_ d|_ d|_ |jjr.tjtj d|_yy)NrzLimit cannot be <= 0Fr ) ValueError_limitr r<r= bytearray_buffer_eof_waiter _exceptionror>rFr extract_stacksys _getframerj)rCrrs rrDzStreamReader.__init__s A:34 4 <..0DJDJ {    ::   !%3%A%A a &"D " "rcdg}|jr'|jt|jd|jr|jd|jt k7r|jd|j|j r|jd|j |jr|jd|j|jr|jd|j|jr|jdd jd j|S) Nrz byteseofzlimit=zwaiter=z exception=rpausedrr) rrYlenrr_DEFAULT_LIMITrrror>rrrs rrzStreamReader.__repr__s << KK3t||,-V4 5 99 KK  ;;. ( KK& . / << KK'$,,!12 3 ?? KK*T__$78 9 ?? KK*T__$78 9 << KK !}}SXXd^,,rc|jSr)rrHs rrzStreamReader.exceptions rc||_|j}|*d|_|js|j|yyyr)rrrrRrSs rrRzStreamReader.set_exceptionsC  DL##%$$S)& rcv |j}|*d|_|js|jdyyyr)rrrLrMs r_wakeup_waiterzStreamReader._wakeup_waiters??  DL##%!!$'& rc||_yrr)rCr&s rrzStreamReader.set_transports #rc|jrEt|j|jkr"d|_|jj yyyr;)r>rrrroresume_readingrHs r_maybe_resume_transportz$StreamReader._maybe_resume_transports; <rr pause_readingr]rs rrzStreamReader.feed_datas  D!  OO 'LLDLL!A O3 $--/ $ 4! ( ' '#'  's-BB%$B%c.K |jt|d|jr!d|_|jj |j j |_ |jd{d|_y7 #d|_wxYww)NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr>rorr=rX)rC func_names r_wait_for_datazStreamReader._wait_for_data s  << #+456 6 << DL OO * * ,zz//1  ,,  DL DLs0A(B+B :B;B ?BB BBcK d}t|} |j|d{}|S7#tj$r}|jcYd}~Sd}~wtj $r}|j j||jr|j d|j|z=n|j j|jt|jdd}~wwxYww)N r) r readuntilrIncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)rCsepseplenlinees rreadlinezStreamReader.readline%s S (,,D --- 99 ++ (||&&sAJJ7LL!5!**v"5!56 ""$  ( ( *QVVAY' '  (sJC6/-/C6/C3 A C3C6C3)BC..C33C6cK t|}|dk(r td|j |jd} t|j}||z |k\rO|jj ||}|dk7rn|dz|z }||j kDrt jd||jrEt|j}|jjt j|d|jdd{||j kDrt jd||jd||z}|jd||z=|jt|S7iw)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrrrrbytesrrrr)rC separatorroffsetbuflenisepchunks rrzStreamReader.readuntilDs &Y Q;KL L ?? &// !*&F&(||((F;2: !f,DKK'$66L  yydll+ ""$ 44UDAA%%k2 2 2=@ $++ ..DdL L ^dVm, LL$- ( $$&U| 3sD E7 E5 A*E7cK |j |j|dk(ry|dkrLg} |j|jd{}|sn|j|8dj |S|j s%|j s|jdd{tt|j d|}|j d|=|j|S77Hw)Nrrread) rr rrYrrrrr memoryviewr)rCnblocksblockrs rr zStreamReader.reads * ?? &// ! 6 q5 F"ii 44 e$  88F# #||DII%%f- - -Z -bq12 LL!  $$& 5 .s&AC*C& AC*C( AC*(C*cK |dkr td|j |j|dk(ryt|j|kr|jrEt |j}|jj tj|||jdd{t|j|krt|j|k(r0t |j}|jj n0t t|jd|}|jd|=|j|S7w)Nrz*readexactly size can not be less than zeror readexactly) rrrrrrrrrrr r)rCr  incompleters rrzStreamReader.readexactlys  q5IJ J ?? &// ! 6$,,!#yy"4<<0  ""$ 44ZCC%%m4 4 4 $,,!# t||  !&D LL   DLL1"156D RaR  $$&  5sB-E/E0E B Ec|SrrrHs r __aiter__zStreamReader.__aiter__s rcXK|jd{}|dk(rt|S7w)Nr)rStopAsyncIteration)rCvals r __anext__zStreamReader.__anext__s+MMO# #:$ $ $s *(*)r)r)rarbrcrjrrDrrrRrrrrrrrrrr rrrrrrrrsf+$",-$*($- .$, 8>Yv1f'Rrrrr)__all__r?socketrrrghasattrr r rrrlogrtasksrrrrr r Protocolr9rrrrrrrs '  69 < 5  ( ( 46c t|}|sd}d}|dk(r||dd}nc|dk(r+dj||dd||dd}n3|dkDr.dj||dd|dz ||dd}d |d S) #helper function for Future.__repr__c.tj|dS)Nr)r_format_callback_source)callbacks r format_cbz$_format_callbacks..format_cbs55hCCrrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizers r_format_callbacksrs r7D  D qy r!uQx   __Yr!uQx0)BqE!H2E F  ' ' "Q%((;(,q(1"R&)(<>"Q<rc|jjg}|jtk(r^|j|j d|jn3t j |j}|j d||jr$|j t|j|jr,|jd}|j d|dd|d|S)rz exception=zresult=rz created at r:r) _statelower _FINISHED _exceptionappendreprlibrepr_result _callbacksr_source_traceback)futureinforesultframes r_future_repr_infor0,s MM   ! "D }} !    ( KK*V%6%6$9: ;\\&..1F KK'&* +  %f&7&789 ((, k%(1U1XJ78 Krcpdjt|}d|jjd|dS)N <>)joinr0r __name__)r,r-s r _future_reprr7@s8 88%f- .D v(()4& 22r) __all__r'rr_PENDING _CANCELLEDr$rrr0recursive_reprr7rrrr<sO     6((33r__pycache__/threads.cpython-312.opt-1.pyc000064400000002354152343231170014055 0ustar00 ֦i.dZddlZddlZddlmZdZdZy)z6High-level support for working with threads in asyncioN)events) to_threadcKtj}tj}t j |j |g|i|}|jd|d{S7w)aAsynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. N)rget_running_loop contextvars copy_context functoolspartialrunrun_in_executor)funcargskwargsloopctx func_calls (/usr/lib64/python3.12/asyncio/threads.pyrr s]  " " $D  " " $C!!#''4A$A&AI%%dI6 66 6sA"A+$A)%A+)__doc__r rr__all__rrrs<  7r__pycache__/threads.cpython-312.opt-2.pyc000064400000001445152343231170014056 0ustar00 ֦i, ddlZddlZddlmZdZdZy)N)events) to_threadcK tj}tj}t j |j |g|i|}|jd|d{S7w)N)rget_running_loop contextvars copy_context functoolspartialrunrun_in_executor)funcargskwargsloopctx func_calls (/usr/lib64/python3.12/asyncio/threads.pyrr sb  " " $D  " " $C!!#''4A$A&AI%%dI6 66 6sA#A,%A*&A,)r rr__all__rrrs<  7r__pycache__/futures.cpython-312.opt-2.pyc000064400000032401152343231170014115 0ustar00 ֦i8h dZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z e jZ e jZe jZe j Zej"dz ZGd d ZeZd Zd Zd ZdZdZdZdddZ ddlZej&xZZy#e$rYywxYw))Future wrap_futureisfutureN) GenericAlias) base_futures)events) exceptions)format_helpersceZdZ eZdZdZdZdZdZ dZ dZ dZ dddZ dZdZeeZedZej*dZd Zd Zdd Zd Zd ZdZdZdZdddZdZdZ dZ!dZ"e"Z#y)rNFloopc |tj|_n||_g|_|jj r.t j tjd|_ yy)Nr) r get_event_loop_loop _callbacks get_debugr extract_stacksys _getframe_source_tracebackselfrs (/usr/lib64/python3.12/asyncio/futures.py__init__zFuture.__init__Hs` <..0DJDJ ::   !%3%A%A a &"D " "c,tj|SN)r _future_reprrs r__repr__zFuture.__repr__Xs((..rc|jsy|j}|jjd||d}|jr|j|d<|j j |y)Nz exception was never retrieved)message exceptionfuturesource_traceback)_Future__log_traceback _exception __class____name__rrcall_exception_handler)rexccontexts r__del__zFuture.__del__[sl## oo>>**++IJ    ! !*.*@*@G& ' ))'2rc|jSr)r'r s r_log_tracebackzFuture._log_tracebackms###rc,|r tdd|_y)Nz'_log_traceback can only be set to FalseF) ValueErrorr')rvals rr0zFuture._log_tracebackqs FG G$rc: |j}| td|S)Nz!Future object is not initialized.)r RuntimeErrorrs rget_loopzFuture.get_loopws$;zz <BC C rc |j|j}d|_|S|jtj}ntj|j}|j|_d|_|Sr)_cancelled_exc_cancel_messager CancelledError __context__)rr,s r_make_cancelled_errorzFuture._make_cancelled_error~sw    *%%C"&D J    '++-C++D,@,@AC--" rc d|_|jtk7ryt|_||_|j y)NFT)r'_state_PENDING _CANCELLEDr9_Future__schedule_callbacks)rmsgs rcancelz Future.cancels> % ;;( "  " !!#rc |jdd}|syg|jdd|D]#\}}|jj|||%yNr-)rr call_soon)r callbackscallbackctxs r__schedule_callbackszFuture.__schedule_callbackssR OOA&  &MHc JJ 4 ='rc* |jtk(Sr)r>r@r s r cancelledzFuture.cancelleds6{{j((rc* |jtk7Sr)r>r?r s rdonez Future.dones {{h&&rc" |jtk(r|j|jtk7rt j dd|_|j%|jj|j|jS)NzResult is not ready.F) r>r@r< _FINISHEDr InvalidStateErrorr'r(with_traceback _exception_tb_resultr s rresultz Future.resultsy ;;* $,,. . ;;) #../EF F$ ?? &//001C1CD D||rc |jtk(r|j|jtk7rt j dd|_|jS)NzException is not set.F)r>r@r<rQr rRr'r(r s rr$zFuture.exceptionsT  ;;* $,,. . ;;) #../FG G$rrFc |jtk7r|jj|||y|t j }|j j||fyrE)r>r?rrG contextvars copy_contextrappend)rfnr-s radd_done_callbackzFuture.add_done_callbacksW ;;( " JJ T7 ;%224 OO " "B= 1rc |jDcgc]\}}||k7r||f}}}t|jt|z }|r||jdd|Scc}}wr)rlen)rr\frJfiltered_callbacks removed_counts rremove_done_callbackzFuture.remove_done_callbackss /3oo*.=(1c!"b !#h.= *DOO,s3E/FF !3DOOA  *sAc |jtk7r$tj|jd|||_t |_|j y)N: )r>r?r rRrUrQrA)rrVs r set_resultzFuture.set_resultsO ;;( "..$++b/IJ J   !!#rcl |jtk7r$tj|jd|t |t r|}t |t rtd}||_||_ |}||_ |j|_ t|_|jd|_y)NrezPStopIteration interacts badly with generators and cannot be raised into a FutureT)r>r?r rR isinstancetype StopIterationr5 __cause__r;r( __traceback__rTrQrAr')rr$new_excs r set_exceptionzFuture.set_exceptions ;;( "..$++b/IJ J i &! I i /"$,-G!*G "+G I#&44  !!##rc#K|js d|_||js td|jSw)NTzawait wasn't used with future)rO_asyncio_future_blockingr5rVr s r __await__zFuture.__await__s=yy{,0D )Jyy{>? ?{{}sAA r)$r* __module__ __qualname__r?r>rUr(rrr9r8rpr'rr!r. classmethodr__class_getitem__propertyr0setterr6r<rCrArMrOrVr$r]rcrfrnrq__iter__rrrrs&FGJ EON %O#" /3 $L1 $$%% (  >) ' 04 2  $$.Hrrc^ |j}|S#t$rY|jSwxYwr)r6AttributeErrorr)futr6s r _get_loopr}-s:<<z    99  s  ,,cJ |jry|j|yr)rMrf)r|rVs r_set_result_unless_cancelledr9sI }}NN6rclt|}|tjjurt j|j S|tjj urt j |j S|tjjurt j|j S|Sr)ri concurrentfuturesr:r args TimeoutErrorrR)r, exc_classs r_convert_future_excr@sS IJ&&555((#((33 j((55 5&&11 j((:: :++SXX66 rc  |jr|j|jsy|j}||jt |y|j }|j|yr)rMrCset_running_or_notify_cancelr$rnrrVrf)rsourcer$rVs r_set_concurrent_future_staterLsuB   2: 2 2 4  "I   !4Y!?@ f%rc |jry|jr|jy|j}||jt |y|j }|j |yr)rMrCr$rnrrVrf)rdestr$rVs r_copy_future_stater[sj  ~~  $$&    29= >]]_F OOF #rc ts/ttjjs t dts/ttjjs t dtr t ndtr t nddfd}fd}j|j|y)Nz(A future is required for source argumentz-A future is required for destination argumentcLt|r t||yt||yr)rrr)r%others r _set_statez!_chain_future.._set_states F  uf - ( 7rc|jr3urjyjjyyr)rMrCcall_soon_threadsafe) destination dest_loopr source_loops r_call_check_cancelz)_chain_future.._call_check_cancels<  ""kY&> 00? #rcjrjryur |yjryj|yr)rM is_closedr)rrrrrs r_call_set_statez&_chain_future.._call_set_states[  ! ! #%)*=*=*?    [ 8 {F +""$  * *:{F Kr)rrhrrr TypeErrorr}r])rrrrrrrs`` @@@r _chain_futureros F Jv/9/A/A/H/H%JBCC K K4>4F4F4M4M*OGHH'/'7)F#TK*2;*? +&TI8 @ L!!"45 _-rr c t|r|S|tj}|j}t |||Sr)rr r create_futurer)r%r new_futures rrrsE0  |$$&##%J&*% r)__all__concurrent.futuresrrYloggingrtypesrrr r r rr?r@rQDEBUG STACK_DEBUGr _PyFuturer}rrrrrr_asyncio_CFuture ImportErrorryrrrs4        $ $  " " mma HHX     &$().X!% ( !'FX   sB))B10B1__pycache__/protocols.cpython-312.pyc000064400000021120152343231170013500 0ustar00 ֦i-~dZdZGddZGddeZGddeZGdd eZGd d eZd Zy )zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc,eZdZdZdZdZdZdZdZy)ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cy)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)self transports */usr/lib64/python3.12/asyncio/protocols.pyconnection_madezBaseProtocol.connection_madecy)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrr excs r connection_lostzBaseProtocol.connection_lostrrcy)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrr s r pause_writingzBaseProtocol.pause_writing%rrcy)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrrs r resume_writingzBaseProtocol.resume_writing;rrN) __name__ __module__ __qualname____doc__ __slots__r rrrrrr rr s"I   , rrc eZdZdZdZdZdZy)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcy)zTCalled when some data is received. The argument is a bytes object. Nr)r datas r data_receivedzProtocol.data_received^rrcyzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrrs r eof_receivedzProtocol.eof_receiveddrrN)rrrrrr!r$rrr rrBs2I  rrc&eZdZdZdZdZdZdZy)ra:Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcy)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)r sizehints r get_bufferzBufferedProtocol.get_bufferrrcy)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)r nbytess r buffer_updatedzBufferedProtocol.buffer_updatedrrcyr#rrs r r$zBufferedProtocol.eof_receivedrrN)rrrrrr(r+r$rrr rrms.I    rrc eZdZdZdZdZdZy)rz Interface for datagram protocol.rcy)z&Called when some datagram is received.Nr)r r addrs r datagram_receivedz"DatagramProtocol.datagram_receivedrrcy)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrrs r error_receivedzDatagramProtocol.error_receivedrrN)rrrrrr0r2rrr rrs*I5 rrc&eZdZdZdZdZdZdZy)rz,Interface for protocol for subprocess calls.rcy)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)r fdr s r pipe_data_receivedz%SubprocessProtocol.pipe_data_receivedrrcy)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)r r5rs r pipe_connection_lostz'SubprocessProtocol.pipe_connection_lostrrcy)z"Called when subprocess has exited.Nrrs r process_exitedz!SubprocessProtocol.process_exitedrrN)rrrrrr6r8r:rrr rrs6I  1rrct|}|rr|j|}t|}|s td||k\r||d||j|y|d||d||j|||d}t|}|rqyy)Nz%get_buffer() returned an empty buffer)lenr( RuntimeErrorr+)protor data_lenbufbuf_lens r _feed_data_to_buffered_protorBs4yH x(c(FG G h !C N   *  'NCM   )>D4yH rN)r__all__rrrrrrBrrr rDsQ%  6 6 r( |( V2 |2 j  |  11.!r__pycache__/staggered.cpython-312.opt-1.pyc000064400000014376152343231170014377 0ustar00 ֦iPdZdZddlZddlmZddlmZddlmZddlmZdd d Z y) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loopc t Kxstjt|ddgg t d fd d  f d d} t j }j  |d} j||j |jd} r j d{d r || f ~S7#tj$r,}|} D]}|j|jYd}~Nd}~wwxYw# ~wxYww)aRun coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. Ncj|#jssjd|jry|j }|yj |yN)discarddone set_result cancelled exceptionappend)taskexcon_completed_fut running_tasksunhandled_exceptionss */usr/lib64/python3.12/asyncio/staggered.py task_donez!staggered_race..task_doneJscd#  ($))+!  ' ' - >>  nn ; ##C(cX K|jd{|Xtjtj5t j |j d{ddd t \}}tj}tj}j||}j||j|j jd |d{}||t j }D]} | |us| j#y777#1swYxYw#t$rYywxYw7Z#t$t&f$rt($r} | |<|jYd} ~ yd} ~ wwxYwwr )wait contextlibsuppressexceptions_mod TimeoutErrorrwait_fornext StopIterationrEvent create_taskaddadd_done_callbacksetr current_taskcancel SystemExitKeyboardInterrupt BaseException) ok_to_startprevious_failed this_indexcoro_fn this_failednext_ok_to_start next_taskresultr)tedelay enum_coro_fnsrr run_one_cororr winner_index winner_results rr:z$staggered_race..run_one_coro[s    &$$^%@%@A nn_%9%9%;UCCC B "&}"5 Jkkm  ;;=$$\2BK%PQ )$##I. $ "9_F&L"M!--d3L"L(HHJ#a !D BA    %-.   %&Jz " OO   sF*E)F*(E)E*E.F*7EBF* E0E.E0"F*;F*EEF* E+(F**E++F*.E00F'F"F*"F''F*)returnN)rget_running_loop enumerater(rr$r%r&r' create_futurerCancelledErrorr*argsExceptionGroup)coro_fnsr8r propagate_cancellation_errorr. first_taskexrr9rrr:rrrr;r<s `` @@@@@@@@@rrr sQh  ,6**,Dh'MMLJEM)"66p$( Kkkm %%l;&EF *%$$Y/'+$#113  *&&& $   ( 3. .lJ6 46J'!00 */1,)DDKK)* * 46JsaAD8A2D0C.C,C.D0 D0(D8,C..D-"D(#D0(D--D00D55D8) __doc____all__rrrrrrrrrrLs(L *37aKr__pycache__/windows_utils.cpython-312.opt-2.pyc000064400000015152152343231170015336 0ustar00 ֦i ddlZejdk7redddlZddlZddlZddlZddlZddlZddl Z dZ dZ ejZ ejZ ejZdde dd ZGd d ZGd d ej$Zy)Nwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec  tjdjtjt t }|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"} tj$||dtj"tj&|tj"} tj(| d} | j+d| | fS#| tj,| | tj,| xYw)Nz\\.\pipe\python-pipe-{:d}-{:d}-)prefixrTr )tempfilemktempformatosgetpidnext _mmap_counter_winapiPIPE_ACCESS_DUPLEX GENERIC_READ GENERIC_WRITEPIPE_ACCESS_INBOUNDFILE_FLAG_FIRST_PIPE_INSTANCEFILE_FLAG_OVERLAPPEDCreateNamedPipe PIPE_WAITNMPWAIT_WAIT_FOREVERNULL CreateFile OPEN_EXISTINGConnectNamedPipeGetOverlappedResult CloseHandle) rr r addressopenmodeaccessobsizeibsizeflags_and_attribsh1h2ovs ./usr/lib64/python3.12/asyncio/windows_utils.pyrr sOoo188 IIKm,./G--%%(=(== '..&&G 555H!}G000!}#88NB  $ $ Xw00 vvw;;W\\K   VQ g.C.C w||- % %bT : t$2v  >    # >    # s +B6F""1GczeZdZ dZdZedZdZejddZ e jfdZ dZd Zy ) rc||_yN_handleselfhandles r/__init__zPipeHandle.__init__Vs  cx|jd|j}nd}d|jjd|dS)Nzhandle=closed< >)r4 __class____name__r5s r/__repr__zPipeHandle.__repr__YsB << #t||./FF4>>**+1VHA66r9c|jSr2r3r6s r/r7zPipeHandle.handle`s ||r9cH|j td|jS)NzI/O operation on closed pipe)r4 ValueErrorrCs r/filenozPipeHandle.filenods" << ;< <||r9)r%cP|j||jd|_yyr2r3)r6r%s r/closezPipeHandle.closeis$ << #  %DL $r9cb|j#|d|t||jyy)Nz unclosed )source)r4ResourceWarningrH)r6_warns r/__del__zPipeHandle.__del__ns- << # IdX& E JJL $r9c|Sr2rCs r/ __enter__zPipeHandle.__enter__ss r9c$|jyr2)rH)r6tvtbs r/__exit__zPipeHandle.__exit__vs  r9N)r@ __module__ __qualname__r8rApropertyr7rFrr%rHwarningswarnrMrPrUrOr9r/rrQsR7 $+#6#6 %MM r9rc"eZdZ dfd ZxZS)rc dx}x}}dx} x} } |tk(r5tdd\} } tj| tj }n|}|tk(r&td\} } tj| d}n|}|tk(r&td\} }tj|d}n|t k(r|}n|} t| |f|||d|| t| |_ | t| |_ | t| |_ |tk(rt j||tk(rt j||tk(rt j|yy#| | | fD]}|tj|xYw#|tk(rt j||tk(rt j||tk(rt j|wwxYw)N)FTT)r r)TFrr)stdinstdoutstderr)rrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr8rr]r^r_rr%rH)r6argsr]r^r_kwds stdin_rfd stdout_wfd stderr_wfdstdin_wh stdout_rh stderr_rhstdin_rh stdout_wh stderr_whhr?s r/r8zPopen.__init__s/32 2J+///9y D=!%t!L Hh--h DII T>#'=#A Iy..y!#'=#A Iy..y!rzs/ <<7 l ##  0     ! \7+b&&X0%J  0%r9__pycache__/events.cpython-312.opt-2.pyc000064400000065513152343231170013736 0ustar00 ֦ir dZddlZddlZddlZddlZddlZddlZddlZddlm Z GddZ Gdde Z Gd d Z Gd d Z Gd dZGddeZdaej"ZGddej&ZeZdZdZdZdZdZdZdZdZdZdZdZ eZ!eZ"eZ#eZ$ ddl%mZmZmZmZeZ&eZ'eZ(eZ)e+edrd Z,ejZe,!yy#e*$rY(wxYw)")AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpersc>eZdZ dZd dZdZdZdZdZdZ d Z y) r) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNc"|tj}||_||_||_||_d|_d|_|jjr.tjtjd|_ yd|_ y)NFr) contextvars copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontexts '/usr/lib64/python3.12/asyncio/events.py__init__zHandle.__init__$sx ?!..0G  !  ::   !%3%A%A a &"D "&*D "ch|jjg}|jr|jd|j9|jt j |j|j|jr,|jd}|jd|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r$infoframes r) _repr_infozHandle._repr_info3s''( ?? KK $ >> % KK>> , -  ! !**2.E KK+eAhZqq ; < r+c|j |jS|j}djdj|S)Nz<{}> )rr6formatjoin)r$r4s r)__repr__zHandle.__repr__?s9 :: !::  }}SXXd^,,r+c|jSN)rr$s r) get_contextzHandle.get_contextEs }}r+c|js@d|_|jjrt||_d|_d|_yy)NT)rrr reprrrrr>s r)cancelz Handle.cancelHs@"DOzz##%"$Z !DNDJr+c|jSr=)rr>s r)r-zHandle.cancelledSs r+c |jj|jg|jd}y#tt f$rt $rw}tj|j|j}d|}|||d}|jr|j|d<|jj|Yd}~d}yd}~wwxYw)NzException in callback )message exceptionhandlesource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr3rrcall_exception_handler)r$exccbmsgr(s r)_runz Handle._runVs 7 DMM  dnn :tzz :-.   777 ,B*2$/C G %%.2.D.D*+ JJ - -g 6 6 7s16CA+CCr=) r1 __module__ __qualname__ __slots__r*r6r;r?rBr-rQr+r)rrs/;I * -  r+rcheZdZ ddgZd fd ZfdZdZdZdZdZ d Z d Z fd Z d Z xZS)r _scheduled_whencxt||||||jr |jd=||_d|_y)Nr.F)superr*rrXrW)r$whenr%r&r'r(r0s r)r*zTimerHandle.__init__os; 4w7  ! !&&r* r+ct|}|jrdnd}|j|d|j|S)Nrzwhen=)rZr6rinsertrX)r$r4posr0s r)r6zTimerHandle._repr_infovs;w!#??a C5 -. r+c,t|jSr=)hashrXr>s r)__hash__zTimerHandle.__hash__|sDJJr+c`t|tr|j|jkStSr= isinstancerrXNotImplementedr$others r)__lt__zTimerHandle.__lt__% e[ ):: + +r+ct|tr,|j|jkxs|j|StSr=rerrX__eq__rfrgs r)__le__zTimerHandle.__le__3 e[ ):: +At{{5/A Ar+c`t|tr|j|jkDStSr=rdrgs r)__gt__zTimerHandle.__gt__rjr+ct|tr,|j|jkDxs|j|StSr=rlrgs r)__ge__zTimerHandle.__ge__ror+ct|trj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(St Sr=)rerrXrrrrfrgs r)rmzTimerHandle.__eq__sl e[ )JJ%++-8NNeoo58JJ%++-8OOu'7'77 9r+cp|js|jj|t|yr=)rr_timer_handle_cancelledrZrB)r$r0s r)rBzTimerHandle.cancels& JJ . .t 4 r+c |jSr=)rXr>s r)r[zTimerHandle.whens zzr+r=)r1rRrSrTr*r6rbrirnrqrsrmrBr[ __classcell__)r0s@r)rrjsBAw'I        r+rc>eZdZ dZdZdZdZdZdZdZ dZ y ) rc tr=NotImplementedErrorr>s r)closezAbstractServer.closes C!!r+c tr=r{r>s r)get_loopzAbstractServer.get_loops B!!r+c tr=r{r>s r) is_servingzAbstractServer.is_serving A!!r+cK twr=r{r>s r) start_servingzAbstractServer.start_servings "! cK twr=r{r>s r) serve_foreverzAbstractServer.serve_forevers "!rcK twr=r{r>s r) wait_closedzAbstractServer.wait_closeds8!!rcK|Swr=rUr>s r) __aenter__zAbstractServer.__aenter__s  sc`K|j|jd{y7wr=)r}r)r$rNs r) __aexit__zAbstractServer.__aexit__s!    s $.,.N) r1rRrSr}rrrrrrrrUr+r)rrs-6""""""!r+rc eZdZ dZdZdZdZdZdZdZ dZ d Z d d d Z d d d Z d d dZdZdZd d ddZd d dZdZdZddddddZdIdZ dJd dddd d d d d d d d dZ dJej2ej4d dd d d d d dd dZdKdd d!Zd"d d d d#d$Z dLd d d d d d%d&Z dLd dd d d dd'd(Zd d d d)d*Z dJdddd d d d d+d,Z!d-Z"d.Z#e$jJe$jJe$jJd/d0Z&e$jJe$jJe$jJd/d1Z'd2Z(d3Z)d4Z*d5Z+d6Z,d7Z-d8Z.dId9Z/d:Z0d;Z1d<Z2d=Z3dKd d d>Z4d?Z5d@Z6dAZ7dBZ8dCZ9dDZ:dEZ;dFZy )Mrc tr=r{r>s r) run_foreverzAbstractEventLoop.run_forever 8!!r+c tr=r{)r$futures r)run_until_completez$AbstractEventLoop.run_until_completes "!r+c tr=r{r>s r)stopzAbstractEventLoop.stops "!r+c tr=r{r>s r) is_runningzAbstractEventLoop.is_runningrr+c tr=r{r>s r) is_closedzAbstractEventLoop.is_closedrr+c tr=r{r>s r)r}zAbstractEventLoop.closes "!r+cK twr=r{r>s r)shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgenss:!!rcK twr=r{r>s r)shutdown_default_executorz+AbstractEventLoop.shutdown_default_executors<!!rc tr=r{)r$rGs r)rvz)AbstractEventLoop._timer_handle_cancelledrr+N)r(c0|jd|g|d|iS)Nrr() call_laterr$r%r(r&s r) call_soonzAbstractEventLoop.call_soon stq(CTC7CCr+ctr=r{)r$delayr%r(r&s r)rzAbstractEventLoop.call_later!!r+ctr=r{)r$r[r%r(r&s r)call_atzAbstractEventLoop.call_atrr+ctr=r{r>s r)timezAbstractEventLoop.timerr+ctr=r{r>s r) create_futurezAbstractEventLoop.create_futurerr+)namer(ctr=r{)r$cororr(s r) create_taskzAbstractEventLoop.create_taskrr+ctr=r{rs r)call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"rr+ctr=r{)r$executorfuncr&s r)run_in_executorz!AbstractEventLoop.run_in_executor%rr+ctr=r{)r$rs r)set_default_executorz&AbstractEventLoop.set_default_executor(rr+r)familytypeprotoflagscKtwr=r{)r$hostportrrrrs r) getaddrinfozAbstractEventLoop.getaddrinfo- !! cKtwr=r{)r$sockaddrrs r) getnameinfozAbstractEventLoop.getnameinfo1 !!r) sslrrrsock local_addrserver_hostnamessl_handshake_timeoutssl_shutdown_timeouthappy_eyeballs_delay interleavec Ktwr=r{)r$protocol_factoryrrrrrrrrrrrrrs r)create_connectionz#AbstractEventLoop.create_connection4s"!rdT) rrrbacklogr reuse_address reuse_portrrrc K twr=r{)r$rrrrrrrrrrrrrs r) create_serverzAbstractEventLoop.create_server>s/ `"!r)fallbackcK twr=r{)r$ transportfileoffsetcountrs r)sendfilezAbstractEventLoop.sendfilexs "!rF) server_siderrrcK twr=r{)r$rprotocol sslcontextrrrrs r) start_tlszAbstractEventLoop.start_tlss  "!r)rrrrrcKtwr=r{)r$rpathrrrrrs r)create_unix_connectionz(AbstractEventLoop.create_unix_connections "!r)rrrrrrcK twr=r{) r$rrrrrrrrs r)create_unix_serverz$AbstractEventLoop.create_unix_servers  8"!r)rrrcK twr=r{)r$rrrrrs r)connect_accepted_socketz)AbstractEventLoop.connect_accepted_sockets  "!r)rrrrrallow_broadcastrcK twr=r{) r$rr remote_addrrrrrrrrs r)create_datagram_endpointz*AbstractEventLoop.create_datagram_endpoints  8"!rcK twr=r{r$rpipes r)connect_read_pipez#AbstractEventLoop.connect_read_pipes $"!rcK twr=r{rs r)connect_write_pipez$AbstractEventLoop.connect_write_pipes %"!r)stdinstdoutstderrcKtwr=r{)r$rcmdrrrkwargss r)subprocess_shellz"AbstractEventLoop.subprocess_shell "!rcKtwr=r{)r$rrrrr&rs r)subprocess_execz!AbstractEventLoop.subprocess_exec rrctr=r{r$fdr%r&s r) add_readerzAbstractEventLoop.add_readerrr+ctr=r{r$rs r) remove_readerzAbstractEventLoop.remove_readerrr+ctr=r{rs r) add_writerzAbstractEventLoop.add_writerrr+ctr=r{rs r) remove_writerzAbstractEventLoop.remove_writer"rr+cKtwr=r{)r$rnbytess r) sock_recvzAbstractEventLoop.sock_recv'rrcKtwr=r{)r$rbufs r)sock_recv_intoz AbstractEventLoop.sock_recv_into*rrcKtwr=r{)r$rbufsizes r) sock_recvfromzAbstractEventLoop.sock_recvfrom-rrcKtwr=r{)r$rrr s r)sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0rrcKtwr=r{)r$rdatas r) sock_sendallzAbstractEventLoop.sock_sendall3rrcKtwr=r{)r$rraddresss r) sock_sendtozAbstractEventLoop.sock_sendto6rrcKtwr=r{)r$rrs r) sock_connectzAbstractEventLoop.sock_connect9rrcKtwr=r{)r$rs r) sock_acceptzAbstractEventLoop.sock_accept<rrcKtwr=r{)r$rrrrrs r) sock_sendfilezAbstractEventLoop.sock_sendfile?rrctr=r{)r$sigr%r&s r)add_signal_handlerz$AbstractEventLoop.add_signal_handlerErr+ctr=r{)r$r#s r)remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHrr+ctr=r{)r$factorys r)set_task_factoryz"AbstractEventLoop.set_task_factoryMrr+ctr=r{r>s r)get_task_factoryz"AbstractEventLoop.get_task_factoryPrr+ctr=r{r>s r)get_exception_handlerz'AbstractEventLoop.get_exception_handlerUrr+ctr=r{)r$handlers r)set_exception_handlerz'AbstractEventLoop.set_exception_handlerXrr+ctr=r{r$r(s r)default_exception_handlerz+AbstractEventLoop.default_exception_handler[rr+ctr=r{r2s r)rMz(AbstractEventLoop.call_exception_handler^rr+ctr=r{r>s r)r zAbstractEventLoop.get_debugcrr+ctr=r{)r$enableds r) set_debugzAbstractEventLoop.set_debugfrr+)rNN)rNr=)?r1rRrSrrrrrr}rrrvrrrrrrrrrrrrsocket AF_UNSPEC AI_PASSIVErrrrrrrrr subprocessPIPErrrrrr r rrrrrrrr!r$r&r)r+r-r0r3rMr r8rUr+r)rrs?""""" """ "26D:>"6:""" )-d" =A""" "#!1""59"$4 "&!%!%$"598"&&##$DT"&!%8"t"#'"%*(,.2-1 "*."4 "&!% "*.""s"&!% ""L"&!% " EI!"./q59d7;$ !"J " "&0__&0oo&0oo"%/OO%/__%/__""""" """""""""(," "" "" """" ""r+rc,eZdZ dZdZdZdZdZy)rc tr=r{r>s r)r z&AbstractEventLoopPolicy.get_event_loopms ("!r+c tr=r{r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwrr+c tr=r{r>s r)r z&AbstractEventLoopPolicy.new_event_loop{s J"!r+c tr=r{r>s r)r z)AbstractEventLoopPolicy.get_child_watchers .!!r+c tr=r{)r$watchers r)r z)AbstractEventLoopPolicy.set_child_watchers 2!!r+N)r1rRrSr r r r r rUr+r)rrjs7"""""r+rcTeZdZ dZGddej ZdZdZdZ dZ y)BaseDefaultEventLoopPolicyNceZdZdZdZy)!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr _set_calledrUr+r)_LocalrJs  r+rLc.|j|_yr=)rL_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__skkm r+c |jj|jjstjtj urd} t jd}|rG|jjd}|dk(s|jdsn|j}|dz }|rF ddl }|jdt||j!|j#|jj*t%d tjj&z|jjS#t$rYwxYw) Nr]rr1asynciozasyncio.rzThere is no current event loop) stacklevelz,There is no current event loop in thread %r.)rNrrK threadingcurrent_thread main_threadr"r# f_globalsget startswithf_backAttributeErrorwarningswarnDeprecationWarningr r RuntimeErrorr)r$rQfmodulerZs r)r z)BaseDefaultEventLoopPolicy.get_event_loops4  KK   %KK++((*i.C.C.EEJ $MM!$ [[__Z8F"i/63D3DZ3PA!OJ   MM:,  E    3 3 5 6 ;;   $M!*!9!9!;!@!@ AB B{{   )"  sE EEc d|j_|2t|ts"t dt |j d||j_y)NTzs r)r z)BaseDefaultEventLoopPolicy.new_event_loops !!##r+) r1rRrSrdrRlocalrLr*r r r rUr+r)rHrHs3 M$!B!$r+rHceZdZdZy) _RunningLoopr9N)r1rRrSloop_pidrUr+r)rgrgsHr+rgc6 t}| td|S)Nzno running event loop)rr]r's r)rrs'  D |233 Kr+cd tj\}}||tjk(r|Syyr=) _running_looprhosgetpid) running_looppids r)rrs: &..L#C299;$6%7r+cD |tjft_yr=)rmrnrlrhrjs r)rrs #BIIK0Mr+c`t5t ddlm}|adddy#1swYyxYw)NrDefaultEventLoopPolicy)_lock_event_loop_policyrtrss r)_init_event_loop_policyrxs!   % 0!7!9  s$-c0 t ttSr=)rvrxrUr+r)rrs,!! r+cr |2t|ts"tdt|jd|ay)NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'ra)rerrbrr1rv)policys r)rrsC:*V5L"M^_cdj_k_t_t^uuvwxxr+cP t}||StjSr=)rrr ) current_loops r)r r s/%&L " 1 1 33r+c8 tj|yr=)rr rjs r)r r 0sM**40r+c4 tjSr=)rr rUr+r)r r 5sI " 1 1 33r+c4 tjSr=)rr rUr+r)r r :sL " 4 4 66r+c6 tj|Sr=)rr )rFs r)r r ?s; " 4 4W ==r+)rrrr forkcttjt_t dt j dy)Nr.)rvrHrLrNrsignal set_wakeup_fdrUr+r)on_forkr]s0  )(B(I(I(K  %$R r+)after_in_child).__all__rrmrr:r=r"rRrwrrrrrrrHrvLockrurergrlrrrrxrrr r r r r _py__get_running_loop_py__set_running_loop_py_get_running_loop_py_get_event_loop_asyncio_c__get_running_loop_c__set_running_loop_c_get_running_loop_c_get_event_loop ImportErrorhasattrrregister_at_forkrUr+r)rs]'   JJZ<&<~'!'!TT"T"n ""DD$!8D$V  9??   1:  4 1 4 7 >*)'# '<< -,*& 2v!Bw/  s= C22C:9C:__pycache__/transports.cpython-312.opt-1.pyc000064400000033242152343231170014642 0ustar00 ֦i)dZdZGddZGddeZGddeZGdd eeZGd d eZGd d eZGddeZy)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc<eZdZdZdZd dZd dZdZdZdZ d Z y) rzBase class for transports._extraNc|i}||_yNr )selfextras +/usr/lib64/python3.12/asyncio/transports.py__init__zBaseTransport.__init__s =E c:|jj||S)z#Get optional transport information.)r get)r namedefaults rget_extra_infozBaseTransport.get_extra_infos{{tW--rct)z2Return True if the transport is closing or closed.NotImplementedErrorr s r is_closingzBaseTransport.is_closing!!rct)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. rrs rclosezBaseTransport.close "!rct)zSet a new protocol.r)r protocols r set_protocolzBaseTransport.set_protocol%rrct)zReturn the current protocol.rrs r get_protocolzBaseTransport.get_protocol)rrr ) __name__ __module__ __qualname____doc__ __slots__rrrrr"r$rrrr s($I .""""rrc&eZdZdZdZdZdZdZy)rz#Interface for read-only transports.r*ct)z*Return True if the transport is receiving.rrs r is_readingzReadTransport.is_reading3rrct)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. rrs r pause_readingzReadTransport.pause_reading7 "!rct)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. rrs rresume_readingzReadTransport.resume_reading?r0rN)r%r&r'r(r)r-r/r2r*rrrr.s-I"""rrcFeZdZdZdZd dZdZdZdZdZ d Z d Z d Z y) rz$Interface for write-only transports.r*Nct)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. rr highlows rset_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs &"!rct)z,Return the current size of the write buffer.rrs rget_write_buffer_sizez$WriteTransport.get_write_buffer_sizebrrct)zGet the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.rrs rget_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs "!rct)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. r)r datas rwritezWriteTransport.writelr0rcHdj|}|j|y)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. rN)joinr?)r list_of_datar>s r writelineszWriteTransport.writelinests xx % 4rct)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. rrs r write_eofzWriteTransport.write_eof} "!rct)zAReturn True if this transport supports write_eof(), False if not.rrs r can_write_eofzWriteTransport.can_write_eofrrctzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. rrs rabortzWriteTransport.abortrFrNN) r%r&r'r(r)r8r:r<r?rCrErHrKr*rrrrHs2.I"*"" """"rrceZdZdZdZy)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r*N)r%r&r'r(r)r*rrrrs(Irrc"eZdZdZdZddZdZy)rz(Interface for datagram (UDP) transports.r*Nct)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. r)r r>addrs rsendtozDatagramTransport.sendtorrctrJrrs rrKzDatagramTransport.abortrFrr )r%r&r'r(r)rQrKr*rrrrs2I""rrc4eZdZdZdZdZdZdZdZdZ y) rr*ct)zGet subprocess id.rrs rget_pidzSubprocessTransport.get_pidrrct)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode rrs rget_returncodez"SubprocessTransport.get_returncoder0rct)z&Get transport for pipe with number fd.r)r fds rget_pipe_transportz&SubprocessTransport.get_pipe_transportrrct)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal r)r signals r send_signalzSubprocessTransport.send_signalr0rct)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate rrs r terminatezSubprocessTransport.terminates "!rct)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill rrs rkillzSubprocessTransport.kills "!rN) r%r&r'r)rUrWrZr]r_rar*rrrrs%I"""" " "rrcPeZdZdZdZd fd ZdZdZdZd dZ d dZ d Z xZ S) _FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_waterc`t||||_d|_|j y)NF)superrrdre_set_write_buffer_limits)r rloop __class__s rrz_FlowControlMixin.__init__s+  % %%'rc@|j}||jkry|js#d|_ |jj yy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exception transportr!) r:rfre _protocol pause_writing SystemExitKeyboardInterrupt BaseExceptionrdcall_exception_handler)r sizeexcs r_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols))+ 4## # $$$(D ! ,,.% 12    11@!$!% $ 3 sAB)*BBc<|jrA|j|jkr#d|_ |jj yyy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NFz protocol.resume_writing() failedrn) rer:rgrrresume_writingrtrurvrdrw)r rys r_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's  ! !**,?$)D ! --/@ "  12    11A!$!% $ 3 sAB'*BBc2|j|jfSr )rgrfrs rr<z)_FlowControlMixin.get_write_buffer_limits7s!1!122rc| |d}nd|z}||dz}||cxk\rdk\sntd|d|d||_||_y)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorrfrgr5s rrjz*_FlowControlMixin._set_write_buffer_limits:sh <{ 3w ;!)Csa 23'HJ J rcJ|j|||jy)N)r6r7)rjrzr5s rr8z)_FlowControlMixin.set_write_buffer_limitsJs! %%4S%9 ""$rctr rrs rr:z'_FlowControlMixin.get_write_buffer_sizeNs!!rrL) r%r&r'r(r)rrzr}r<rjr8r: __classcell__)rls@rrcrcs3 KI($ 3 %"rrcN) r(__all__rrrrrrrcr*rrrsj  """"J"M"4I"]I"X ~0" "23"-3"lT" T"r__pycache__/trsock.cpython-312.opt-1.pyc000064400000011731152343231170013727 0ustar00 ֦i  ddlZGddZy)NceZdZdZdZdej fdZedZedZ edZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZy)TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _socksockc||_yNr)selfrs '/usr/lib64/python3.12/asyncio/trsock.py__init__zTransportSocket.__init__s  c.|jjSr )rfamilyr s r rzTransportSocket.familyszz   r c.|jjSr )rtypers r rzTransportSocket.typeszzr c.|jjSr )rprotors r rzTransportSocket.protoszzr crd|jd|jd|jd|j}|jdk7r4 |j }|r|d|} |j}|r|d|}|dS#t j $rY4wxYw#t j $rY3wxYw) Nz)filenorrr getsocknamesocketerror getpeername)r sladdrraddrs r __repr__zTransportSocket.__repr__s*4;;=/:kk_GDII=9ZZL " ;;=B  ((*#XeW-A ((*#XeW-AAw<<   <<  s$B)B BB B65B6ctd)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrs r __getstate__zTransportSocket.__getstate__5sIJJr c6|jjSr )rrrs r rzTransportSocket.fileno8szz  ""r c6|jjSr )rduprs r r&zTransportSocket.dup;szz~~r c6|jjSr )rget_inheritablers r r(zTransportSocket.get_inheritable>szz))++r c:|jj|yr )rshutdown)r hows r r*zTransportSocket.shutdownAs C r c:|jj|i|Sr )r getsockoptr argskwargss r r-zTransportSocket.getsockoptFs$tzz$$d5f55r c<|jj|i|yr )r setsockoptr.s r r2zTransportSocket.setsockoptIs t.v.r c6|jjSr )rrrs r rzTransportSocket.getpeernameLzz%%''r c6|jjSr )rrrs r rzTransportSocket.getsocknameOr4r c6|jjSr )r getsockbynamers r r7zTransportSocket.getsockbynameRszz''))r c$|dk(rytd)Nrzr r rrsIV]]!!  .K# ,! 6/((*L Cr r)rrr>r r rIs ^C^Cr __pycache__/proactor_events.cpython-312.pyc000064400000127314152343231170014705 0ustar00 ֦i܂dZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZdZGddej*ej,ZGddeej0ZGddeej4ZGddeZGddeej:ZGddeeej>Z Gddeeej>Z!Gdde jDZ#y)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggerctj||jd< |j|jd<d|jvr |j|jd<yy#tj $r5|j jrtjd|dYuwxYw#tj $rd|jd<YywxYw)Nsocketsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extra getsocknamererror_loop get_debugr warning getpeername) transportsocks 0/usr/lib64/python3.12/asyncio/proactor_events.py_set_socket_extrars!'!7!7!=IXC'+'7'7'9 $ ))) 0+/+;+;+=I  Z (* <<C ?? $ $ & NN,dT CC|| 0+/I  Z ( 0s$A/B:/AB76B7:"CCceZdZdZ dfd ZdZdZdZdZdZ dZ e jfd Z dd Zd Zd Zd ZxZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.ct||||j|||_|j |||_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ |j |j j|jj!|j"j$||,|jj!t&j(|dyy)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing_called_connection_lost _eof_written_attachr call_soon _protocolconnection_mader_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__s rr$z#_ProactorBasePipeTransport.__init__2s %   (#   ',$! << # LL " T^^;;TB   JJ !E!E!' / c|jjg}|j|jdn|jr|jd|j,|jd|jj |j |jd|j |j|jd|j|jr'|jdt|j|jr|jddjd j|S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r=__name__r&appendr.filenor*r+r)lenr0formatjoin)r7infos r__repr__z#_ProactorBasePipeTransport.__repr__Is''( ::  KK ! ]] KK " :: ! KK#djj//123 4 >> % KK%12 3 ?? & KK& 34 5 << KK.T\\):(;< =    KK &}}SXXd^,,r>c"||jd<y)Npipe)rr7rs rr%z%_ProactorBasePipeTransport._set_extra[s" Fr>c||_yNr3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s !r>c|jSrOrPr7s r get_protocolz'_ProactorBasePipeTransport.get_protocolas ~~r>c|jSrO)r.rRs r is_closingz%_ProactorBasePipeTransport.is_closingds }}r>c.|jryd|_|xjdz c_|js2|j&|jj |j d|j"|jjd|_yy)NTr) r.r-r)r+rr2_call_connection_lostr*cancelrRs rclosez _ProactorBasePipeTransport.closegsq ==   1|| 7 JJ !;!;T B >> % NN ! ! #!DN &r>cv|j-|d|t||jjyy)Nzunclosed transport )source)r&ResourceWarningrY)r7_warns r__del__z"_ProactorBasePipeTransport.__del__rs5 :: ! 'x0/$ O JJ    "r>c0 t|tr4|jjrDt j d||dn*|jj ||||jd|j|y#|j|wxYw)Nz%r: %sTr)message exceptionrr9) isinstanceOSErrorrrr debugcall_exception_handlerr3 _force_close)r7excr`s r _fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy ##w'::'')LL44H 11&!$!% $ 3   c "D  c "s A.BBcH|jS|jjs9||jjdn|jj||jr |j ryd|_|xj dz c_|jr!|jjd|_|jr!|jjd|_ d|_ d|_ |jj|j|y)NTrr) _empty_waiterdone set_result set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_closes    )$2D2D2I2I2K{""--d3""005 ==T99   1 ?? OO " " $"DO >> NN ! ! #!DN  T77=r>c|jry |jj|t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_y#t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_wxYw)NshutdownT) r/r3connection_losthasattrr&rEror SHUT_RDWRrYr(_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_losts  ' '  0 NN * *3 / tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (s CB+E?cf|j}|j|t|jz }|SrO)r,r)rF)r7sizes rget_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_sizes/"" << # C % %D r>NNN)zFatal error on pipe transport)rC __module__ __qualname____doc__r$rJr%r'rSrUrYwarningswarnr^rhrfrWrw __classcell__r=s@rr!r!.sQ448$(/.-$#" "%MM #>(0(r>r!cNeZdZdZ d fd ZdZdZdZdZdZ d dZ xZ S) _ProactorReadPipeTransportzTransport for read pipes.cd|_d|_t| ||||||t ||_|j j|jd|_y)NrpTF) _pending_data_length_pausedr#r$ bytearray_datarr2 _loop_reading) r7r8rr9r:r;r< buffer_sizer=s rr$z#_ProactorReadPipeTransport.__init__sT$&!  tXvufE{+  T//0 r>c:|j xr |j SrO)rr.rRs r is_readingz%_ProactorReadPipeTransport.is_readings<<5 $55r>c|js |jryd|_|jjrt j d|yy)NTz%r pauses reading)r.rrrr rdrRs r pause_readingz(_ProactorReadPipeTransport.pause_readings? ==DLL   ::   ! LL,d 3 "r>c|js |jsyd|_|j&|jj |j d|j }d|_|dkDr4|jj |j|jd|||jjrtjd|yy)NFrpz%r resumes reading) r.rr*rr2rr_data_receivedrrr rd)r7lengths rresume_readingz)_ProactorReadPipeTransport.resume_readings ==  >> ! JJ !3!3T :**$&! B; JJ !4!4djj&6I6 R ::   ! LL-t 4 "r>c.|jjrtjd| |jj }|s|jyy#t tf$rt$r}|j|dYd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rdr3 eof_received SystemExitKeyboardInterrupt BaseExceptionrhrY)r7 keep_openrgs r _eof_receivedz(_ProactorReadPipeTransport._eof_receiveds ::   ! LL*D 1 335I JJL-.      H J  sA B8BBc|jr|jdk(sJ||_y|dk(r|jyt|jt j r" t j|j|y|jj|y#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nrprz3Fatal error: protocol.buffer_updated() call failed.) rrrrbr3r BufferedProtocol_feed_data_to_buffered_protorrrrh data_received)r7datarrgs rrz)_ProactorReadPipeTransport._data_receiveds <<,,2 22(.D %  Q;     dnni&@&@ A 66t~~tL NN ( ( . 12   !!##12  s! BC6C  Ccd}d} ||j|us|j |jsJd|_|jrQ|j}|dk(r |dkDr|j ||yyt t |jd|}n|j|jr |dkDr|j ||yy|js?|jjj|j|j|_|js&|jj|j |dkDr|j ||yy#t $rZ}|js|j#|dn1|jj%rt'j(ddYd}~wd}~wt*$r}|j-|Yd}~d}~wt.$r}|j#|dYd}~d}~wt0j2$r|jsYwxYw#|dkDr|j ||wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*r.rkresultrbytes memoryviewrrXrr _proactor recv_intor&add_done_callbackrConnectionAbortedErrorrhrr rdConnectionResetErrorrfrcrCancelledError)r7futrrrgs rrz(_ProactorReadPipeTransport._loop_readings. 2~~,1G15@@!%88: ZZ\F{F{##D&1A!DJJ!7!@ADJJL}}2{##D&1)<E$A E$2H0$ H--AG=H0 H-G$H0$ H-0HH0#H-*H0,H--H00I )NNNirO) rCryrzr{r$rrrrrrr~rs@rrrs/#486;64&5$ /212r>rcReZdZdZdZfdZdZd dZdZdZ dZ d Z d Z xZ S) _ProactorBaseWritePipeTransportzTransport for write pipes.Tc2t||i|d|_yrO)r#r$rjr7argskwr=s rr$z(_ProactorBaseWritePipeTransport.__init__Ns $%"%!r>ct|tttfs!t dt |j |jr td|j td|sy|jrH|jtjk\rtjd|xjdz c_ y|j*|j J|j#t|y|j s!t||_|j%y|j j'||j%y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r)rbrrr TypeErrortyperCr0 RuntimeErrorrjr-r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+r) _loop_writing_maybe_pause_protocolextend)r7rs rwritez%_ProactorBaseWritePipeTransport.writeRs$ : >?Dz**+-. .   ;< <    )IJ J  ??)"M"MM@A OOq O  ?? "<<' ''   E$K  0$T?DL  & & ( LL   %  & & (r>cN ||j |jry||jusJd|_d|_|r|j||j}d|_|sx|jr&|j j |jd|jr)|jjtj|jn|j jj|j||_|jj!sW|jdk(sJt#||_|jj%|j&|j)n%|jj%|j&|j*)|j|j*j-dyyy#t.$r}|j1|Yd}~yd}~wt2$r}|j5|dYd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,rr)rr2rWr0r&rorSHUT_WR_maybe_resume_protocolrsendrkrFrrrrjrlrrfrcrh)r7frrgs rrz-_ProactorBaseWritePipeTransport._loop_writingxs& J}!8T]]' ''"DO"#D  |||# ==JJ(()C)CTJ$$JJ''7 ++-"&**"6"6";";DJJ"M++-..!333*-d)D'OO55d6H6HI..0OO55d6H6HI!!-$//2I""--d33J-# #   c " " J   c#H I I Js)GF=G H$&G<< H$HH$cyNTrRs r can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eofr>c$|jyrO)rYrRs r write_eofz)_ProactorBaseWritePipeTransport.write_eofs  r>c&|jdyrOrfrRs rabortz%_ProactorBaseWritePipeTransport.abort $r>c|j td|jj|_|j|jj d|jS)NzEmpty waiter is already set)rjrr create_futurer+rlrRs r_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waitersY    )<= =!ZZ557 ?? "    ) )$ /!!!r>cd|_yrO)rjrRs r_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiters !r>NN)rCryrzr{_start_tls_compatibler$rrrrrrrr~rs@rrrHs7$ "$)L'JR ""r>rc$eZdZfdZdZxZS)_ProactorWritePipeTransportct||i||jjj |j d|_|j j|jy)N) r#r$rrrecvr&r*r _pipe_closedrs rr$z$_ProactorWritePipeTransport.__init__sO $%"%--224::rB (():):;r>cB|jry|jdk(sJ|jr|jJy||jusJ||jfd|_|j|j t y|jy)Nr>) cancelledrr.r*r+rfBrokenPipeErrorrY)r7rs rrz(_ProactorWritePipeTransport._pipe_closeds ==? zz|s""" ==>>) )) dnn$;sDNN&;;$ ?? &   o/ 0 JJLr>)rCryrzr$rr~rs@rrrs < r>rcReZdZdZ d fd ZdZdZdZd dZd dZ d dZ xZ S) _ProactorDatagramTransportic||_d|_d|_t||||||t j |_|jj|jy)Nr)r:r;) _addressrj _buffer_sizer#r$ collectionsdequer)rr2r)r7r8rr9addressr:r;r=s rr$z#_ProactorDatagramTransport.__init__s^ ! tXfEJ#((*  T//0r>ct||yrOrrMs rr%z%_ProactorDatagramTransport._set_extra $%r>c|jSrO)rrRs rrwz0_ProactorDatagramTransport.get_write_buffer_sizes   r>c&|jdyrOrrRs rrz _ProactorDatagramTransport.abortrr>crt|tttfst dt ||sy|j (|d|j fvrtd|j |jrT|j rH|jtjk\rtjd|xjdz c_y|jjt||f|xjt!|z c_|j"|j%|j'y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbrrrrrr ValueErrorr-rrr rr)rDrrFr+rr)r7raddrs rsendtoz!_ProactorDatagramTransport.sendtos$ : >?J J( (  == $dDMM5J)J3DMM?CE E ??t}})"M"MMBC OOq O  U4[$/0 SY& ?? "     ""$r>c |jry||jusJd|_|r|j|jr|jr?|jr3|j r&|j j|jdy|jj\}}|xjt|zc_ |j6|j jj|j||_n7|j jj|j|||_|jj!|j"|j%y#t&$r%}|j(j+|Yd}~yd}~wt,$r}|j/|dYd}~yd}~wwxYw)N)rz'Fatal write error on datagram transport)r-r+rr)rr.rr2rWpopleftrrFrrr&rrrrrcr3error_received Exceptionrh)r7rrrrgs rrz(_ProactorDatagramTransport._loop_writingsd *$//) ))"DO <>S(T^^-C-1]] <<"DNjjl==D000t<-==,!$dmm$D!$JD$ 00t<}}(!%!5!5!:!:4::;?=="J"&!5!5!>!>tzz?C}}"N~~)001C1CD00t< / NN ) )# . .(( ==! 00t<sN G AG !,G .B G 92H HG4/H4#HHHH!H>rxrO) rCryrzrr$r%rwrrrrr~rs@rrrs2H59$( 1&! %: *D)=r>rceZdZdZdZdZy)_ProactorDuplexPipeTransportzTransport for duplex pipes.cy)NFrrRs rrz*_ProactorDuplexPipeTransport.can_write_eofUsr>ctrO)NotImplementedErrorrRs rrz&_ProactorDuplexPipeTransport.write_eofXs!!r>N)rCryrzr{rrrr>rrrPs&"r>rcfeZdZdZej j Z dfd ZdZ dZ dZ xZ S)_ProactorSocketTransportz Transport for connected sockets.cXt|||||||tj|yrO)r#r$r _set_nodelayr6s rr$z!_ProactorSocketTransport.__init__cs( tXvufE  &r>ct||yrOrrMs rr%z#_ProactorSocketTransport._set_extrahrr>cyrrrRs rrz&_ProactorSocketTransport.can_write_eofkrr>c|js |jryd|_|j*|jj t j yyr)r.r0r+r&rorrrRs rrz"_ProactorSocketTransport.write_eofnsA ==D--   ?? " JJ   / #r>rx) rCryrzr{r _SendfileMode TRY_NATIVE_sendfile_compatibler$r%rrr~rs@rrr\s4+$22==48$(' &0r>rceZdZfdZ ddZ dddddddddZ ddZ d dZ d d Z d d Z fd Z d Z d Z dZ d!dZdZdZdZdZdZdZdZdZddZdZ d"dZdZdZdZxZS)#rct|tjd|jj ||_||_d|_i|_ |j||jtjtjur.tj |j"j%yy)NzUsing proactor: %s)r#r$r rdr=rCr _selector_self_reading_future_accept_futuresset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockrE)r7proactorr=s rr$zBaseProactorEventLoop.__init__xs  )8+=+=+F+FG!!$(!!$   # # %)>)>)@ @  !3!3!5 6 Ar>Nc"t||||||SrO)r)r7rr9r:r;r<s r_make_socket_transportz,BaseProactorEventLoop._make_socket_transports'dHf(-v7 7r>F) server_sideserver_hostnamer;r<ssl_handshake_timeoutssl_shutdown_timeoutc ttj||||||| | } t||| ||| jS)N)rrr;r<)r SSLProtocolr_app_transport) r7rawsockr9 sslcontextr:rrr;r<rr ssl_protocols r_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transportsI  ++h F_&;%9 ; !w ',V =***r>c"t||||||SrO)r)r7rr9rr:r;s r_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transports)$h*0%9 9r>c t|||||SrO)rr7rr9r:r;s r_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transports+D,0(FEK Kr>c t|||||SrO)rrs r_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transports)$hNNr>c t|||||SrO)rrs r_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transports+4+/65J Jr>c|jr td|jrytjtj urt jd|j|j|jjd|_ d|_ t|-y)Nz!Cannot close a running event looprp) is_runningr is_closedrrr r r _stop_accept_futures_close_self_piperrYrr#)r7r=s rrYzBaseProactorEventLoop.closes ?? BC C >>    # # %)>)>)@ @   $ !!#    r>cVK|jj||d{S7wrO)rr)r7rns r sock_recvzBaseProactorEventLoop.sock_recvs#^^((q1111 )')cVK|jj||d{S7wrO)rr)r7rbufs rsock_recv_intoz$BaseProactorEventLoop.sock_recv_intos#^^--dC8888r-cVK|jj||d{S7wrO)rr)r7rbufsizes r sock_recvfromz#BaseProactorEventLoop.sock_recvfroms#^^,,T7;;;;r-crK|s t|}|jj|||d{S7wrO)rFr recvfrom_into)r7rr/nbytess rsock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_intos1XF^^11$VDDDDs .757cVK|jj||d{S7wrO)rr)r7rrs r sock_sendallz"BaseProactorEventLoop.sock_sendalls#^^((t4444r-cZK|jj||d|d{S7w)Nr)rr)r7rrrs r sock_sendtoz!BaseProactorEventLoop.sock_sendtos'^^**4q'BBBBs "+)+cK|jr|jdk7r td|jj ||d{S7w)Nrzthe socket must be non-blocking)_debug gettimeoutrrconnect)r7rrs r sock_connectz"BaseProactorEventLoop.sock_connectsD ;;4??,1>? ?^^++D'::::sA A A AcTK|jj|d{S7wrO)racceptrMs r sock_acceptz!BaseProactorEventLoop.sock_accepts!^^**40000s (&(cK |j} t j|j}|r|n|}|syt|d}|rt||z|n|} t||}d} t| |z |}|dkr| | dkDr|j|SS|jj||||d{||z }| |z } ^#ttjf$r}t j dd}~wwxYw#t$rt j dwxYw7g#| dkDr|j|wwxYww)Nznot a regular filerl)rEAttributeErrorioUnsupportedOperationrSendfileNotAvailableErrorosfstatst_sizercminseekrsendfile) r7rfileoffsetcountrEerrfsize blocksizeend_pos total_sents r_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_natives_ M[[]F MHHV$,,E#E  ;/ 05#fune,5VU#  "& 0)< >% A~ &! nn--dD&)LLL)#i'  7 78 M667KL L M M667KL L MMA~ &!shEC D6E+D$E!D$:D";D$ C=#C88C==EDE"D$$D==EcjK|j}|j|jd{ |j|j|||dd{|j |r|j SS7P7)#|j |r|j wwxYww)NF)fallback)rrr sock_sendfiler&rr)r7transprOrPrQrs r_sendfile_nativez&BaseProactorEventLoop._sendfile_natives**,''))) (++FLL$5:,<<  & & (%%' *<  & & (%%'s84B3BB3#B B  B #%B3 B %B00B3c |j!|jjd|_|jjd|_|jjd|_|xj dzc_y)Nr)rrX_ssockrYr  _internal_fdsrRs rr)z&BaseProactorEventLoop._close_self_pipesg  $ $ 0  % % , , .(,D %     ar>ctj\|_|_|jj d|jj d|xj dz c_y)NFr)r socketpairr^r  setblockingr_rRs rrz%BaseProactorEventLoop._make_self_pipesN#)#4#4#6  T[ & & ar>ct ||j|j|ury|jj|jd}||_|j |j y#tj$rYyttf$rt$r}|jd||dYd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) rrrrr^r_loop_self_readingrrrrrre)r7rrgs rrdz(BaseProactorEventLoop._loop_self_readings 9} ((1##DKK6A)*D %   7 7 8((  -.     ' 'K )   s" A,&A,,B7B7B22B7c|j}|y |jdy#t$r(|jrt j ddYyYywxYw)Nz3Fail to write a null byte into the self-pipe socketTr)r rrcr=r rd)r7csocks r_write_to_selfz$BaseProactorEventLoop._write_to_self4sU   =  , JJu  ,{{ 0&*, ,s#,AAc Pdfd jy)Nc  |s|j\}}jrtjd||} j || dd|i nj ||d|ij ryjj }|j j<|jy#t$r} jdk7r9jd|tj d j!n.jrtjd d Yd}~yYd}~yYd}~yd}~wt"j$$r j!YywxYw) Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)rr=r rdrrr'rrBrrErrcrer rrYrr) rconnrr9rgr8protocol_factoryr7r<rrrrs rr8z2BaseProactorEventLoop._start_serving..loopKsw# *=!"JD${{ %J%+T49/1H!-00 (JD#-t"4V2G1E 1G 33 (#-t"4V4E>>#NN))$/78$$T[[]3##D) 6;;=B&//#>%("("8"8">1 JJL[[LL!=!%66!!,,   s%BC C FA0E&FFrO)r2) r7rlrrr<backlogrrr8s ````` ``@r_start_servingz$BaseProactorEventLoop._start_servingFs $ *$ *L tr>cyrOr)r7 event_lists r_process_eventsz%BaseProactorEventLoop._process_eventsss r>c|jjD]}|j|jjyrO)rvaluesrXclear)r7futures rr(z*BaseProactorEventLoop._stop_accept_futuresws6**113F MMO4 ""$r>c|jj|jd}|r|j|jj ||j yrO)rpoprErXr _stop_servingrY)r7rrus rrxz#BaseProactorEventLoop._stop_serving|sG%%))$++->  MMO $$T* r>rxrOr)r)NNdNN)rCryrzr$rrrr r"r$rYr,r0r3r7r9r;r@rCrWr\r)rrdrhrnrqr(rxr~rs@rrrvs 7=A267 9= + $t"&!% + CG9 BF*.K @D(,OAE)-J (29<E 5C; 1": (  98,&>A-1,0+Z % r>r)$r{__all__rFrIrr|r rrrrrrr r r r logr r_FlowControlMixin BaseTransportr! ReadTransportrWriteTransportrrDatagramTransportr Transportrr BaseEventLooprrr>rrs #  0$D!=!=!+!9!9DNP2!;!+!9!9P2fk"&@&0&?&?k"\"A,A=!;!+!=!=A=H "#=#B#-#7#7 "09>)3304KK55Kr>__pycache__/log.cpython-312.opt-1.pyc000064400000000433152343231170013200 0ustar00 ֦i|4dZddlZejeZy)zLogging configuration.N)__doc__logging getLogger __package__logger$/usr/lib64/python3.12/asyncio/log.pyr s   ; 'r __pycache__/base_futures.cpython-312.opt-2.pyc000064400000005442152343231170015114 0ustar00 ֦ihdZddlZddlmZdZdZdZdZd Zd Z ejd Z y) N)format_helpersPENDING CANCELLEDFINISHEDcP t|jdxr|jduS)N_asyncio_future_blocking)hasattr __class__r )objs -/usr/lib64/python3.12/asyncio/base_futures.pyisfuturer s0 CMM#= > 5  ( ( 46c" t|}|sd}d}|dk(r||dd}nc|dk(r+dj||dd||dd}n3|dkDr.dj||dd|dz ||dd}d |d S) Nc.tj|dS)Nr)r_format_callback_source)callbacks r format_cbz$_format_callbacks..format_cbs55hCCrrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizers r_format_callbacksrs- r7D  D qy r!uQx   __Yr!uQx0)BqE!H2E F  ' ' "Q%((;(,q(1"R&)(<>"Q<rc |jjg}|jtk(r^|j|j d|jn3t j |j}|j d||jr$|j t|j|jr,|jd}|j d|dd|d|S)Nz exception=zresult=rz created at r:r) _statelower _FINISHED _exceptionappendreprlibrepr_result _callbacksr_source_traceback)futureinforesultframes r_future_repr_infor/,s- MM   ! "D }} !    ( KK*V%6%6$9: ;\\&..1F KK'&* +  %f&7&789 ((, k%(1U1XJ78 Krcpdjt|}d|jjd|dS)N <>)joinr/r __name__)r+r,s r _future_reprr6@s8 88%f- .D v(()4& 22r) __all__r&rr_PENDING _CANCELLEDr#rrr/recursive_reprr6rrrr;sO     6((33r__pycache__/base_tasks.cpython-312.pyc000064400000007760152343231170013611 0ustar00 ֦ip tddlZddlZddlZddlmZddlmZdZejdZdZ dZ y) N) base_futures) coroutinesctj|}|jr|jsd|d<|j dd|j z|j |j dd|j |jr5tj|j}|j dd|d|S) N cancellingrrzname=%rz wait_for=zcoro=<>) r_future_repr_infordoneinsertget_name _fut_waiter_coror_format_coroutine)taskinfocoros +/usr/lib64/python3.12/asyncio/base_tasks.py_task_repr_infor s  ) )$ /D QKK9t}}./ # A4#3#3"678 zz++DJJ7 AvQ'( Kcpdjt|}d|jjd|dS)N >zz 7 " KK !   *  61;;?xt<=) //C  dX&T2  th&?@tL 4(";<4H d3 33CMM3GD $Tr *Hr) r:reprlibr?r1rrrrecursive_reprrr.rJrrrNsC&11 F+r__pycache__/futures.cpython-312.pyc000064400000041634152343231170013165 0ustar00 ֦i8jdZdZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z dd l m Z e jZe jZe j Ze j"Zej$dz ZGd d ZeZd Zd ZdZdZdZdZdddZ ddlZej(xZZy#e$rYywxYw)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) GenericAlias) base_futures)events) exceptions)format_helpersceZdZdZeZdZdZdZdZ dZ dZ dZ dZ dddZdZdZeeZedZej,d Zd Zd Zdd Zd ZdZdZdZdZdddZdZ dZ!dZ"dZ#e#Z$y)ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopc|tj|_n||_g|_|jj r.t j tjd|_ yy)zInitialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. Nr) r get_event_loop_loop _callbacks get_debugr extract_stacksys _getframe_source_tracebackselfrs (/usr/lib64/python3.12/asyncio/futures.py__init__zFuture.__init__Hs[ <..0DJDJ ::   !%3%A%A a &"D " "c,tj|SN)r _future_reprrs r__repr__zFuture.__repr__Xs((..rc|jsy|j}|jjd||d}|jr|j|d<|j j |y)Nz exception was never retrieved)message exceptionfuturesource_traceback)_Future__log_traceback _exception __class____name__rrcall_exception_handler)rexccontexts r__del__zFuture.__del__[sl## oo>>**++IJ    ! !*.*@*@G& ' ))'2rc|jSr)r'r s r_log_tracebackzFuture._log_tracebackms###rc,|r tdd|_y)Nz'_log_traceback can only be set to FalseF) ValueErrorr')rvals rr0zFuture._log_tracebackqs FG G$rc8|j}| td|S)z-Return the event loop the Future is bound to.z!Future object is not initialized.)r RuntimeErrorrs rget_loopzFuture.get_loopws!zz <BC C rc|j|j}d|_|S|jtj}ntj|j}|j|_d|_|S)zCreate the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. N)_cancelled_exc_cancel_messager CancelledError __context__)rr,s r_make_cancelled_errorzFuture._make_cancelled_error~sr    *%%C"&D J    '++-C++D,@,@AC--" rc~d|_|jtk7ryt|_||_|j y)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r'_state_PENDING _CANCELLEDr9_Future__schedule_callbacks)rmsgs rcancelz Future.cancels9 % ;;( "  " !!#rc|jdd}|syg|jdd|D]#\}}|jj|||%y)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr-)rr call_soon)r callbackscallbackctxs r__schedule_callbackszFuture.__schedule_callbackssM OOA&  &MHc JJ 4 ='rc(|jtk(S)z(Return True if the future was cancelled.)r>r@r s r cancelledzFuture.cancelleds{{j((rc(|jtk7S)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r>r?r s rdonez Future.dones {{h&&rc |jtk(r|j|jtk7rt j dd|_|j%|jj|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.F) r>r@r< _FINISHEDr InvalidStateErrorr'r(with_traceback _exception_tb_resultr s rresultz Future.resultst ;;* $,,. . ;;) #../EF F$ ?? &//001C1CD D||rc|jtk(r|j|jtk7rt j dd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r>r@r<rPr rQr'r(r s rr$zFuture.exceptionsO ;;* $,,. . ;;) #../FG G$rrEc|jtk7r|jj|||y|t j }|j j||fy)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. rEN)r>r?rrF contextvars copy_contextrappend)rfnr-s radd_done_callbackzFuture.add_done_callbacksR ;;( " JJ T7 ;%224 OO " "B= 1rc|jDcgc]\}}||k7r||f}}}t|jt|z }|r||jdd|Scc}}w)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. N)rlen)rr[frIfiltered_callbacks removed_counts rremove_done_callbackzFuture.remove_done_callbacksn /3oo*.=(1c!"b !#h.= *DOO,s3E/FF !3DOOA  *sAc|jtk7r$tj|jd|||_t |_|j y)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r>r?r rQrTrPrA)rrUs r set_resultzFuture.set_resultsJ ;;( "..$++b/IJ J   !!#rcj|jtk7r$tj|jd|t |t r|}t |t rtd}||_||_ |}||_ |j|_ t|_|jd|_y)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rdzPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r>r?r rQ isinstancetype StopIterationr5 __cause__r;r( __traceback__rSrPrAr')rr$new_excs r set_exceptionzFuture.set_exceptions ;;( "..$++b/IJ J i &! I i /"$,-G!*G "+G I#&44  !!##rc#K|js d|_||js td|jSw)NTzawait wasn't used with future)rN_asyncio_future_blockingr5rUr s r __await__zFuture.__await__s=yy{,0D )Jyy{>? ?{{}sAA r)%r* __module__ __qualname____doc__r?r>rTr(rrr9r8ror'rr!r. classmethodr__class_getitem__propertyr0setterr6r<rCrArLrNrUr$r\rbrermrp__iter__rrrrs&FGJ EON %O#" /3 $L1 $$%% (  >) ' 04 2  $$.Hrrc^ |j}|S#t$rY|jSwxYwr)r6AttributeErrorr)futr6s r _get_loopr}-s:<<z    99  s  ,,cH|jry|j|y)z?Helper setting the result only if the future was not cancelled.N)rLre)r|rUs r_set_result_unless_cancelledr9s }}NN6rclt|}|tjjurt j|j S|tjj urt j |j S|tjjurt j|j S|Sr)rh concurrentfuturesr:r args TimeoutErrorrQ)r, exc_classs r_convert_future_excr@sS IJ&&555((#((33 j((55 5&&11 j((:: :++SXX66 rc.|jsJ|jr|j|jsy|j }||j t |y|j}|j|y)z8Copy state from a future to a concurrent.futures.Future.N) rNrLrCset_running_or_notify_cancelr$rmrrUre)rsourcer$rUs r_set_concurrent_future_staterLs ;;==   2: 2 2 4  "I   !4Y!?@ f%rcL|jsJ|jry|jrJ|jr|jy|j}||j t |y|j }|j|y)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)rNrLrCr$rmrrUre)rdestr$rUs r_copy_future_stater[s ;;== ~~yy{?  $$&    29= >]]_F OOF #rcts/ttjjs t dts/ttjjs t dtr t ndtr t nddfd}fd}j|j|y)aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcLt|r t||yt||yr)rrr)r%others r _set_statez!_chain_future.._set_states F  uf - ( 7rc|jr3urjyjjyyr)rLrCcall_soon_threadsafe) destination dest_loopr source_loops r_call_check_cancelz)_chain_future.._call_check_cancels<  ""kY&> 00? #rcjrjryur |yjryj|yr)rL is_closedr)rrrrrs r_call_set_statez&_chain_future.._call_set_states[  ! ! #%)*=*=*?    [ 8 {F +""$  * *:{F Kr)rrgrrr TypeErrorr}r\)rrrrrrrs`` @@@r _chain_futureros F Jv/9/A/A/H/H%JBCC K K4>4F4F4M4M*OGHH'/'7)F#TK*2;*? +&TI8 @ L!!"45 _-rr ct|r|St|tjjs Jd||t j }|j}t|||S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got ) rrgrrrr r create_futurer)r%r new_futures rrrso fj0077 8A 5fZ@A 8 |$$&##%J&*% r) rs__all__concurrent.futuresrrXloggingrtypesrrr r r rr?r@rPDEBUG STACK_DEBUGr _PyFuturer}rrrrrr_asyncio_CFuture ImportErrorryrrrs4        $ $  " " mma HHX     &$().X!% ( !'FX   sB**B21B2__pycache__/streams.cpython-312.opt-1.pyc000064400000100275152343231170014102 0ustar00 ֦ikldZddlZddlZddlZddlZddlZeedredz ZddlmZddlm Z ddlm Z dd lm Z dd lm Z dd l mZdd lmZd ZdeddZdeddZeedrdeddZdeddZGdde j,ZGddee j,ZGddZGddZy)) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)limitc Ktj}t||}t|| |j fd||fi|d{\}}t | ||}||fS7w)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) rlooprcSNprotocols(/usr/lib64/python3.12/asyncio/streams.pyz!open_connection..1sN)r get_running_looprrcreate_connectionr) hostportrkwdsrreader transport_writerrs @rrrsx&  " " $D D 1F#F6H///$.(,..LIq )Xvt .sA A) A'A)cKtjfd}j|||fi|d{S7w)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. c>t}t|}|SNrrrrr%rclient_connected_cbrrs rfactoryzstart_server..factoryNs&E5'0C-13rN)r r create_server)r.r"r#rr$r/rs` ` @rrr6s@,  " " $D $##GT4@4@ @@ @s4A>AcKtj}t||}t|||jfd|fi|d{\}}t |||}||fS7w)z@Similar to `open_connection` but works with UNIX Domain Sockets.rrcSrrrsrrz&open_unix_connection..bsHrN)r r rrcreate_unix_connectionr) pathrr$rr%r&r'r(rs @rr r Zsv&&(E5'T:8T88 d,&*,, 1i64@v~,sA A( A& A(cKtjfd}j||fi|d{S7w)z=Similar to `start_server` but works with UNIX Domain Sockets.c>t}t|}|Sr+r,r-s rr/z"start_unix_server..factoryks&!D9F+F4G157HOrN)r r create_unix_server)r.r4rr$r/rs` ` @rr r fs>&&(  -T,,WdCdCCCCs 3?=?c6eZdZdZd dZdZdZdZdZdZ y) FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. Nc|tj|_n||_d|_t j |_d|_yNF)r get_event_loop_loop_paused collectionsdeque_drain_waiters_connection_lost)selfrs r__init__zFlowControlMixin.__init__~s> <..0DJDJ )//1 %rctd|_|jjrtjd|yy)NTz%r pauses writing)r>r= get_debugrdebugrCs r pause_writingzFlowControlMixin.pause_writings- ::   ! LL,d 3 "rcd|_|jjrtjd||j D]$}|j r|jd&y)NFz%r resumes writing)r>r=rFrrGrAdone set_resultrCwaiters rresume_writingzFlowControlMixin.resume_writingsO ::   ! LL-t 4))F;;=!!$'*rcd|_|jsy|jD]8}|jr||j d(|j |:yNT)rBr>rArKrL set_exceptionrCexcrNs rconnection_lostz FlowControlMixin.connection_lostsN $|| ))F;;=;%%d+((- *rcNK|jr td|jsy|jj }|j j | |d{|j j|y7 #|j j|wxYww)NzConnection lost)rBConnectionResetErrorr>r= create_futurerAappendremoverMs r _drain_helperzFlowControlMixin._drain_helpers  &'89 9|| ))+ ""6* /LL    & &v .     & &v .s0AB%B"B#B'B%BB""B%ctr)NotImplementedErrorrCstreams r_get_close_waiterz"FlowControlMixin._get_close_waiters!!rr) __name__ __module__ __qualname____doc__rDrIrOrUr[r`rrrr9r9ts%&4 ( . /"rr9cfeZdZdZdZd fd ZedZdZdZ fdZ dZ d Z d Z d ZxZS) ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Nc4t|||,tj||_|j |_nd|_|||_d|_d|_d|_ d|_ ||_ d|_ |jj|_y)NrF)superrDweakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer_task _transport_client_connected_cb _over_sslr=rX_closed)rC stream_readerr.r __class__s rrDzStreamReaderProtocol.__init__s d#  $%,[[%?D "%2%D%DD "%)D "  *#0D "'" $7!zz//1 rc<|jy|jSr)rjrHs r_stream_readerz#StreamReaderProtocol._stream_readers  ! ! )%%''rc|j}|j}||_||_|j ddu|_y)N sslcontext)r=r&rnrpget_extra_inforr)rCr(rr&s r_replace_writerz$StreamReaderProtocol._replace_writers<zz$$ $#"11,?tKrcxjrKddi}jrj|d<jj|j y_j }||jjddu_ jt|j_ j|j}tj|rAfd}jj|_j j#|d_yy)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.source_tracebackryc|jrjy|j}|0jj d|djyy)Nz*Unhandled exception in client_connected_cb)r} exceptionr&) cancelledcloserr=call_exception_handler)taskrTrCr&s rcallbackz6StreamReaderProtocol.connection_made..callbacks\~~'!)..*C 99'S),)2; ") 'r)rmrkr=rabortrprw set_transportrzrrrqrrnr iscoroutine create_taskroadd_done_callbackrl)rCr&contextr%resrs`` rconnection_madez$StreamReaderProtocol.connection_mades#  " "@G %%.2.D.D*+ JJ - -g 6 OO  #$$     +"11,?tK  $ $ 0".y$/5/3zz#;D ++F,0,?,?AC%%c* *"ZZ33C8  ,,X6"&D / 1rcf|j}|$||jn|j||jj s9||jj dn|jj|t ||d|_d|_ d|_ d|_ yr) rwfeed_eofrRrsrKrLrgrUrjrnrorp)rCrTr%rus rrUz$StreamReaderProtocol.connection_lost s$$  {!$$S)||  "{ ''- **3/ $!%" rcD|j}||j|yyr)rw feed_data)rCdatar%s r data_receivedz"StreamReaderProtocol.data_receiveds&$$     T " rcZ|j}||j|jryy)NFT)rwrrr)rCr%s r eof_receivedz!StreamReaderProtocol.eof_received!s,$$   OO  >>rc|jSr)rsr^s rr`z&StreamReaderProtocol._get_close_waiter,s ||rc |j}|jr"|js|jyyy#t$rYywxYwr)rsrKrrAttributeError)rCcloseds r__del__zStreamReaderProtocol.__del__/sM #\\F{{}V%5%5%7  "&8}   s A A  A NN)rarbrcrdrkrDpropertyrwr{rrUrrr`r __classcell__)rus@rrrsN2((( L('T$#  #rrczeZdZdZdZdZedZdZdZ dZ dZ d Z d Z d Zdd ZdZd d d ddZdZy )ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. c||_||_||_||_|jj |_|j j dyr)rp _protocol_readerr=rX _complete_futrL)rCr&rr%rs rrDzStreamWriter.__init__EsI#!  !ZZ557 %%d+rc|jjd|jg}|j|j d|jdj dj |S)N transport=zreader=<{}> )rurarprrYformatjoinrCinfos r__repr__zStreamWriter.__repr__Os['':doo5H)IJ << # KK'$,,!12 3}}SXXd^,,rc|jSrrprHs rr&zStreamWriter.transportUs rc:|jj|yr)rpwriterCrs rrzStreamWriter.writeYs d#rc:|jj|yr)rp writelinesrs rrzStreamWriter.writelines\s ""4(rc6|jjSr)rp write_eofrHs rrzStreamWriter.write_eof_s((**rc6|jjSr)rp can_write_eofrHs rrzStreamWriter.can_write_eofbs,,..rc6|jjSr)rprrHs rrzStreamWriter.closees$$&&rc6|jjSr)rp is_closingrHs rrzStreamWriter.is_closinghs))++rcVK|jj|d{y7wr)rr`rHs r wait_closedzStreamWriter.wait_closedksnn..t444s )')Nc:|jj||Sr)rprz)rCnamedefaults rrzzStreamWriter.get_extra_infons--dG<>jjl"jj22 OOXz#_"7!5 377 (  & 7s!8BB 3B.B/BBc|jjsc|jjrt j dt y|jt j d|t yy)Nzloop is closedz unclosed )rprr= is_closedwarningswarnResourceWarningrrHs rrzStreamWriter.__del__sT))+zz##% .@  $2OD ,rr)rarbrcrdrDrrr&rrrrrrrrzrrrrrrrr;sh,- $)+/',5=-4)-.2-1' ErrceZdZdZedfdZdZdZdZdZ dZ dZ d Z d Z d Zd Zd ZddZddZdZdZdZy)rNcl|dkr td||_|tj|_n||_t |_d|_d|_d|_ d|_ d|_ |jjr.tjtj d|_yy)NrzLimit cannot be <= 0Fr ) ValueError_limitr r<r= bytearray_buffer_eof_waiter _exceptionrpr>rFr extract_stacksys _getframerk)rCrrs rrDzStreamReader.__init__s A:34 4 <..0DJDJ {    ::   !%3%A%A a &"D " "rcdg}|jr'|jt|jd|jr|jd|jt k7r|jd|j|j r|jd|j |jr|jd|j|jr|jd|j|jr|jdd jd j|S) Nrz byteseofzlimit=zwaiter=z exception=rpausedrr) rrYlenrr_DEFAULT_LIMITrrrpr>rrrs rrzStreamReader.__repr__s << KK3t||,-V4 5 99 KK  ;;. ( KK& . / << KK'$,,!12 3 ?? KK*T__$78 9 ?? KK*T__$78 9 << KK !}}SXXd^,,rc|jSr)rrHs rrzStreamReader.exceptions rc||_|j}|*d|_|js|j|yyyr)rrrrRrSs rrRzStreamReader.set_exceptionsC  DL##%$$S)& rct|j}|*d|_|js|jdyyy)z1Wakeup read*() functions waiting for data or EOF.N)rrrLrMs r_wakeup_waiterzStreamReader._wakeup_waiters<  DL##%!!$'& rc||_yrr)rCr&s rrzStreamReader.set_transports #rc|jrEt|j|jkr"d|_|jj yyyr;)r>rrrrpresume_readingrHs r_maybe_resume_transportz$StreamReader._maybe_resume_transports; <rr pause_readingr]rs rrzStreamReader.feed_datas  D!  OO 'LLDLL!A O3 $--/ $ 4! ( ' '#'  's-BB%$B%c,K|jt|d|jr!d|_|jj |j j |_ |jd{d|_y7 #d|_wxYww)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr>rprr=rX)rC func_names r_wait_for_datazStreamReader._wait_for_data s << #+456 6 << DL OO * * ,zz//1  ,,  DL DLs0A'B*B9B:B>BB BBcKd}t|} |j|d{}|S7#tj$r}|jcYd}~Sd}~wtj $r}|j j||jr|j d|j|z=n|j j|jt|jdd}~wwxYww)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilrIncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)rCsepseplenlinees rreadlinezStreamReader.readline%s S (,,D --- 99 ++ (||&&sAJJ7LL!5!**v"5!56 ""$  ( ( *QVVAY' '  (sJC5.,.C5.C2 A C2 C5C2(BC--C22C5cKt|}|dk(r td|j |jd} t|j}||z |k\rO|jj ||}|dk7rn|dz|z }||j kDrt jd||jrEt|j}|jjt j|d|jdd{||j kDrt jd||jd||z}|jd||z=|jt|S7iw) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrrrrbytesrrrr)rC separatorroffsetbuflenisepchunks rrzStreamReader.readuntilDsz(Y Q;KL L ?? &// !*&F&(||((F;2: !f,DKK'$66L  yydll+ ""$ 44UDAA%%k2 2 2=@ $++ ..DdL L ^dVm, LL$- ( $$&U| 3sDE6 E4 A*E6cK|j |j|dk(ry|dkrLg} |j|jd{}|sn|j|8dj |S|j s%|j s|jdd{tt|j d|}|j d|=|j|S77Hw)aRead up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rr rrYrrrrr memoryviewr)rCnblocksblockrs rr zStreamReader.reads, ?? &// ! 6 q5 F"ii 44 e$  88F# #||DII%%f- - -Z -bq12 LL!  $$& 5 .s&AC)C%AC)C'AC)'C)cK|dkr td|j |j|dk(ryt|j|kr|jrEt |j}|jj tj|||jdd{t|j|krt|j|k(r0t |j}|jj n0t t|jd|}|jd|=|j|S7w)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrrrrr r)rCr  incompleters rrzStreamReader.readexactlys q5IJ J ?? &// ! 6$,,!#yy"4<<0  ""$ 44ZCC%%m4 4 4 $,,!# t||  !&D LL   DLL1"156D RaR  $$&  5sB,E.E/E B Ec|SrrrHs r __aiter__zStreamReader.__aiter__s rcXK|jd{}|dk(rt|S7w)Nr)rStopAsyncIteration)rCvals r __anext__zStreamReader.__anext__s+MMO# #:$ $ $s *(*)r)r)rarbrcrkrrDrrrRrrrrrrrrrr rrrrrrrrsf+$",-$*($- .$, 8>Yv1f'Rrrrr)__all__r?socketrrrhhasattrr r rrrlogrtasksrrrrr r Protocolr9rrrrrrrs '  69 <)typerid_formatr+s r__repr__zQueue.__repr__Bs54:&&'tBtHR=$,,.9IKKrcVdt|jd|jdS)Nr;r<r=)r>rr@r+s r__str__z Queue.__str__Es)4:&&'q(8::rcPd|j}t|ddr|dt|jz }|jr|dt |jdz }|j r|dt |j dz }|jr|d|jz }|S)Nzmaxsize=r(z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr(rlenrr)r#results rr@z Queue._formatJsDMM,- 44 ( dkk!2 56 6F ==  3t}}#5"6a8 8F ==  3t}}#5"6a8 8F  ! !  6 678 8F rc,t|jS)zNumber of items in the queue.)rHr(r+s rqsizez Queue.qsizeVs4;;rc|jS)z%Number of items allowed in the queue.)rr+s rr$z Queue.maxsizeZs}}rc|j S)z3Return True if the queue is empty, False otherwise.r(r+s remptyz Queue.empty_s;;rc\|jdkry|j|jk\S)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rF)rrKr+s rfullz Queue.fullcs( ==A ::<4==0 0rcK|jrU|jj}|jj | |d{|jrU|j|S7&#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYww)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rQ _get_loop create_futurerr/cancelremove ValueError cancelledr9 put_nowait)r#r1putters rputz Queue.putns iik^^%335F MM  (  iik&t$$  MM((0!yy{6+;+;+=%%dmm4sZA C8 A;A9A;C8(C89A;;C5B*)C5* B63C55B66?C55C8c|jrt|j||xjdz c_|jj |j |jy)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. r N)rQrr2rrclearr9rr0s rrYzQueue.put_nowaitsP 99;O $ !#  $--(rcK|jrU|jj}|jj | |d{|jrU|jS7%#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYww)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rOrSrTrr/rUrVrWrXr9 get_nowait)r#getters rgetz Queue.gets jjl^^%335F MM  (  jjl&    MM((0!zz|F,<,<,>%%dmm4sZA C7 A:A8A:C7(C78A::C4 B)(C4) B52C44B55?C44C7c|jrt|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rOrr,r9rr0s rr_zQueue.get_nowaits5 ::< yy{ $--( rc|jdkr td|xjdzc_|jdk(r|jjyy)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesr N)rrWrr r+s r task_donezQueue.task_donesR  ! !Q &@A A !#  ! !Q & NN    'rctK|jdkDr#|jjd{yy7w)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwaitr+s rjoinz Queue.joins4  ! !A %..%%' ' ' & 's -868N)r)rrrrr%r!r,r2r9rArC classmethodr__class_getitem__r@rKpropertyr$rOrQr[rYrar_rdrgrrrrrs~  *%! L;$L1   1%6 )!4 !( (rrcReZdZdZdZej fdZejfdZ y)rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cg|_yr'rNr"s rr!zPriorityQueue._init  rc*||j|yr'rN)r#r1heappushs rr2zPriorityQueue._putsd#rc&||jSr'rN)r#heappops rr,zPriorityQueue._getst{{##rN) rrrrr!heapqror2rqr,rrrrrs( #(..$!==$rrc"eZdZdZdZdZdZy)rzEA subclass of Queue that retrieves most recently added entries first.cg|_yr'rNr"s rr!zLifoQueue._initrmrc:|jj|yr'r.r0s rr2zLifoQueue._putr3rc6|jjSr')r(popr+s rr,zLifoQueue._gets{{  rN)rrrrr!r2r,rrrrrsO!!rr)__all__rrrtypesrr r Exceptionrr_LoopBoundMixinrrrrrrr}s^ L     B(F " "B(J $E $ ! !r__pycache__/exceptions.cpython-312.pyc000064400000006013152343231170013641 0ustar00 ֦idZdZGddeZeZGddeZGddeZGdd e Z Gd d eZ Gd d eZ y)zasyncio exceptions.)BrokenBarrierErrorCancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorceZdZdZy)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__+/usr/lib64/python3.12/asyncio/exceptions.pyrr s+rrceZdZdZy)rz+The operation is not allowed in this state.Nr rrrrrs5rrceZdZdZy)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nr rrrrrsrrc(eZdZdZfdZdZxZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) c||dn t|}t| t|d|d||_||_y)N undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrr r_expected __class__s rrzIncompleteReadError.__init__$sE$,$4[$x.  CL>)C&<8 9   rcHt||j|jffSN)typerrrs r __reduce__zIncompleteReadError.__reduce__+sDzDLL$--888rr r r rrr$ __classcell__rs@rrrs !9rrc(eZdZdZfdZdZxZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. c2t||||_yr!)rrconsumed)rmessager*rs rrzLimitOverrunError.__init__5s !  rcNt||jd|jffS)N)r"argsr*r#s rr$zLimitOverrunError.__reduce__9s"DzDIIaL$--888rr%r's@rrr/s !9rrceZdZdZy)rz*Barrier is broken by barrier.abort() call.Nr rrrrr=s4rrN) r__all__ BaseExceptionrr Exceptionr RuntimeErrorrEOFErrorrrrrrrr5s^ ( ,], 6 6 9(9$ 9 955r__pycache__/format_helpers.cpython-312.opt-2.pyc000064400000007070152343231170015436 0ustar00 ֦id ZddlZddlZddlZddlZddlZddlmZdZdZdZ d dZ d dZ y) N) constantsc\tj|}tj|r$|j}|j|j fSt |tjrt|jSt |tjrt|jSyN) inspectunwrap isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcodes //usr/lib64/python3.12/asyncio/format_helpers.pyrr s >>$ D$}}  $"5"566$ ))*#DII..$ //0#DII.. c\t||d}t|}|r|d|dd|dz }|S)Nz at r:r)_format_callbackr)rargs func_reprsources r_format_callback_sourcersB tT2I !$ 'F tF1I;aq {33 rc g}|r|jd|D|r&|jd|jDdjdj|S)Nc3FK|]}tj|ywrreprlibrepr).0args r z*_format_args_and_kwargs..&s7$3W\\#&$s!c3VK|]!\}}|dtj|#yw)=Nr)r"kvs rr$z*_format_args_and_kwargs..(s)I.$!Qs!GLLO,-.s')z({})z, )extenditemsformatjoin)rkwargsr*s r_format_args_and_kwargsr.sV E  7$77  I&,,.II ==5) **rct|tjr;t|||z}t |j |j |j|St|dr|jr |j}n0t|dr|jr |j}n t|}|t||z }|r||z }|S)N __qualname____name__) r rrr.rrrkeywordshasattrr0r1r!)rrr-suffixrs rrr,s$ ))*(v6? 499dmmVLLt^$):):%% z "t}}MM J  (v66I V rc |tjj}|tj}t j jt j||d}|j|S)NF)limit lookup_lines) sys _getframef_backrDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr6stacks r extract_stackrC>so y MMO " " }++  " " * *9+?+?+B168= + ?E MMO Lr))NN) rrr r8r<rDrrrr.rrCrrrFs0   +$r__pycache__/base_subprocess.cpython-312.pyc000064400000037320152343231170014647 0ustar00 ֦i"ddlZddlZddlZddlmZddlmZddlmZGddejZ Gdd ejZ Gd d e ejZ y) N) protocols) transports)loggerceZdZ dfd ZdZdZdZdZdZdZ e jfdZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZxZS)BaseSubprocessTransportc nt || d|_||_||_d|_d|_d|_g|_tj|_ i|_ d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d| |j j$|_|j |j&d<|jj)r?t+|t,t.fr|} n|d} t1j2d| |j |jj5|j7| y#|j#xYw) NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepid_extra get_debug isinstancebytesstrrdebug create_task_connect_pipes)selfloopprotocolr r r rrrwaiterextrakwargsprogram __class__s 0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__ sx  !   )//1  JOO #!DKKN Z__ $!DKKN Z__ $!DKKN  DKK BTeF%w B:@ B JJNN $(JJ L! ::   !$ -q' LL5 $)) - t226:;  JJL s F!!F4c^|jjg}|jr|jd|j|jd|j|j |jd|j n/|j|jdn|jd|j jd}||jd|j|j jd}|j jd }|#||ur|jd |jn@||jd |j||jd |jd jdj|S)Nclosedzpid=z returncode=runningz not startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}> ) r4__name__rappendrrrgetpipeformatjoin)r-infor rrs r5__repr__z BaseSubprocessTransport.__repr__7sX''( << KK ! 99 KK$tyyk* +    ' KK+d&6&6%78 9 YY " KK " KK & "   KK& - .##  &F"2 KK. 6 7! gfkk]34! gfkk]34}}SXXd^,,c tN)NotImplementedError)r-r r r rrrr2s r5r"zBaseSubprocessTransport._startTs!!rBc||_yrDr)r-r/s r5 set_protocolz$BaseSubprocessTransport.set_protocolWs !rBc|jSrDrGr-s r5 get_protocolz$BaseSubprocessTransport.get_protocolZs ~~rBc|jSrD)rrJs r5 is_closingz"BaseSubprocessTransport.is_closing]s ||rBc|jryd|_|jjD]}||jj !|j t|j g|j jL|jjrtjd| |j jyyyy#t$rYywxYw)NTz$Close running child process: kill %r)rrvaluesr=r#rrpollrr&rwarningkillProcessLookupError)r-protos r5r#zBaseSubprocessTransport.close`s <<  [['')E} JJ   * JJ "  ( !)zz##%EtL  ! *) #&  s4C CCcb|js#|d|t||jyy)Nzunclosed transport )source)rResourceWarningr#)r-_warns r5__del__zBaseSubprocessTransport.__del__{s+|| 'x0/$ O JJLrBc|jSrD)rrJs r5get_pidzBaseSubprocessTransport.get_pids yyrBc|jSrD)rrJs r5get_returncodez&BaseSubprocessTransport.get_returncodesrBcR||jvr|j|jSyrD)rr=)r-fds r5get_pipe_transportz*BaseSubprocessTransport.get_pipe_transports%  ;;r?'' 'rBc0|j tyrD)rrSrJs r5 _check_procz#BaseSubprocessTransport._check_procs :: $& & rBcZ|j|jj|yrD)rbr send_signal)r-signals r5rdz#BaseSubprocessTransport.send_signals   v&rBcX|j|jjyrD)rbr terminaterJs r5rgz!BaseSubprocessTransport.terminates  rBcX|j|jjyrD)rbrrRrJs r5rRzBaseSubprocessTransport.kills  rBcK j}j}|j9|jfd|jd{\}}|jd<|j 9|j fd|j d{\}}|jd<|j9|j fd|jd{\}}|jd<jJ|jjjjD]\}}|j|g|d_|#|js|jdyyy7)77#ttf$rt $r7}|+|js|j#|Yd}~yYd}~yYd}~yd}~wwxYww)NctdS)Nr)WriteSubprocessPipeProtorJsr5z8BaseSubprocessTransport._connect_pipes..s 4T1=rBrctdS)NrReadSubprocessPipeProtorJsr5rlz8BaseSubprocessTransport._connect_pipes.. 3D!.rprBr )rrr connect_write_piperrconnect_read_piperr call_soonrconnection_made cancelled set_result SystemExitKeyboardInterrupt BaseException set_exception) r-r0procr._r=callbackdataexcs ` r5r,z&BaseSubprocessTransport._connect_pipess# (::D::Dzz% $ 7 7=JJ!  4"& A{{& $ 6 6<KK!!!4"& A{{& $ 6 6<KK!!!4"& A&&2 22 NN4>>994 @"&"5"5$x/$/#6"&D !&*:*:*<!!$'+=!; ! !-.   *!&*:*:*<$$S))+=! *shG AE; E4 AE;E7AE;E9A8E;&G 4E;7E;9E;;G #G6G G  G c|j|jj||fy|jj|g|yrD)rr;rrt)r-cbrs r5_callzBaseSubprocessTransport._calls?    *    & &Dz 2 DJJ  +d +rBcr|j|jj|||jyrD)rrpipe_connection_lost _try_finish)r-r_rs r5_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_losts( 4>>66C@ rBcR|j|jj||yrD)rrpipe_data_received)r-r_rs r5_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_receiveds 4>>44b$?rBcx|J||jJ|j|jjrtjd||||_|j j ||j _|j|jj|jy)Nz%r exited with return code %r) rrr&rr@r returncoderrprocess_exitedr)r-rs r5_process_exitedz'BaseSubprocessTransport._process_exiteds%1z1%'9)9)99' ::   ! KK7z J% :: (%/DJJ ! 4>>001 rBcK|j |jS|jj}|jj ||d{S7w)zdWait until the process exit and return the process return code. This method is a coroutine.N)rr create_futurerr;)r-r0s r5_waitzBaseSubprocessTransport._waitsP    '## #))+ !!&)||sAAAAc|jrJ|jytd|jj Dr$d|_|j |j dyy)Nc3@K|]}|duxr |jywrD) disconnected).0ps r5 z6BaseSubprocessTransport._try_finish..s(.,1}//,sT)r rallrrOr_call_connection_lostrJs r5rz#BaseSubprocessTransport._try_finishs`>>!!    #  . **,. .!DN JJt114 8 .rBc |jj||jD].}|jr|j |j 0d|_d|_d|_d|_y#|jD].}|jr|j |j 0d|_d|_d|_d|_wxYwrD)rconnection_lostrrvrwrrr)r-rr0s r5rz-BaseSubprocessTransport._call_connection_losts " NN * *3 /,,'')%%d&6&67-"&D DJDJ!DN ,,'')%%d&6&67-"&D DJDJ!DNsA77 C:C)NN)r: __module__ __qualname__rrAr"rHrKrMr#warningswarnrYr[r]r`rbrdrgrRr,rrrrrrr __classcell__)r4s@r5rr s%)))r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s04>>**+4ytyym1MMrBcld|_|jj|j|d|_y)NT)rr|rr_)r-rs r5rz(WriteSubprocessPipeProto.connection_lost s)  ''5 rBcL|jjjyrD)r|r pause_writingrJs r5rz&WriteSubprocessPipeProto.pause_writings ))+rBcL|jjjyrD)r|rresume_writingrJs r5rz'WriteSubprocessPipeProto.resume_writings **,rBN) r:rrrrurArrrrrBr5rkrks!" N ,-rBrkceZdZdZy)rocP|jj|j|yrD)r|rr_)r-rs r5 data_receivedz%ReadSubprocessPipeProto.data_receiveds %%dggt4rBN)r:rrrrrBr5roros5rBro)rrrrrlogrSubprocessTransportr BaseProtocolrkProtocolrorrBr5rsTr"j<<r"j-y55-456'005rB__pycache__/subprocess.cpython-312.opt-1.pyc000064400000027451152343231170014620 0ustar00 ֦i92dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZ Gd d ejejZGd d Zdddej fd Zdddej ddZy))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercLeZdZdZfdZdZdZdZdZdZ dZ d Z xZ S) SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.ct||||_dx|_x|_|_d|_d|_g|_|jj|_ y)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loop create_future _stdin_closed)selflimitr __class__s +/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ d# 155 5T[4;$!ZZ557cl|jjg}|j|jd|j|j|jd|j|j |jd|j dj dj|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinfos r__repr__z!SubprocessStreamProtocol.__repr__s''( :: ! KK&/ 0 ;; " KK'$++1 2 ;; " KK'$++1 2}}SXXd^,,rcn||_|jd}|ftj|j|j |_|j j||jjd|jd}|ftj|j|j |_ |jj||jjd|jd}|)tj||d|j |_ yy)Nrrrr)protocolreaderr) rget_pipe_transportr StreamReaderrrr set_transportrr#r StreamWriterr)r transportstdout_transportstderr_transportstdin_transports rconnection_madez(SubprocessStreamProtocol.connection_made(s#$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $#66q9  & --o7;5937::?DJ 'rcx|dk(r |j}n|dk(r |j}nd}||j|yyNrr*)rr feed_data)rfddatar,s rpipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@ 7[[F 1W[[FF     T " rc |dk(rz|j}||j|j|||jj dy|jj |d|j_y|dk(r |j}n|dk(r |j}nd}|$||jn|j |||jvr|jj||jy)NrFrr*) rcloseconnection_lostr set_result set_exception_log_tracebackrrfeed_eofrremove_maybe_close_transport)rr9excpiper,s rpipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs 7::D   %{""--d3  ""0055:""1  7[[F 1W[[FF  {!$$S)   NN ! !" % ##%rc2d|_|jy)NT)rrDrs rprocess_exitedz'SubprocessStreamProtocol.process_exitedhs# ##%rct|jdk(r/|jr"|jj d|_yyy)Nr)lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls: t~~ ! #(<(< OO ! ! #"DO)= #rc8||jur |jSyN)rr)rstreams r_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs TZZ %% % r) r" __module__ __qualname____doc__rr'r5r;rGrJrDrP __classcell__)rs@rr r s.:8-?0#&<&# &rr cZeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d d Zy )Processc||_||_||_|j|_|j|_|j |_|j |_yrN)r _protocolrrrrget_pidpid)rr1r+rs rrzProcess.__init__wsH#! ^^ oo oo $$&rcPd|jjd|jdS)N)rr"rZrIs rr'zProcess.__repr__s&4>>**+1TXXJa88rc6|jjSrN)rget_returncoderIs r returncodezProcess.returncodes--//rcRK|jjd{S7w)z?Wait until the process exit and return the process return code.N)r_waitrIs rwaitz Process.waits__**,,,,s '%'c:|jj|yrN)r send_signal)rsignals rrezProcess.send_signals ##F+rc8|jjyrN)r terminaterIs rrhzProcess.terminates !!#rc8|jjyrN)rkillrIs rrjz Process.kills rcK|jj} |=|jj||r t j d|t ||jjd{|rt j d||jjy77#ttf$r#}|rt j d||Yd}~bd}~wwxYww)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugrLdrainBrokenPipeErrorConnectionResetErrorr=)rinputrnrEs r _feed_stdinzProcess._feed_stdins $$& H    'LL?s5zS**""$ $ $  LL6 =  %!56 H ;T3G  HsAC)AB4:B2;B4?3C)2B44C&C!C)!C&&C)c KywrNrIs r_noopz Process._noops scK|jj|}|dk(r |j}n |j}|jj r |dk(rdnd}t jd|||jd{}|jj r |dk(rdnd}t jd|||j|S7Pw)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrlr rnreadr=)rr9r1rOnameoutputs r _read_streamzProcess._read_streamsOO66r: 7[[F[[F ::   !!Qw8HD LL2D$ ?{{}$ ::   !!Qw8HD LL3T4 @ %sBC C ACNcK|j|j|}n|j}|j|j d}n|j}|j |j d}n|j}t j|||d{\}}}|jd{||fS7$7 wr7) rrsrvrr{rr gatherrc)rrrrrrs r communicatezProcess.communicates :: !$$U+EJJLE ;; "&&q)FZZ\F ;; "&&q)FZZ\F&+ll5&&&I Ivviik!Js$B%C'C (CC CCrN)r"rQrRrr'propertyr`rcrerhrjrsrvr{r~rurrrVrVvsH'900-,$(" rrVc Ktj  fd} j||f|||d|d{\}}t|| S7w)NctSNr)r r)srz)create_subprocess_shell..7e=A Crrrr)rget_running_loopsubprocess_shellrV) cmdrrrrkwdsprotocol_factoryr1r+rs ` @rrrsm  " " $DC 5 5 5 !!!Ix 9h -- s6AAA)rrrrc Ktj  fd} j||g||||d|d{\}} t|| S7w)NctSrrr)srrz(create_subprocess_exec..rrr)rrsubprocess_execrV) programrrrrargsrrr1r+rs ` @rrrsy  " " $DC 4 4 4!!F ! !Ix 9h -- s9AAA)__all__ subprocessrrrr logr PIPESTDOUTDEVNULLFlowControlMixinSubprocessProtocolr rV_DEFAULT_LIMITrrrurrrs =      b&w77(;;b&JU U p.2$t(/(>(> .8)r _repr_inforr&insertaddressr infostater"s r#r*z_OverlappedFuture._repr_info=s\w!# 88 !%!1!1I{E KK\%4883C3CB2GqI J r$c|jy |jjd|_y#t$rM}d||d}|jr|j|d<|jj |Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)r exccontexts r#_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs 88   7 HHOO  7C G %%.2.D.D*+ JJ - -g 6 6 7s1 B r$cd|_yrB)r)r futs r#_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cbs r$c|jsyd|_|j}d|_ tj||jdy#t$rh}|j tj k7rAd||d}|jr|j|d<|jj|Yd}~yYd}~~d}~wwxYwNFz$Failed to unregister the wait handler1r5) rSrR _overlappedUnregisterWaitr7winerrorERROR_IO_PENDINGrr8r9rcr rUr:r;s r#_unregister_waitz&_BaseWaitHandleFuture._unregister_waits  ''     & &{ 3   & ||{;;;E!$" ))262H2HG./ 11':< sA CAB<<CcD|jt| |Sr>)rkrr6r@s r#r6z_BaseWaitHandleFuture.cancels  w~#~&&r$cD|jt| |yrB)rkrrCrDs r#rCz#_BaseWaitHandleFuture.set_exceptions  i(r$cD|jt| |yrB)rkrrFrGs r#rFz _BaseWaitHandleFuture.set_results  6"r$rB) rIrJrKrr\r*rcrkr6rCrFrLrMs@r#rOrOas6<8<  '  '0')##r$rOc@eZdZ ddfd ZdZfdZfdZxZS)_WaitCancelFutureNrc:t|||||d|_y)Nr)rr_done_callback)r r!eventrUrr"s r#rz_WaitCancelFuture.__init__s! UKd;"r$ctd)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr[s r#r6z_WaitCancelFuture.cancelsDEEr$c`t|||j|j|yyrB)rrFrrrGs r#rFz_WaitCancelFuture.set_results/ 6"    *    % +r$c`t|||j|j|yyrB)rrCrrrDs r#rCz_WaitCancelFuture.set_exceptions/ i(    *    % +r$)rIrJrKrr6rFrCrLrMs@r#rprps'8<# F& &&r$rpc4eZdZddfd ZfdZdZxZS)_WaitHandleFutureNrct|||||||_d|_t j dddd|_d|_y)NrTF)rr _proactor_unregister_proactorrf CreateEvent_event _event_fut)r r!rTrUproactorrr"s r#rz_WaitHandleFuture.__init__sG V[t<!$(!!--dD%F r$c|j-tj|jd|_d|_|jj |j d|_t|!|yrB) r~rX CloseHandlerr{ _unregisterrrrc)r rbr"s r#rcz%_WaitHandleFuture._unregister_wait_cbsY ;; "    ,DK"DO ""488, #C(r$c|jsyd|_|j}d|_ tj||j|jj|j|j|_y#t $rh}|j tjk7rAd||d}|jr|j|d<|jj|Yd}~yYd}~d}~wwxYwre)rSrRrfUnregisterWaitExr~r7rhrirr8r9r{ _wait_cancelrcrrjs r#rkz"_WaitHandleFuture._unregister_waits  ''     ( (dkk B..55dkk6:6N6NP ||{;;;E!$" ))262H2HG./ 11':< s A?? C0AC++C0)rIrJrKrrcrkrLrMs@r#ryrysBF)$Pr$ryc0eZdZ dZdZdZdZdZeZy) PipeServerc||_tj|_d|_d|_|j d|_yNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)r r,s r#rzPipeServer.__init__s; &0 #' --d3 r$cL|j|jdc}|_|SNF)rr)r tmps r#_get_unconnected_pipez PipeServer._get_unconnected_pipes% **d&>&>u&ETZ r$c ,|jrytjtjz}|r|tjz}tj |j |tjtjztjztjtjtjtjtj}tj|}|j j#||SrB)closedrXPIPE_ACCESS_DUPLEXFILE_FLAG_OVERLAPPEDFILE_FLAG_FIRST_PIPE_INSTANCECreateNamedPiperPIPE_TYPE_MESSAGEPIPE_READMODE_MESSAGE PIPE_WAITPIPE_UNLIMITED_INSTANCESr BUFSIZENMPWAIT_WAIT_FOREVERNULL PipeHandleradd)r firstflagshpipes r#rzPipeServer._server_pipe_handles ;;=**W-I-II  W:: :E  # # MM5  % %(E(E E      , ,  ! !=#8#8  ( (',,  8''*   & r$c|jduSrB)rr[s r#rzPipeServer.closed s %&r$c |j!|jjd|_|jJ|jD]}|j d|_d|_|jj yyrB)rr6rrcloserclear)r rs r#rzPipeServer.close#sp  # # /  $ $ + + -'+D $ == $,, -DJ DM  & & ( %r$N) rIrJrKrrrrr__del__r$r#rrs'4$' )Gr$rc eZdZy)_WindowsSelectorEventLoopN)rIrJrKrr$r#rr2s1r$rcBeZdZ dfd ZfdZdZdZ ddZxZS)rc<| t}t| |yrB)rrr)r rr"s r#rzProactorEventLoop.__init__9s  #~H "r$c |j|jt| |ja|jj }|jj |'|js|jj|d|_yy#|ja|jj }|jj |'|js|jj|d|_wwxYwrB) call_soon_loop_self_readingr run_forever_self_reading_futurerr6r&r{r)r r!r"s r#rzProactorEventLoop.run_forever>s 1 NN422 3 G  !((4..22))002>"**NN..r2,0)5t((4..22))002>"**NN..r2,0)5s )BA/D cK|jj|}|d{}|}|j||d|i}||fS7%w)Naddrextra)r{ connect_pipe_make_duplex_pipe_transport)r protocol_factoryr,frprotocoltranss r#create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ NN ' ' 0w#%00x8>7H1Jh s!A A &A cfKtdfd jgSw)NcJd} |ri|j}jj|jr|j y}j ||dij }|yjj|}|_ |jy#t$r9|r#|jdk7r|j jYyt$rz}|r9|jdk7r&jd||d|j n$j rt#j$d|djYd}~yd}~wt&j($r|r|j YyYywxYw) NrrrzPipe accept failed)r2r3rzAccept pipe failed on pipe %rT)exc_info)rHrdiscardrrrrr{ accept_piperadd_done_callbackBrokenPipeErrorfilenorr7r9_debugrwarningr CancelledError) rrrr:r,loop_accept_piperr servers r#rz>ProactorEventLoop.start_serving_pipe..loop_accept_pipe\stD) 688:D**2248}} /1H44hvw.?5A335<NN..t4*./*##$45+# 1DKKMR/JJL/0 1DKKMR///#7%( $1 JJL[[NN#B#'$8/00,, !JJL !s1A B7/B7B77?F"8F"A0E55(F"!F"rB)rr)r rr,rrs```@@r#start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2G$+ 6+ 6Z '(xs*1c K|j} t||||||||f| |d| } | d{| S7#ttf$rt$r+| j | j d{7wxYww)N)waiterr) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionr_wait) r rargsshellstdinstdoutstderrbufsizerkwargsrtransps r#_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transports##%,T8T5-2FFG74:%7067 LL  -.    LLN,,.  s1'A>868A>8;A;3A64A;;A>rB) rIrJrKrrrrrrLrMs@r#rr6s%<# 1&1j04r$rceZdZ efdZdZdZdZd dZdZ e dZ e d Z d!d Zd!d Zd!d Zd!d Zd"dZd!dZdZdZdZdZdZd dZdZdZdZdZdZdZd dZ dZ!dZ"dZ#y)#rcd|_g|_tjtjt d||_i|_tj|_ g|_ tj|_ yrW) r8_resultsrfCreateIoCompletionPortINVALID_HANDLE_VALUEr_iocp_cacherrrS _unregistered_stopped_serving)r concurrencys r#rzIocpProactor.__init__s_   77  , ,dA{D  "??, ' 1r$c2|j tdy)NzIocpProactor is closed)rrur[s r# _check_closedzIocpProactor._check_closeds :: 78 8 r$cdt|jzdt|jzg}|j|j dd|j j ddj|dS)Nzoverlapped#=%sz result#=%sr< r))lenrrrr`r"rIjoin)r r.s r#__repr__zIocpProactor.__repr__s_ 3t{{#33s4==113 ::  KK ! NN33SXXd^DDr$c||_yrB)r8)r rs r#set_loopzIocpProactor.set_loops  r$Ncz|js|j||j}g|_ |d}S#d}wxYwrB)rr\)r timeoutrs r#selectzIocpProactor.selects:}} JJw mm  C$Cs6:c\|jj}|j||SrB)r8rrF)r valuerbs r#_resultzIocpProactor._results%jj&&( u r$c |jS#t$rD}|jtjtj fvrt |jd}~wwxYwrB) getresultr7rhrfERROR_NETNAME_DELETEDERROR_OPERATION_ABORTEDConnectionResetErrorr)rkeyr!r:s r#finish_socket_funczIocpProactor.finish_socket_funcsY <<> ! || A A + C C EE*CHH55  s A?AAc |j|||S#t$r,}|jtjk(r |dfcYd}~Sd}~wwxYwrB)rr7rhrfERROR_PORT_UNREACHABLE)clsrrr! empty_resultr:s r#_finish_recvfromzIocpProactor._finish_recvfromsN ))%b9 9 ||{AAA#T))  s A  AA AA c|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYw)Nr$) _register_with_iocprf Overlappedr isinstancesocketWSARecvrReadFilerr _registerrr connnbytesrr!s r#recvzIocpProactor.recvs   &  # #D ) %$ . 4;;=&%8 DKKM62~~b$(?(?@@ %<<$ $ %AB%%CCc|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYwrW) r rfr rr r  WSARecvIntor ReadFileIntorrrrr rbufrr!s r# recv_intozIocpProactor.recv_intos   &  # #D ) #$ .t{{}c59 s3~~b$(?(?@@ #<<? " #rc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)N)r$Nr$r) r rfr r WSARecvFromrrrrrrrs r#recvfromzIocpProactor.recvfroms   &  # #D ) - NN4;;=&% 8~~b$0E0E=@)BC C -<< , , -!A55BBc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)NrNrr) r rfr rWSARecvFromIntorrrrrrrs r# recvfrom_intozIocpProactor.recvfrom_intos   &  # #D ) +   t{{}c5 9~~b$0E0E=>)@A A +<< * * +rc|j|tjt}|j |j ||||j |||jSrB)r rfr r WSASendTorrr)r rrrrr!s r#sendtozIocpProactor.sendtosQ   &  # #D ) T[[]C5~~b$(?(?@@r$cH|j|tjt}t |t j r"|j |j||n |j|j||j|||jSrB) r rfr rr r WSASendr WriteFilerrrs r#sendzIocpProactor.sendsq   &  # #D ) dFMM * JJt{{}c5 1 LL ,~~b$(?(?@@r$c||j|jjtjt }|j jjfd}d}|j||}||}tj||j|S)Nc,|jtjdj}j t j tj|jjjfS)Nz@P) rstructpackr setsockoptr  SOL_SOCKETrfSO_UPDATE_ACCEPT_CONTEXT settimeout gettimeout getpeername)rrr!rrlisteners r# finish_acceptz*IocpProactor.accept..finish_accept*sl LLN++dHOO$56C OOF--'@@# G OOH//1 2))++ +r$cvK |d{y7#tj$r|jwxYwwrB)r rr)r4rs r# accept_coroz(IocpProactor.accept..accept_coro3s2  ,,   s 99%69r) r _get_accept_socketfamilyrfr rAcceptExrrr ensure_futurer8)r r5r!r6r8r4corors ` @r#acceptzIocpProactor.accept$s   *&&x7  # #D ) HOO%t{{}5 , Hm<64( Dtzz2 r$cjtjk(rQtjj ||j j}|jd|S|j tjj jtj"t$}|j'j |fd}|j)||S#t$r?}|jtjk7rj!ddk(rYd}~d}~wwxYw)Nrrc|jjtjtj dSrW)rr/r r0rfSO_UPDATE_CONNECT_CONTEXT)rrr!rs r#finish_connectz,IocpProactor.connect..finish_connectVs1 LLN OOF--'AA1 FKr$)typer  SOCK_DGRAMrf WSAConnectrr8rrFr  BindLocalr:r7rherrno WSAEINVAL getsocknamer r ConnectExr)r rr,rber!rBs ` r#connectzIocpProactor.connect@s 99)) )  " "4;;=' :****,C NN4 J   &   ! !$++- = # #D ) T[[]G, ~~b$77! zzU__,!!$)*  s.D E  5EE c 6|j|tjt}|dz}|dz dz}|j |j t j|j |||dd|j|||jS)Nl r) r rfr r TransmitFilermsvcrt get_osfhandlerr)r sockfileoffsetcountr! offset_low offset_highs r#sendfilezIocpProactor.sendfile_s   &  # #D )k) |{2   ,,T[[];"Kq! % ~~b$(?(?@@r$c|jtjt}|j j }|r|j Sfd}|j||S)Nc(|jSrB)r)rrr!rs r#finish_accept_pipez4IocpProactor.accept_pipe..finish_accept_pipevs LLNKr$)r rfr rConnectNamedPiperrr)r rr! connectedr[s ` r#rzIocpProactor.accept_pipeksf   &  # #D )'' 6 <<% % ~~b$(:;;r$c<Kt} tj|} tj|S#t$r(}|jtj k7rYd}~nd}~wwxYwt |dzt}tj|d{7w)N) CONNECT_PIPE_INIT_DELAYrf ConnectPiper7rhERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr r)r r,delayrTr:s r#rzIocpProactor.connect_pipe|s' $009''// <<;#>#>>?   #9:E++e$ $ $s6B6B A'A"B"A''.BBBc* |j||dSr)_wait_for_handle)r rTrs r#wait_for_handlezIocpProactor.wait_for_handles $$VWe<.finish_wait_for_handles779 r$r)rrXINFINITEmathceilrfr rRegisterWaitWithQueuerr,rpr8ryrr) r rTr _is_cancelmsr!rUrors @r#rhzIocpProactor._wait_for_handles  ?!!B7S=)B # #D )!77 DJJ B0 !"fk KA!"fk4'+zz3A  ##B' $%b!-C"D BJJr$c||jvrL|jj|tj|j |j ddyyrW)rSrrfrrrr objs r#r z IocpProactor._register_with_iocpsI d&& &     %  . .szz|TZZA N 'r$c^|jt||j}|jr |jd=|js |dd|}|j |||||f|j|j<|S#t $r}|j|Yd}~>d}~wwxYwr) rrr8rr&rFr7rCrr,)r r!rxcallbackrrrKs r#rzIocpProactor._registers  btzz 2  ##B'zz  $ tR0 U#$%b#x"8 BJJ #"" #s B B,B''B,c\ |j|jj|yrB)rrr`)r r!s r#rzIocpProactor._unregisters)  !!"%r$cRtj|}|jd|SrW)r r2)r r:ss r#r9zIocpProactor._get_accept_sockets MM& ! Qr$c "|t}n<|dkr tdtj|dz}|tk\r td t j |j |}|nd}|\}}}} |jj|\}} } } | |j vr|j#nI|j%s9 | ||| } |j'| |j(j+|d}|j0D](} |jj| j2d*|j0j5y#t$rl|jjr%|jjdd||||fzd|dtjfvrtj|Y}wxYw#t,$r7} |j/| |j(j+|Yd} ~ d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2status)rp ValueErrorrqrrrfGetQueuedCompletionStatusrrpopKeyErrorr8 get_debugr9rrXrrr6donerFrr`r7rCrr,r)r rrurerr transferredrr,rr!rxrzrrKs r#r\zIocpProactor._polls ?B q[/0 07S=)BX~ !233 ::4::rJF~B-3 *Cc7 '+{{w'?$2sH d+++ VVX $[#r:E LL'MM((+AMR$$B KKOOBJJ -%   "E ::'')JJ55%7#N&);W%E$F7q+"B"BCC'', ,,OOA&MM((++,AsC4 E G,H A1GG H,H<H HH Hc:|jj|yrB)rrrws r# _stop_servingzIocpProactor._stop_serving2s !!#&r$c4|jyt|jjD]:\}}}}|j rt |t r* |j<d}tj}||z} |jrx| tjkrCtjd|tj|z tj|z} |j!||jrxg|_t%j&|jd|_y#t$rS}|j>++ K!4>>#3j#@B>>+j8 JJz "kk DJJ' ; Czz-'C),&)# 00:=:O:OG$67 99'B CsD;; FAFFc$|jyrB)rr[s r#rzIocpProactor.__del__gs  r$rB)rr!)$rIrJrKrprrrrrr staticmethodr classmethodrrrrr#r&r*r>rLrXrrrirrhr rrr9r\rrrrr$r#rrs-#+29E     A A C AAA88> A<"0&= DO@& 7#r' -^r$rceZdZdZy)rc tj|f|||||d|_fd}jjj t jj} | j|y)N)rrrrrc\jj}j|yrB)_procpoll_process_exited)r returncoder s r#rzz4_WindowsSubprocessTransport._start..callbackrs!*J   ,r$) r Popenrr8r{riintrQr) r rrrrrrrrzrs ` r#_startz"_WindowsSubprocessTransport._startmso"(( 'U6&'%'  - JJ 0 0TZZ5G5G1H I H%r$N)rIrJrKrrr$r#rrks &r$rceZdZeZy)rN)rIrJrKr _loop_factoryrr$r#rr}%Mr$rceZdZeZy)rN)rIrJrKrrrr$r#rrrr$r)3sysplatform ImportErrorrfrXrG functoolsrrqrPr r-rrrrrr r r r r logr__all__rrpERROR_CONNECTION_REFUSEDERROR_CONNECTION_ABORTEDr`rdFuturerrOrpryobjectrBaseSelectorEventLooprBaseProactorEventLooprrBaseSubprocessTransportrrBaseDefaultEventLoopPolicyrrrrr$r#rs\4 <<7 l ##   ||    --`G#GNNG#T&-&01P-1Ph88v2 E E2g==gTHHV &/"I"I &.&V%F%F&&V%F%F&8r$__pycache__/timeouts.cpython-312.pyc000064400000017167152343231170013345 0ustar00 ֦iddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZ Gd d ejZ eGd d Zd eedefdZdeedefdZy)N) TracebackType)finalOptionalType)events) exceptions)tasks)Timeouttimeout timeout_atc eZdZdZdZdZdZdZy)_StatecreatedactiveexpiringexpiredfinishedN)__name__ __module__ __qualname__CREATEDENTEREDEXPIRINGEXPIREDEXITED)/usr/lib64/python3.12/asyncio/timeouts.pyrrsGGHG Frrc eZdZdZdeeddfdZdeefdZdeeddfdZde fdZ de fd Z dd Z d eeed eed eedee fdZddZy)r zAsynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. whenreturnNcXtj|_d|_d|_||_y)zSchedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. N)rr_state_timeout_handler_task_when)selfr!s r__init__zTimeout.__init__!s%nn >B+/  rc|jS)zReturn the current deadline.)r'r(s rr!z Timeout.when.s zzrc|jtjurJ|jtjur t dt d|jj d||_|j|jj|d|_ytj}||jkr!|j|j|_y|j||j|_y)zReschedule the timeout.zTimeout has not been enteredzCannot change state of z TimeoutN)r$rrr RuntimeErrorvaluer'r%cancelrget_running_looptime call_soon _on_timeoutcall_at)r(r!loops r reschedulezTimeout.reschedule2s ;;fnn ,{{fnn,"#ABB)$++*;*;))r$rrr'roundappendjoinr.)r(infor!info_strs r__repr__zTimeout.__repr__Msst ;;&.. (+/::+A5Q'tD KK%v '88D>DKK--.az;;rcJK|jtjur tdt j }| tdtj |_||_|jj|_ |j|j|Sw)Nz Timeout has already been enteredz$Timeout should be used inside a task) r$rrr-r current_taskrr& cancelling _cancellingr6r')r(tasks r __aenter__zTimeout.__aenter__Us} ;;fnn ,AB B!!# <EF Fnn  ::002  # sB!B#exc_typeexc_valexc_tbcK|jtjtjfvsJ|j!|jj d|_|jtjurVtj |_|jj|jkr|tjurt|y|jtjurtj|_ywN)r$rrrr%r/rr&uncancelrGr CancelledError TimeoutErrorr)r(rJrKrLs r __aexit__zTimeout.__aexit__as {{v~~v????  ,  ! ! ( ( *$(D ! ;;&// ) ..DKzz""$(8(88XIbIb=b#/[[FNN * --DKsDDc|jtjusJ|jj tj |_d|_yrN)r$rrr&r/rr%r+s rr3zTimeout._on_timeoutys;{{fnn,,, oo $r)r"r )r"N)rrr__doc__rfloatr)r!r6boolrstrrCrIr BaseExceptionrrRr3rrrr r s Xe_  huoMxM4M.@@<#< 4 ./-('  $ 0%rr delayr"crtj}t||j|zSdS)a Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. N)rr0r r1)rYr5s rr r s5  " " $D %*;499;& FF FFrr!ct|S)abSchedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. )r )r!s rr r s& 4=r)enumtypesrtypingrrrr9rr r __all__Enumrr rUr r rrrras (( TYYc%c%c%LG8E?GwG(Xe_r__pycache__/mixins.cpython-312.pyc000064400000002006152343231170012765 0ustar00 ֦iRdZddlZddlmZejZGddZy)zEvent loop mixins.N)eventsceZdZdZdZy)_LoopBoundMixinNctj}|j"t5|j||_ddd||jurt |d|S#1swY'xYw)Nz# is bound to a different event loop)r_get_running_loop_loop _global_lock RuntimeError)selfloops '/usr/lib64/python3.12/asyncio/mixins.py _get_loopz_LoopBoundMixin._get_loop sa'') :: ::%!%DJ tzz !$)LMN N s A!!A*)__name__ __module__ __qualname__r rrrr s E rr)__doc__ threadingrLockr rrrrrs&y~~   r__pycache__/base_events.cpython-312.opt-1.pyc000064400000251165152343231170014727 0ustar00 ֦i26dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlm Z ddl!m"Z"dZ#dZ$dZ%e&e dZ'dZ(dZ)dZ*dZ+d&dZ,d'dZ-dZ.e&e drdZ/ndZ/dZ0Gd d!ejbZ2Gd"d#ejfZ4Gd$d%ejjZ6y#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/lib64/python3.12/asyncio/base_events.py_format_handler Gs=   B'"j$/<BKK  6{ch|tjk(ry|tjk(ryt|S)Nzz) subprocessPIPESTDOUTr)fds r _format_piper'Ps+ 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_reuseportr2Ys` 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! a ]  s) collections OrderedDictrBlistvaluesextend itertoolschain from_iterable zip_longest) addrinfosfirst_address_family_countaddrinfos_by_familyaddrrFaddrinfos_lists reordereds r_interleave_addrinfosrds&113a , ,*,  'F#**40  .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!c.|xjdz c_yrq)rrs r_attachzServer._attach&s ar!c|xjdzc_|jdk(r|j|jyyy)Nrr)rr_wakeuprs r_detachzServer._detach*s; a    "t}}'< LLN(= "r!c||j}d|_|D]$}|jr|jd&yrP)rdoner)rwaiterswaiters rrzServer._wakeup0s3-- F;;=!!$'r!c *|jryd|_|jD]p}|j|j|jj |j ||j||j|j|jry)NT) rrlistenrr_start_servingrrrr)rr1s rrzServer._start_serving7sp ==  MMD KK & JJ % %&&d.?.?dmmT%@%@** ,"r!c|jSrP)rrs rget_loopzServer.get_loopBs zzr!c|jSrP)rrs r is_servingzServer.is_servingEs }}r!cT|jytd|jDS)NrQc3FK|]}tj|ywrP)rTransportSocket)rRss rrTz!Server.sockets..LsF 1V++A. s!)rtuplers rrzServer.socketsHs$ == F FFFr!cP|j}|yd|_|D]}|jj|d|_|j;|jj s!|jj d|_|jdk(r|jyy)NFr) rr _stop_servingrrrrrr)rrr1s rclosez Server.closeNs-- ?  D JJ $ $T *  % % 1--224  % % , , .(,D %    " LLN #r!cjK|jtjdd{y7w)Nr)rr sleeprs r start_servingzServer.start_servingas% 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_forevergs  $ $ 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)namecontextc2|j|j3tj||||}|jrM|jd=n?||j||}n|j|||}tj || |~S#~wxYw)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 , s BBcB|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_shutdownfs 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_foreverws   ++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_soon2sDxtW=  # #((, 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_thread9sB ?? " '')  ''( ( (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_threadsafeJs`  ;;  +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_executorUs  ;;  '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_executores,(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_debugjsq!"  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.getaddrinfosU ;;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$rP} d| dt | j }t | j|} |j| Yd} ~ d} ~ wwxYw7f#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/rlowererrnopop sock_connectr)rr addr_infolocal_addr_infos my_exceptionsrFtype_rH_r)r1lfamilyladdrrmrs r _connect_sockzBaseEventLoop._connect_socks  -(+4(ua# .==U%HD   U #+/?+GQ1e&(  2 %( 0@%+//11%(OyPV&WXX##D'2 2 2*. -J1#2'',ir#c(..2B1CE&cii5%,,S11 2 3    %   )- -JskE#z;BaseEventLoop.create_connection...]s$2D2D&+3r!NrQ)rRrrr rs rrTz2BaseEventLoop.create_connection..Zs' ).H)1).srrzcreate_connection failedc3:K|]}t|k(ywrPr)rRrmmodels rrTz2BaseEventLoop.create_connection..psGJSs3x50JszMultiple exceptions: {}rc32K|]}t|ywrPr)rRrms rrTz2BaseEventLoop.create_connection..us%E*3c#h*sz5host 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"rrrrrinfosrsubrmrrrr rs` @@@rcreate_connectionzBaseEventLoop.create_connectionsq(  &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&+&? ? !&(66 ). )   |-7GZc3Cc3cZG &!,-GTT:!+(m+!$JqM 2GJGG",Q-/&&?&F&F II%E*%EE'GHH | KMMyyF...!8ACC%)$E$E "C"7!5%F%77 8 ;;++H5D LL:tT9h @(""mN," ?#! ! H "&J 7sBJI4;JI7*J>I=I:I=*JJ JJ"J'A8JAJ1J2AJ7J:I== J J J  JJJJc .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_addrrFrHrr3r4rc36K|]\}}|s |d|yw)=NrQ)rRkvs rrTz9BaseEventLoop.create_datagram_endpoint..=s!$NLDAqAs!A3ZLs  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 expectedrrzcan 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) rrrr6rFrHrr3r4r1optsproblemsr_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'5D' 40E'(<==6*Q-{"B 6==)<)D)DEIIj1&,UO%/$=$?#B #$j/A{3C!DIC' *4 7CIN"+,A"BB&*&;&; f6G6G"'u4'<'A!A %")*M"NN7<3CCG#&*C"*437, 33:JsOC0 8="E&r,rwrCrr}platformrrUabcIterablerYr rWsetrZr[r\r+rGr|rwarningrBr-r. SO_REUSEADDRr@rr2rAr*r` IPV6_V6ONLYrr/rr EADDRNOTAVAILrrrGr:rrrrr)rrrDrErFrr1rrurZr3rrrrhostsfsr completedresrLsocktyperH canonnamesarMrrrs r create_serverzBaseEventLoop.create_servers8 c4 HI I ,CE E + BD D   d #  t/ NPP$ "7 2 Os||x7O GrzT3' {'?'?@$%#d11$V8=2?# % ,,++E 55e<=EI4 % C9<6B%B!%}}R5ANN4($"--v/B/BDJ"bV^^V__,M&M&t,"&//1#FN;(;(;(.(:(:(,. @ " ;!V!:?%@%$d1g%%@#CDD!  ' !(| !LMMyyF... #EdX!NOOfGD   U #g'7W&;,.   ! ! #++a. ;; KK 0 c%,"<<!;;"NN,G+-xO! !4# @#%c#hnn&6 899(;(;;#KKM JJL#{{ &s 3$%cii54? @&A! ' !(!( !sC QL'*QL,.Q1 P?L/C P M/1P? P PB(Q>P>?.Q/9M,(P+M,,P/ P8A=P5P;PPPP;;Q)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_socketRs 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_pipeps#%##%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|rrrurvs rconnect_write_pipez BaseEventLoop.connect_write_pipes#%##%33D(FK  LL ;; LL< 8 =(""   OO  rxcr|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)rrcmdr4r5r6r~r3r7rrrr8r 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)rrprogramr4r5r6r~r3r7rrrr2r8 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_listrstriprrBrrG) rr rSrgr_ log_linesrRvaluetbs rdefault_exception_handlerz'BaseEventLoop.default_exception_handlers[++i(9GKK ,  YI4K4KLHH g -$$0$$66$$66 & 'I '?C..CLE((WWY2259:F$**WWY2259:F$U    uBug. /#  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-rrGrr*rr)rr ctxthingrms rrZz$BaseEventLoop.call_exception_handler+sq,  " " * ,..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_callbackss"  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_signalsafexs 6" r!cH|jr|xjdz c_yy)z3Notification that a TimerHandle has been cancelled.rN)rrrs r_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s!     ' '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_runrrrfr ) r sched_count new_scheduledrrjrr=end_timentodoirrs rrzBaseEventLoop._run_onces$//* 6 6  ' '+ 55 6M//$$(-F%!((0 * 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 uA[[((*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$r2rVr+r:rrYr? AI_PASSIVErqrsrwrzr}r#r$rrrrrrZrrrrr{rrrQr!rrrs/< ))-d4 %""%)$" 9=" $t"&!%!% "CG" @D(," AE)-"04" ""7DG "20DK40$L*.%MM - :>06:$26&%("=A 5 * 2"#!1H7 A(, A./4*).X59Q#14T"&!%!%$Q#j*/"&!% #8-<#'-<^1"4%*(,.2-1 .+bEID#./q267;$ D#N'(f.@.@%&a D59K####"&!%K^"&!% #<# # %&0__&0oo&0oo27%)1(,T "#J%/OOJOO%/__$)1'+Dt #D' *"0>dF0P'  - N` :Tr!r)rr)r)7__doc__rUcollections.abcconcurrent.futuresrrrrZrCr+rAr#rfrrr}rLrru ImportErrorr5rrrrrr r r r r rrlogr__all__rrr*rArr r'r2rMrdrnrrrwProtocolryAbstractServerrAbstractEventLooprrQr!rrs-      $ #),% FJ ' #J8v," 6=!G  > A) 2 2A)HBV " "BJPTF,,PTk  CsDDD__pycache__/__main__.cpython-312.opt-1.pyc000064400000012521152343231170014140 0ustar00 ֦i jddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z GddejZGddejZedk(rej$d ej&Zej*ed eiZd D]Zeeee<eeeZdad a ddlZeZd e_ejA ejCyy#e$rY9wxYw#e"$r3t4r*t4jGst4jId aYVwxYw)N)futuresc$eZdZfdZdZxZS)AsyncIOInteractiveConsolect|||jjxjt j zc_||_tj|_ y)N) super__init__compilecompilerflagsastPyCF_ALLOW_TOP_LEVEL_AWAITloop contextvars copy_contextcontext)selflocalsr __class__s )/usr/lib64/python3.12/asyncio/__main__.pyr z"AsyncIOInteractiveConsole.__init__sH   ##s'E'EE# "//1 c8tjjfd}tj |j  j S#t$rt$r,trjdYyjYywxYw)Nc&dadatjj} |}tj|sj|y jj|jatj ty#t $rt $r}daj|Yd}~yd}~wt$r}j|Yd}~yd}~wwxYw#t$r}j|Yd}~yd}~wwxYw)NFTr) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterrupt set_exception BaseExceptioninspect iscoroutine set_resultr create_taskrr _chain_future)funccoroexexccodefuturers rcallbackz3AsyncIOInteractiveConsole.runcode..callbacksK&+ #%%dDKK8D v&&t,!!$' *"ii33D$,,3O %%k6:! $ *.'$$R(  $$R( ! *$$S)) *s<BAC,C)*C C)C$$C), D5D  Drz KeyboardInterrupt ) concurrentrFuturercall_soon_threadsaferresultrr"rwrite showtraceback)rr,r.r-s`` @rruncodez!AsyncIOInteractiveConsole.runcodes|##**, *< !!(DLL!A %==? "   %& 23""$  %s A)BBB)__name__ __module__ __qualname__r r5 __classcell__)rs@rrrs 2 +%rrceZdZdZy) REPLThreadc  dtjdtjdttddd}tj |dt jd d t tjtjy#t jd d t tjtjwxYw) Nz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. ps1z>>> zimport asynciozexiting asyncio REPL...)bannerexitmsgignorez ^coroutine .* was never awaited$)messagecategory) sysversionplatformgetattrconsoleinteractwarningsfilterwarningsRuntimeWarningrr1stop)rr>s rrunzREPLThread.runGs 1 }D?*3v./~ ?    1  3  # #;' )  % %dii 0  # #;' )  % %dii 0s ABACN)r6r7r8rMrrr;r;Es1rr;__main__zcpython.run_stdinasyncio>__file__r6__spec__ __loader__ __package__ __builtins__FT)%r rPr,concurrent.futuresr/rr#rC threadingrrIrInteractiveConsolerThreadr;r6auditnew_event_looprset_event_loop repl_localskeyrrGrrreadline ImportError repl_threaddaemonstart run_foreverr donecancelrNrrrhsP    3% 7 73%l1!!10 z CII!" !7 ! ! #DG4 g&K,"8C= C, ( T:GK# ,KK       G&    ! ;#3#3#5""$*.'   s$9C/C:/C76C7:5D21D2__pycache__/base_subprocess.cpython-312.opt-1.pyc000064400000037003152343231170015604 0ustar00 ֦i"ddlZddlZddlZddlmZddlmZddlmZGddejZ Gdd ejZ Gd d e ejZ y) N) protocols) transports)loggerceZdZ dfd ZdZdZdZdZdZdZ e jfdZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZxZS)BaseSubprocessTransportc nt || d|_||_||_d|_d|_d|_g|_tj|_ i|_ d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d| |j j$|_|j |j&d<|jj)r?t+|t,t.fr|} n|d} t1j2d| |j |jj5|j7| y#|j#xYw) NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepid_extra get_debug isinstancebytesstrrdebug create_task_connect_pipes)selfloopprotocolr r r rrrwaiterextrakwargsprogram __class__s 0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__ sx  !   )//1  JOO #!DKKN Z__ $!DKKN Z__ $!DKKN  DKK BTeF%w B:@ B JJNN $(JJ L! ::   !$ -q' LL5 $)) - t226:;  JJL s F!!F4c^|jjg}|jr|jd|j|jd|j|j |jd|j n/|j|jdn|jd|j jd}||jd|j|j jd}|j jd }|#||ur|jd |jn@||jd |j||jd |jd jdj|S)Nclosedzpid=z returncode=runningz not startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}> ) r4__name__rappendrrrgetpipeformatjoin)r-infor rrs r5__repr__z BaseSubprocessTransport.__repr__7sX''( << KK ! 99 KK$tyyk* +    ' KK+d&6&6%78 9 YY " KK " KK & "   KK& - .##  &F"2 KK. 6 7! gfkk]34! gfkk]34}}SXXd^,,c tN)NotImplementedError)r-r r r rrrr2s r5r"zBaseSubprocessTransport._startTs!!rBc||_yrDr)r-r/s r5 set_protocolz$BaseSubprocessTransport.set_protocolWs !rBc|jSrDrGr-s r5 get_protocolz$BaseSubprocessTransport.get_protocolZs ~~rBc|jSrD)rrJs r5 is_closingz"BaseSubprocessTransport.is_closing]s ||rBc|jryd|_|jjD]}||jj !|j t|j g|j jL|jjrtjd| |j jyyyy#t$rYywxYw)NTz$Close running child process: kill %r)rrvaluesr=r#rrpollrr&rwarningkillProcessLookupError)r-protos r5r#zBaseSubprocessTransport.close`s <<  [['')E} JJ   * JJ "  ( !)zz##%EtL  ! *) #&  s4C CCcb|js#|d|t||jyy)Nzunclosed transport )source)rResourceWarningr#)r-_warns r5__del__zBaseSubprocessTransport.__del__{s+|| 'x0/$ O JJLrBc|jSrD)rrJs r5get_pidzBaseSubprocessTransport.get_pids yyrBc|jSrD)rrJs r5get_returncodez&BaseSubprocessTransport.get_returncodesrBcR||jvr|j|jSyrD)rr=)r-fds r5get_pipe_transportz*BaseSubprocessTransport.get_pipe_transports%  ;;r?'' 'rBc0|j tyrD)rrSrJs r5 _check_procz#BaseSubprocessTransport._check_procs :: $& & rBcZ|j|jj|yrD)rbr send_signal)r-signals r5rdz#BaseSubprocessTransport.send_signals   v&rBcX|j|jjyrD)rbr terminaterJs r5rgz!BaseSubprocessTransport.terminates  rBcX|j|jjyrD)rbrrRrJs r5rRzBaseSubprocessTransport.kills  rBcK j}j}|j9|jfd|jd{\}}|jd<|j 9|j fd|j d{\}}|jd<|j9|j fd|jd{\}}|jd<|jjjjD]\}}|j|g|d_ |#|js|jdyyy777#ttf$rt $r7}|+|js|j#|Yd}~yYd}~yYd}~yd}~wwxYww)NctdS)Nr)WriteSubprocessPipeProtorJsr5z8BaseSubprocessTransport._connect_pipes..s 4T1=rBrctdS)NrReadSubprocessPipeProtorJsr5rlz8BaseSubprocessTransport._connect_pipes.. 3D!.rprBr )rrr connect_write_piperrconnect_read_piper call_soonrconnection_mader cancelled set_result SystemExitKeyboardInterrupt BaseException set_exception) r-r0procr._r=callbackdataexcs ` r5r,z&BaseSubprocessTransport._connect_pipess# (::D::Dzz% $ 7 7=JJ!  4"& A{{& $ 6 6<KK!!!4"& A{{& $ 6 6<KK!!!4"& A NN4>>994 @"&"5"5$x/$/#6"&D !&*:*:*<!!$'+=!; ! !-.   *!&*:*:*<$$S))+=! *shF?AE- E& AE-E)AE-E+A*E-&F?&E-)E-+E--F<#F7(F?7F<<F?c|j|jj||fy|jj|g|yrD)rr;rrt)r-cbrs r5_callzBaseSubprocessTransport._calls?    *    & &Dz 2 DJJ  +d +rBcr|j|jj|||jyrD)rrpipe_connection_lost _try_finish)r-r_rs r5_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_losts( 4>>66C@ rBcR|j|jj||yrD)rrpipe_data_received)r-r_rs r5_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_receiveds 4>>44b$?rBc,|jjrtjd||||_|j j ||j _|j|jj|jy)Nz%r exited with return code %r) rr&rr@rr returncoderrprocess_exitedr)r-rs r5_process_exitedz'BaseSubprocessTransport._process_exitedsm ::   ! KK7z J% :: (%/DJJ ! 4>>001 rBcK|j |jS|jj}|jj ||d{S7w)zdWait until the process exit and return the process return code. This method is a coroutine.N)rr create_futurerr;)r-r0s r5_waitzBaseSubprocessTransport._waitsP    '## #))+ !!&)||sAAAAc|jytd|jjDr$d|_|j |j dyy)Nc3@K|]}|duxr |jywrD) disconnected).0ps r5 z6BaseSubprocessTransport._try_finish..s(.,1}//,sT)rallrrOr r_call_connection_lostrJs r5rz#BaseSubprocessTransport._try_finishsS    #  . **,. .!DN JJt114 8 .rBc |jj||jD].}|jr|j |j 0d|_d|_d|_d|_y#|jD].}|jr|j |j 0d|_d|_d|_d|_wxYwrD)rconnection_lostrrvrwrrr)r-rr0s r5rz-BaseSubprocessTransport._call_connection_losts " NN * *3 /,,'')%%d&6&67-"&D DJDJ!DN ,,'')%%d&6&67-"&D DJDJ!DNsA77 C:C)NN)r: __module__ __qualname__rrAr"rHrKrMr#warningswarnrYr[r]r`rbrdrgrRr,rrrrrrr __classcell__)r4s@r5rr s%)))r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s04>>**+4ytyym1MMrBcld|_|jj|j|d|_y)NT)rr|rr_)r-rs r5rz(WriteSubprocessPipeProto.connection_lost s)  ''5 rBcL|jjjyrD)r|r pause_writingrJs r5rz&WriteSubprocessPipeProto.pause_writings ))+rBcL|jjjyrD)r|rresume_writingrJs r5rz'WriteSubprocessPipeProto.resume_writings **,rBN) r:rrrrurArrrrrBr5rkrks!" N ,-rBrkceZdZdZy)rocP|jj|j|yrD)r|rr_)r-rs r5 data_receivedz%ReadSubprocessPipeProto.data_receiveds %%dggt4rBN)r:rrrrrBr5roros5rBro)rrrrrlogrSubprocessTransportr BaseProtocolrkProtocolrorrBr5rsTr"j<<r"j-y55-456'005rB__pycache__/runners.cpython-312.pyc000064400000023410152343231170013154 0ustar00 ֦i>dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z Gd d ejZ Gd d Zddd dZdZy))RunnerrunN) coroutines)events) exceptions)tasks) constantsceZdZdZdZdZy)_Statecreated initializedclosedN)__name__ __module__ __qualname__CREATED INITIALIZEDCLOSED(/usr/lib64/python3.12/asyncio/runners.pyr r sGK Frr cNeZdZdZddddZdZdZdZdZdd d Z d Z d Z y) ra5A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. Ndebug loop_factoryctj|_||_||_d|_d|_d|_d|_y)NrF) r r_state_debug _loop_factory_loop_context_interrupt_count_set_event_loop)selfrrs r__init__zRunner.__init__0s:nn  )  !$rc&|j|SN) _lazy_initr%s r __enter__zRunner.__enter__9s  rc$|jyr()close)r%exc_typeexc_valexc_tbs r__exit__zRunner.__exit__=s  rcF|jtjury |j}t ||j |j |j |jtj|jrtjd|jd|_tj|_y#|jrtjdjd|_tj|_wxYw)zShutdown and close event loop.N)rr rr!_cancel_all_tasksrun_until_completeshutdown_asyncgensshutdown_default_executorr THREAD_JOIN_TIMEOUTr$rset_event_loopr-r)r%loops rr-z Runner.close@s ;;f00 0  (::D d #  # #D$;$;$= >  # #..y/L/LM O##%%d+ JJLDJ --DK ##%%d+ JJLDJ --DKs A$CAD c:|j|jS)zReturn embedded event loop.)r)r!r*s rget_loopzRunner.get_loopQs zzrcontextctj|stdj|t j t d|j| |j}|jj||}tjtjurztjtj tj"urGt%j&|j(|} tjtj |nd}d|_ |jj-||Ytjtj |ur3tjtj tj"SSS#t$rd}YwxYw#t.j0$r4|j*dkDr#t3|dd}||dk(r t5wxYw#|Ytjtj |ur3tjtj tj"wwwxYw)z/Run a coroutine inside the embedded event loop.z"a coroutine was expected, got {!r}Nz7Runner.run() cannot be called from a running event loopr<) main_taskruncancel)r iscoroutine ValueErrorformatr_get_running_loop RuntimeErrorr)r"r! create_task threadingcurrent_thread main_threadsignal getsignalSIGINTdefault_int_handler functoolspartial _on_sigintr#r4rCancelledErrorgetattrKeyboardInterrupt)r%coror=tasksigint_handlerr@s rrz Runner.runVs%%d+AHHNO O  # # % 1IK K  ?mmGzz%%dG%<  $ $ &)*?*?*A A  /63M3MM&..t$ON & fmm^<"N ! I::006*$$V]]3~E fmmV-G-GHF+% &"&  &(( $$q("4T:'HJ!O+--   *$$V]]3~E fmmV-G-GHF+s,$F,6F=, F:9F:=AHHAI$c$|jtjur td|jtjury|j Lt j|_|jsz#Runner._on_sigint..sDr)r#donecancelr!call_soon_threadsaferS)r%signumframer?s rrPzRunner._on_sigintsT "  A %inn.>     JJ + +L 9 !!r) rrr__doc__r&r+r1r-r;rr)rPrrrrrs=6!%4%(" $(+IZ)&"rrrctj tdt||5}|j |cdddS#1swYyxYw)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopr)rrDrErr)mainrrrunners rrrsK:!- FH H e, 76zz$ 8 7 7s AAcBtj|}|sy|D]}|j|jtj|ddi|D]G}|j r|j %|jd|j |dIy)Nreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)message exceptionrU)r all_tasksr`r4gather cancelledrkcall_exception_handler)r9 to_cancelrUs rr3r3s%I   ELL)LtLM >>   >>  '  ' 'N!^^-)  r)__all__rZenumrNrGrJrrrr r Enumr rrr3rrrrusW   TYY I"I"X$# Lr__pycache__/log.cpython-312.pyc000064400000000433152343231170012241 0ustar00 ֦i|4dZddlZejeZy)zLogging configuration.N)__doc__logging getLogger __package__logger$/usr/lib64/python3.12/asyncio/log.pyr s   ; 'r __pycache__/base_futures.cpython-312.opt-1.pyc000064400000006020152343231170015104 0ustar00 ֦ihdZddlZddlmZdZdZdZdZd Zd Z ejd Z y) N)format_helpersPENDING CANCELLEDFINISHEDcNt|jdxr|jduS)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r )objs -/usr/lib64/python3.12/asyncio/base_futures.pyisfuturer s+ CMM#= > 5  ( ( 46c t|}|sd}d}|dk(r||dd}nc|dk(r+dj||dd||dd}n3|dkDr.dj||dd|dz ||dd}d |d S) #helper function for Future.__repr__c.tj|dS)Nr)r_format_callback_source)callbacks r format_cbz$_format_callbacks..format_cbs55hCCrrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizers r_format_callbacksrs r7D  D qy r!uQx   __Yr!uQx0)BqE!H2E F  ' ' "Q%((;(,q(1"R&)(<>"Q<rc|jjg}|jtk(r^|j|j d|jn3t j |j}|j d||jr$|j t|j|jr,|jd}|j d|dd|d|S)rz exception=zresult=rz created at r:r) _statelower _FINISHED _exceptionappendreprlibrepr_result _callbacksr_source_traceback)futureinforesultframes r_future_repr_infor0,s MM   ! "D }} !    ( KK*V%6%6$9: ;\\&..1F KK'&* +  %f&7&789 ((, k%(1U1XJ78 Krcpdjt|}d|jjd|dS)N <>)joinr0r __name__)r,r-s r _future_reprr7@s8 88%f- .D v(()4& 22r) __all__r'rr_PENDING _CANCELLEDr$rrr0recursive_reprr7rrrr<sO     6((33r__pycache__/selector_events.cpython-312.pyc000064400000173530152343231170014675 0ustar00 ֦i̼dZdZddlZddlZddlZddlZddlZddlZddlZddl 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 0/usr/lib64/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_connectionsXwA" )![[] 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*c t||d|_|j%|jj t dyy#d|_|j%|jj t dwwxYw)NzConnection is closed by peer)rr_rzrwrConnectionError)r)rr"s rr_z._SelectorSocketTransport._call_connection_losts E G )# . $D !!-""00#$BCE.!%D !!-""00#$BCE.s A :Bc|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*c0d|_t| yr/)rurrJrKs 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 )E""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#--_4DZ1Zzl1!3Z5Q5Ql1Y% C$  s#C&:C3&C0/C03C=<C=__pycache__/taskgroups.cpython-312.opt-1.pyc000064400000020233152343231170014621 0ustar00 ֦iW%@dZddlmZddlmZddlmZGddZy)) TaskGroup)events) exceptions)taskscXeZdZdZdZdZdZdZdZdddd Z d e d e fd Z d Z dZy)ra9Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. cd|_d|_d|_d|_d|_d|_t |_g|_d|_ d|_ y)NF) _entered_exiting _aborting_loop _parent_task_parent_cancel_requestedset_tasks_errors _base_error_on_completed_futselfs +/usr/lib64/python3.12/asyncio/taskgroups.py__init__zTaskGroup.__init__sN    (-%e  !%cxdg}|jr'|jdt|j|jr'|jdt|j|jr|jdn|j r|jddj |}d|dS) Nztasks=zerrors= cancellingentered z )rappendlenrr r join)rinfoinfo_strs r__repr__zTaskGroup.__repr__(st ;; KK&T[[!1 23 4 << KK'#dll"3!45 6 >> KK % ]] KK "88D>H:Q''rcK|jrtd|d|jtj|_t j |j|_|jtd|dd|_|Sw)N TaskGroup z has already been enteredz! cannot determine the parent taskT)r RuntimeErrorr rget_running_loopr current_taskr rs r __aenter__zTaskGroup.__aenter__6s ==TH$=>@ @ :: 002DJ!..tzz:    $TH$EFH H  sB B cKd} |j||d{d|_d|_d|_d}S7#d|_d|_d|_d}wxYwwN)_aexitr rr)retexctbs r __aexit__zTaskGroup.__aexit__Dsc  R-- !%D DL#D C. !%D DL#D Cs%A979A9AAcKd|_|$|j|r|j||_|tjur|nd}|j r|j jdk(rd}||js|j|jrT|j|jj|_ |jd{d|_ |jrT|j |j |r|js |d}|-|tjur|jj||jr t!d|jdy7#tj$r(}|js|}|jYd}~d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYww)NTzunhandled errors in a TaskGroup)r _is_base_errorrrCancelledErrorrr uncancelr _abortrrr create_futurerrBaseExceptionGroup)rr.r/propagate_cancellation_errorexs rr-zTaskGroup._aexitRs O##C(  ("D 222C %  ( (  ))+q004, >>> kk%%-)-)A)A)C& ",,,,&*D "'kk.    ' &&&  0+DLL66,0 ( >b (A(AA LL   $ << (5LL M-,, "~~460KKM "*C+/ (sCG E2E0E2G / G < F0 F>F7=G G/G 0E22F-F(#G (F--G 0F44G 7F;;F>>GG G  G N)namecontextc|jstd|d|jr|jstd|d|jrtd|d||j j |}n|j j ||}tj|||jj||j|j |~S#~wxYw)zbCreate a new task in this group and return it. Similar to `asyncio.create_task`. r&z has not been enteredz is finishedz is shutting down)r=) r r'r rr r create_taskr_set_task_nameaddadd_done_callback _on_task_done)rcoror<r=tasks rr?zTaskGroup.create_tasks }}D83HIJ J ==D8<@A A >>D83DEF F ?::))$/D::))$)@D T4(  t112 s &C))C,r/returnc.t|ttfSr,) isinstance SystemExitKeyboardInterrupt)rr/s rr4zTaskGroup._is_base_errors# ,=>??rcvd|_|jD]#}|jr|j%y)NT)r rdonecancel)rts rr7zTaskGroup._aborts)A668 rc|jj||jA|js5|jjs|jj d|j ry|j }|y|jj||j|r|j||_ |jjr1|jjd|d|jd||dy|js?|js2|j!d|_|jj#yyy)NTzTask z% has errored out but its parent task z is already completed)message exceptionrE)rdiscardrrL set_result cancelledrQrrr4rr r call_exception_handlerr rr7rM)rrEr/s rrCzTaskGroup._on_task_dones3 D!  ! ! -dkk))..0&&11$7 >>  nn ;  C   s #(8(8(@"D     ! ! # JJ - -"4(+##'#4#4"55JL  /  ~~d&C&C& KKM,0D )    $ $ &+'D~r)__name__ __module__ __qualname____doc__rr$r*r1r-r? BaseExceptionboolr4r7rCrrrr sO & (  Wt)-dF@-@D@2'rrN)__all__rrrrrr\rrr^s! @'@'r__pycache__/taskgroups.cpython-312.pyc000064400000020374152343231170013670 0ustar00 ֦iW%@dZddlmZddlmZddlmZGddZy)) TaskGroup)events) exceptions)taskscXeZdZdZdZdZdZdZdZdddd Z d e d e fd Z d Z dZy)ra9Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. cd|_d|_d|_d|_d|_d|_t |_g|_d|_ d|_ y)NF) _entered_exiting _aborting_loop _parent_task_parent_cancel_requestedset_tasks_errors _base_error_on_completed_futselfs +/usr/lib64/python3.12/asyncio/taskgroups.py__init__zTaskGroup.__init__sN    (-%e  !%cxdg}|jr'|jdt|j|jr'|jdt|j|jr|jdn|j r|jddj |}d|dS) Nztasks=zerrors= cancellingentered z )rappendlenrr r join)rinfoinfo_strs r__repr__zTaskGroup.__repr__(st ;; KK&T[[!1 23 4 << KK'#dll"3!45 6 >> KK % ]] KK "88D>H:Q''rcK|jrtd|d|jtj|_t j |j|_|jtd|dd|_|Sw)N TaskGroup z has already been enteredz! cannot determine the parent taskT)r RuntimeErrorr rget_running_loopr current_taskr rs r __aenter__zTaskGroup.__aenter__6s ==TH$=>@ @ :: 002DJ!..tzz:    $TH$EFH H  sB B cKd} |j||d{d|_d|_d|_d}S7#d|_d|_d|_d}wxYwwN)_aexitr rr)retexctbs r __aexit__zTaskGroup.__aexit__Dsc  R-- !%D DL#D C. !%D DL#D Cs%A979A9AAcKd|_|$|j|r|j||_|tjur|nd}|j r|j jdk(rd}||js|j|jrT|j|jj|_ |jd{d|_ |jrT|jrJ|j |j |r|js |d}|-|tjur|jj||jr t!d|jdy7#tj$r(}|js|}|jYd}~d}~wwxYw#d}wxYw#d}wxYw#d}wxYw#d}wxYww)NTzunhandled errors in a TaskGroup)r _is_base_errorrrCancelledErrorrr uncancelr _abortrrr create_futurerrBaseExceptionGroup)rr.r/propagate_cancellation_errorexs rr-zTaskGroup._aexitRs O##C(  ("D 222C %  ( (  ))+q004, >>> kk%%-)-)A)A)C& ",,,,&*D "'kk*;;    ' &&&  0+DLL66,0 ( >b (A(AA LL   $ << (5LL M-,, "~~460KKM "*C+/ (sCGFE>FG/G F>G &G(=G&G=G>FF;F61G6F;;G>GGG  G GGGGN)namecontextc|jstd|d|jr|jstd|d|jrtd|d||j j |}n|j j ||}tj|||jj||j|j |~S#~wxYw)zbCreate a new task in this group and return it. Similar to `asyncio.create_task`. r&z has not been enteredz is finishedz is shutting down)r=) r r'r rr r create_taskr_set_task_nameaddadd_done_callback _on_task_done)rcoror<r=tasks rr?zTaskGroup.create_tasks }}D83HIJ J ==D8<@A A >>D83DEF F ?::))$/D::))$)@D T4(  t112 s &C))C,r/returncRt|tsJt|ttfSr,) isinstance BaseException SystemExitKeyboardInterrupt)rr/s rr4zTaskGroup._is_base_errors%#}---# ,=>??rcvd|_|jD]#}|jr|j%y)NT)r rdonecancel)rts rr7zTaskGroup._aborts)A668 rc|jj||jA|js5|jjs|jj d|j ry|j }|y|jj||j|r|j||_ |jjr1|jjd|d|jd||dy|js?|js2|j!d|_|jj#yyy)NTzTask z% has errored out but its parent task z is already completed)message exceptionrE)rdiscardrrM set_result cancelledrRrrr4rr r call_exception_handlerr rr7rN)rrEr/s rrCzTaskGroup._on_task_dones3 D!  ! ! -dkk))..0&&11$7 >>  nn ;  C   s #(8(8(@"D     ! ! # JJ - -"4(+##'#4#4"55JL  /  ~~d&C&C& KKM,0D )    $ $ &+'D~r)__name__ __module__ __qualname____doc__rr$r*r1r-r?rIboolr4r7rCrrrr sO & (  Wt)-dF@-@D@2'rrN)__all__rrrrrr\rrr^s! @'@'r__pycache__/exceptions.cpython-312.opt-1.pyc000064400000006013152343231170014600 0ustar00 ֦idZdZGddeZeZGddeZGddeZGdd e Z Gd d eZ Gd d eZ y)zasyncio exceptions.)BrokenBarrierErrorCancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorceZdZdZy)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__+/usr/lib64/python3.12/asyncio/exceptions.pyrr s+rrceZdZdZy)rz+The operation is not allowed in this state.Nr rrrrrs5rrceZdZdZy)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nr rrrrrsrrc(eZdZdZfdZdZxZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) c||dn t|}t| t|d|d||_||_y)N undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrr r_expected __class__s rrzIncompleteReadError.__init__$sE$,$4[$x.  CL>)C&<8 9   rcHt||j|jffSN)typerrrs r __reduce__zIncompleteReadError.__reduce__+sDzDLL$--888rr r r rrr$ __classcell__rs@rrrs !9rrc(eZdZdZfdZdZxZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. c2t||||_yr!)rrconsumed)rmessager*rs rrzLimitOverrunError.__init__5s !  rcNt||jd|jffS)N)r"argsr*r#s rr$zLimitOverrunError.__reduce__9s"DzDIIaL$--888rr%r's@rrr/s !9rrceZdZdZy)rz*Barrier is broken by barrier.abort() call.Nr rrrrr=s4rrN) r__all__ BaseExceptionrr Exceptionr RuntimeErrorrEOFErrorrrrrrrr5s^ ( ,], 6 6 9(9$ 9 955r__pycache__/base_tasks.cpython-312.opt-1.pyc000064400000007760152343231170014550 0ustar00 ֦ip tddlZddlZddlZddlmZddlmZdZejdZdZ dZ y) N) base_futures) coroutinesctj|}|jr|jsd|d<|j dd|j z|j |j dd|j |jr5tj|j}|j dd|d|S) N cancellingrrzname=%rz wait_for=zcoro=<>) r_future_repr_infordoneinsertget_name _fut_waiter_coror_format_coroutine)taskinfocoros +/usr/lib64/python3.12/asyncio/base_tasks.py_task_repr_infor s  ) )$ /D QKK9t}}./ # A4#3#3"678 zz++DJJ7 AvQ'( Kcpdjt|}d|jjd|dS)N >zz 7 " KK !   *  61;;?xt<=) //C  dX&T2  th&?@tL 4(";<4H d3 33CMM3GD $Tr *Hr) r:reprlibr?r1rrrrecursive_reprrr.rJrrrNsC&11 F+r__pycache__/windows_events.cpython-312.pyc000064400000121065152343231170014543 0ustar00 ֦iKdZddlZejdk7redddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZdZej6Zej8ZdZdZdZdZ GddejBZ"GddejBZ#Gdde#Z$Gdde#Z%Gdde&Z'Gdd ejPZ)Gd!d"ejTZ+Gd#d$Z,Gd%d&ejZZ.e)Z/Gd'd(ej`Z1Gd)d*ej`Z2e2Z3y)+z.Selector and proactor event loops for Windows.Nwin32z win32 only)partial)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cXeZdZdZddfd ZfdZdZd fd ZfdZfd Z xZ S) _OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcft|||jr |jd=||_yNr)super__init___source_traceback_ov)selfovr __class__s //usr/lib64/python3.12/asyncio/windows_events.pyrz_OverlappedFuture.__init__7s1 d#  ! !&&r*ct|}|jH|jjrdnd}|j dd|d|jj dd|S)Npending completedrz overlapped=)r _repr_inforr&insertaddressr infostater"s r#r*z_OverlappedFuture._repr_info=s\w!# 88 !%!1!1I{E KK\%4883C3CB2GqI J r$c|jy |jjd|_y#t$rM}d||d}|jr|j|d<|jj |Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)r exccontexts r#_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs 88   7 HHOO  7C G %%.2.D.D*+ JJ - -g 6 6 7s1 B r$cd|_yrB)r)r futs r#_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cbs r$c|jsyd|_|j}d|_ tj||jdy#t$rh}|j tj k7rAd||d}|jr|j|d<|jj|Yd}~yYd}~~d}~wwxYwNFz$Failed to unregister the wait handler1r5) rTrS _overlappedUnregisterWaitr7winerrorERROR_IO_PENDINGrr8r9rdr rVr:r;s r#_unregister_waitz&_BaseWaitHandleFuture._unregister_waits  ''     & &{ 3   & ||{;;;E!$" ))262H2HG./ 11':< sA CAB<<CcD|jt| |Sr>)rlrr6r@s r#r6z_BaseWaitHandleFuture.cancels  w~#~&&r$cD|jt| |yrB)rlrrCrDs r#rCz#_BaseWaitHandleFuture.set_exceptions  i(r$cD|jt| |yrB)rlrrFrGs r#rFz _BaseWaitHandleFuture.set_results  6"r$rB) rIrJrKrLrr]r*rdrlr6rCrFrMrNs@r#rPrPas6<8<  '  '0')##r$rPcBeZdZdZddfd ZdZfdZfdZxZS)_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrc:t|||||d|_y)Nr)rr_done_callback)r r!eventrVrr"s r#rz_WaitCancelFuture.__init__s! UKd;"r$ctd)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr\s r#r6z_WaitCancelFuture.cancelsDEEr$c`t|||j|j|yyrB)rrFrsrGs r#rFz_WaitCancelFuture.set_results/ 6"    *    % +r$c`t|||j|j|yyrB)rrCrsrDs r#rCz_WaitCancelFuture.set_exceptions/ i(    *    % +r$) rIrJrKrLrr6rFrCrMrNs@r#rqrqs'8<# F& &&r$rqc4eZdZddfd ZfdZdZxZS)_WaitHandleFutureNrct|||||||_d|_t j dddd|_d|_y)NrTF)rr _proactor_unregister_proactorrg CreateEvent_event _event_fut)r r!rUrVproactorrr"s r#rz_WaitHandleFuture.__init__sG V[t<!$(!!--dD%F r$c|j-tj|jd|_d|_|jj |j d|_t|!|yrB) rrY CloseHandlerr| _unregisterrrrd)r rcr"s r#rdz%_WaitHandleFuture._unregister_wait_cbsY ;; "    ,DK"DO ""488, #C(r$c|jsyd|_|j}d|_ tj||j|jj|j|j|_y#t $rh}|j tjk7rAd||d}|jr|j|d<|jj|Yd}~yYd}~d}~wwxYwrf)rTrSrgUnregisterWaitExrr7rirjrr8r9r| _wait_cancelrdrrks r#rlz"_WaitHandleFuture._unregister_waits  ''     ( (dkk B..55dkk6:6N6NP ||{;;;E!$" ))262H2HG./ 11':< s A?? C0AC++C0)rIrJrKrrdrlrMrNs@r#rzrzsBF)$Pr$rzc2eZdZdZdZdZdZdZdZeZ y) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. c||_tj|_d|_d|_|j d|_yNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)r r,s r#rzPipeServer.__init__s; &0 #' --d3 r$cL|j|jdc}|_|S)NF)rr)r tmps r#_get_unconnected_pipez PipeServer._get_unconnected_pipes% **d&>&>u&ETZ r$c ,|jrytjtjz}|r|tjz}tj |j |tjtjztjztjtjtjtjtj}tj|}|j j#||SrB)closedrYPIPE_ACCESS_DUPLEXFILE_FLAG_OVERLAPPEDFILE_FLAG_FIRST_PIPE_INSTANCECreateNamedPiperPIPE_TYPE_MESSAGEPIPE_READMODE_MESSAGE PIPE_WAITPIPE_UNLIMITED_INSTANCESr BUFSIZENMPWAIT_WAIT_FOREVERNULL PipeHandleradd)r firstflagshpipes r#rzPipeServer._server_pipe_handles ;;=**W-I-II  W:: :E  # # MM5  % %(E(E E      , ,  ! !=#8#8  ( (',,  8''*   & r$c|jduSrB)rr\s r#rzPipeServer.closed s %&r$c |j!|jjd|_|jJ|jD]}|j d|_d|_|jj yyrB)rr6rrcloserclear)r rs r#rzPipeServer.close#sp  # # /  $ $ + + -'+D $ == $,, -DJ DM  & & ( %r$N) rIrJrKrLrrrrr__del__r$r#rrs'4$' )Gr$rceZdZdZy)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)rIrJrKrLrr$r#rr2s1r$rcDeZdZdZdfd ZfdZdZdZ ddZxZ S)rz2Windows version of proactor event loop using IOCP.c<| t}t| |yrB)rrr)r rr"s r#rzProactorEventLoop.__init__9s  #~H "r$c4 |jJ|j|jt||ja|jj }|jj |'|js|jj|d|_yy#|ja|jj }|jj |'|js|jj|d|_wwxYwrB) _self_reading_future call_soon_loop_self_readingr run_foreverrr6r&r|r)r r!r"s r#rzProactorEventLoop.run_forever>s 1,,4 44 NN422 3 G  !((4..22))002>"**NN..r2,0)5t((4..22))002>"**NN..r2,0)5s 7B((A/DcK|jj|}|d{}|}|j||d|i}||fS7%w)Naddrextra)r| connect_pipe_make_duplex_pipe_transport)r protocol_factoryr,frprotocoltranss r#create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ NN ' ' 0w#%00x8>7H1Jh s!A A &A cfKtdfd jgSw)NcJd} |ri|j}jj|jr|j y}j ||dij }|yjj|}|_ |jy#t$r9|r#|jdk7r|j jYyt$rz}|r9|jdk7r&jd||d|j n$j rt#j$d|djYd}~yd}~wt&j($r|r|j YyYywxYw) NrrrzPipe accept failed)r2r3rzAccept pipe failed on pipe %rT)exc_info)rHrdiscardrrrrr| accept_piperadd_done_callbackBrokenPipeErrorfilenorr7r9_debugrwarningr CancelledError) rrrr:r,loop_accept_piperr servers r#rz>ProactorEventLoop.start_serving_pipe..loop_accept_pipe\stD) 688:D**2248}} /1H44hvw.?5A335<NN..t4*./*##$45+# 1DKKMR/JJL/0 1DKKMR///#7%( $1 JJL[[NN#B#'$8/00,, !JJL !s1A B7/B7B77?F"8F"A0E55(F"!F"rB)rr)r rr,rrs```@@r#start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2G$+ 6+ 6Z '(xs*1c K|j} t||||||||f| |d| } | d{| S7#ttf$rt$r+| j | j d{7wxYww)N)waiterr) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionr_wait) r rargsshellstdinstdoutstderrbufsizerkwargsrtransps r#_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transports##%,T8T5-2FFG74:%7067 LL  -.    LLN,,.  s1'A>868A>8;A;3A64A;;A>rB) rIrJrKrLrrrrrrMrNs@r#rr6s%<# 1&1j04r$rceZdZdZefdZdZdZdZd!dZ dZ e d Z e d Zd"d Zd"d Zd"d Zd"dZd#dZd"dZdZdZdZdZdZd!dZdZdZdZdZdZdZ d!dZ!dZ"dZ#d Z$y)$rz#Proactor implementation using IOCP.cd|_g|_tjtjt d||_i|_tj|_ g|_ tj|_ yrX) r8_resultsrgCreateIoCompletionPortINVALID_HANDLE_VALUEr_iocp_cacherrrT _unregistered_stopped_serving)r concurrencys r#rzIocpProactor.__init__s_   77  , ,dA{D  "??, ' 1r$c2|j tdy)NzIocpProactor is closed)rrvr\s r# _check_closedzIocpProactor._check_closeds :: 78 8 r$cdt|jzdt|jzg}|j|j dd|j j ddj|dS)Nzoverlapped#=%sz result#=%sr< r))lenrrrrar"rIjoin)r r.s r#__repr__zIocpProactor.__repr__s_ 3t{{#33s4==113 ::  KK ! NN33SXXd^DDr$c||_yrB)r8)r rs r#set_loopzIocpProactor.set_loops  r$Ncz|js|j||j}g|_ |d}S#d}wxYwrB)rr])r timeoutrs r#selectzIocpProactor.selects:}} JJw mm  C$Cs6:c\|jj}|j||SrB)r8rrF)r valuercs r#_resultzIocpProactor._results%jj&&( u r$c |jS#t$rD}|jtjtj fvrt |jd}~wwxYwrB) getresultr7rirgERROR_NETNAME_DELETEDERROR_OPERATION_ABORTEDConnectionResetErrorr)rkeyr!r:s r#finish_socket_funczIocpProactor.finish_socket_funcsY <<> ! || A A + C C EE*CHH55  s A?AAc |j|||S#t$r,}|jtjk(r |dfcYd}~Sd}~wwxYwrB)rr7rirgERROR_PORT_UNREACHABLE)clsrrr! empty_resultr:s r#_finish_recvfromzIocpProactor._finish_recvfromsN ))%b9 9 ||{AAA#T))  s A  AA AA c|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYw)Nr$) _register_with_iocprg Overlappedr isinstancesocketWSARecvrReadFilerr _registerrr connnbytesrr!s r#recvzIocpProactor.recvs   &  # #D ) %$ . 4;;=&%8 DKKM62~~b$(?(?@@ %<<$ $ %AB%%CCc|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYwrX) r rgr rr r  WSARecvIntor ReadFileIntorrrrr rbufrr!s r# recv_intozIocpProactor.recv_intos   &  # #D ) #$ .t{{}c59 s3~~b$(?(?@@ #<<? " #rc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)N)r$Nr$r) r rgr r WSARecvFromrrrrrrrs r#recvfromzIocpProactor.recvfroms   &  # #D ) - NN4;;=&% 8~~b$0E0E=@)BC C -<< , , -!A55BBc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)NrNrr) r rgr rWSARecvFromIntorrrrrrrs r# recvfrom_intozIocpProactor.recvfrom_intos   &  # #D ) +   t{{}c5 9~~b$0E0E=>)@A A +<< * * +rc|j|tjt}|j |j ||||j |||jSrB)r rgr r WSASendTorrr)r rrrrr!s r#sendtozIocpProactor.sendtosQ   &  # #D ) T[[]C5~~b$(?(?@@r$cH|j|tjt}t |t j r"|j |j||n |j|j||j|||jSrB) r rgr rr r WSASendr WriteFilerrrs r#sendzIocpProactor.sendsq   &  # #D ) dFMM * JJt{{}c5 1 LL ,~~b$(?(?@@r$c||j|jjtjt }|j jjfd}d}|j||}||}tj||j|S)Nc,|jtjdj}j t j tj|jjjfS)Nz@P) rstructpackr setsockoptr  SOL_SOCKETrgSO_UPDATE_ACCEPT_CONTEXT settimeout gettimeout getpeername)rrr!rrlisteners r# finish_acceptz*IocpProactor.accept..finish_accept*sl LLN++dHOO$56C OOF--'@@# G OOH//1 2))++ +r$cvK |d{y7#tj$r|jwxYwwrB)r rr)r4rs r# accept_coroz(IocpProactor.accept..accept_coro3s2  ,,   s 99%69r) r _get_accept_socketfamilyrgr rAcceptExrrr ensure_futurer8)r r5r!r6r8r4corors ` @r#acceptzIocpProactor.accept$s   *&&x7  # #D ) HOO%t{{}5 , Hm<64( Dtzz2 r$cjtjk(rQtjj ||j j}|jd|S|j tjj jtj"t$}|j'j |fd}|j)||S#t$r?}|jtjk7rj!ddk(rYd}~d}~wwxYw)Nrrc|jjtjtj dSrX)rr/r r0rgSO_UPDATE_CONNECT_CONTEXT)rrr!rs r#finish_connectz,IocpProactor.connect..finish_connectVs1 LLN OOF--'AA1 FKr$)typer  SOCK_DGRAMrg WSAConnectrr8rrFr  BindLocalr:r7rierrno WSAEINVAL getsocknamer r ConnectExr)r rr,rcer!rBs ` r#connectzIocpProactor.connect@s 99)) )  " "4;;=' :****,C NN4 J   &   ! !$++- = # #D ) T[[]G, ~~b$77! zzU__,!!$)*  s.D E  5EE c 6|j|tjt}|dz}|dz dz}|j |j t j|j |||dd|j|||jS)Nl r) r rgr r TransmitFilermsvcrt get_osfhandlerr)r sockfileoffsetcountr! offset_low offset_highs r#sendfilezIocpProactor.sendfile_s   &  # #D )k) |{2   ,,T[[];"Kq! % ~~b$(?(?@@r$c|jtjt}|j j }|r|j Sfd}|j||S)Nc(|jSrB)r)rrr!rs r#finish_accept_pipez4IocpProactor.accept_pipe..finish_accept_pipevs LLNKr$)r rgr rConnectNamedPiperrr)r rr! connectedr[s ` r#rzIocpProactor.accept_pipeksf   &  # #D )'' 6 <<% % ~~b$(:;;r$c<Kt} tj|} tj|S#t$r(}|jtj k7rYd}~nd}~wwxYwt |dzt}tj|d{7w)N) CONNECT_PIPE_INIT_DELAYrg ConnectPiper7riERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr r)r r,delayrUr:s r#rzIocpProactor.connect_pipe|s' $009''// <<;#>#>>?   #9:E++e$ $ $s6B6B A'A"B"A''.BBBc(|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)r rUrs r#wait_for_handlezIocpProactor.wait_for_handles $$VWe<.finish_wait_for_handles779 r$r)rrYINFINITEmathceilrgr rRegisterWaitWithQueuerr,rqr8rzrr) r rUr _is_cancelmsr!rVrors @r#rhzIocpProactor._wait_for_handles  ?!!B7S=)B # #D )!77 DJJ B0 !"fk KA!"fk4'+zz3A  ##B' $%b!-C"D BJJr$c||jvrL|jj|tj|j |j ddyyrX)rTrrgrrrr objs r#r z IocpProactor._register_with_iocpsI d&& &     %  . .szz|TZZA N 'r$c^|jt||j}|jr |jd=|js |dd|}|j |||||f|j|j<|S#t $r}|j|Yd}~>d}~wwxYwr) rrr8rr&rFr7rCrr,)r r!rxcallbackrrrKs r#rzIocpProactor._registers  btzz 2  ##B'zz  $ tR0 U#$%b#x"8 BJJ #"" #s B B,B''B,cZ|j|jj|y)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrra)r r!s r#rzIocpProactor._unregisters$  !!"%r$cRtj|}|jd|SrX)r r2)r r:ss r#r9zIocpProactor._get_accept_sockets MM& ! Qr$c "|t}n<|dkr tdtj|dz}|tk\r td t j |j |}|nd}|\}}}} |jj|\}} } } | |j vr|j#nI|j%s9 | ||| } |j'| |j(j+|d}|j0D](} |jj| j2d*|j0j5y#t$rl|jjr%|jjdd||||fzd|dtjfvrtj|Y}wxYw#t,$r7} |j/| |j(j+|Yd} ~ d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2status)rp ValueErrorrqrrrgGetQueuedCompletionStatusrrpopKeyErrorr8 get_debugr9rrYrrr6donerFrrar7rCrr,r)r rrurerr transferredrr,rr!rxrzrrKs r#r]zIocpProactor._polls ?B q[/0 07S=)BX~ !233 ::4::rJF~B-3 *Cc7 '+{{w'?$2sH d+++ VVX $[#r:E LL'MM((+AMR$$B KKOOBJJ -%   "E ::'')JJ55%7#N&);W%E$F7q+"B"BCC'', ,,OOA&MM((++,AsC4 E G,H A1GG H,H<H HH Hc:|jj|yrB)rrrws r# _stop_servingzIocpProactor._stop_serving2s !!#&r$c4|jyt|jjD]:\}}}}|j rt |t r* |j<d}tj}||z} |jrx| tjkrCtjd|tj|z tj|z} |j!||jrxg|_t%j&|jd|_y#t$rS}|j>++ K!4>>#3j#@B>>+j8 JJz "kk DJJ' ; Czz-'C),&)# 00:=:O:OG$67 99'B CsD;; FAFFc$|jyrB)rr\s r#rzIocpProactor.__del__gs  r$rB)rr!)%rIrJrKrLrprrrrrr staticmethodr classmethodrrrrr#r&r*r>rLrXrrrirrhr rrr9r]rrrrr$r#rrs-#+29E     A A C AAA88> A<"0&= DO@& 7#r' -^r$rceZdZdZy)rc tj|f|||||d|_fd}jjj t jj} | j|y)N)rrrrrc\jj}j|yrB)_procpoll_process_exited)r returncoder s r#rzz4_WindowsSubprocessTransport._start..callbackrs!*J   ,r$) r Popenrr8r|riintrRr) r rrrrrrrrzrs ` r#_startz"_WindowsSubprocessTransport._startmso"(( 'U6&'%'  - JJ 0 0TZZ5G5G1H I H%r$N)rIrJrKrrr$r#rrks &r$rceZdZeZy)rN)rIrJrKr _loop_factoryrr$r#rr}%Mr$rceZdZeZy)rN)rIrJrKrrrr$r#rrrr$r)4rLsysplatform ImportErrorrgrYrG functoolsrrqrPr r-rrrrrr r r r r logr__all__rrpERROR_CONNECTION_REFUSEDERROR_CONNECTION_ABORTEDr`rdFuturerrPrqrzobjectrBaseSelectorEventLooprBaseProactorEventLooprrBaseSubprocessTransportrrBaseDefaultEventLoopPolicyrrrrr$r#rs\4 <<7 l ##   ||    --`G#GNNG#T&-&01P-1Ph88v2 E E2g==gTHHV &/"I"I &.&V%F%F&&V%F%F&8r$__pycache__/unix_events.cpython-312.opt-1.pyc000064400000202743152343231170014776 0ustar00 ֦idZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe j6dk(reddZdZGddej>Z GddejBZ"GddejFejHZ%GddejLZ'GddZ(Gdde(Z)Gd d!e(Z*Gd"d#e*Z+Gd$d%e*Z,Gd&d'e(Z-Gd(d)e(Z.d*Z/Gd+d,ej`Z1e Z2e1Z3y)-z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherPidfdChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on Windowscy)zDummy signal handler.N)signumframes ,/usr/lib64/python3.12/asyncio/unix_events.py_sighandler_noopr*scP tj|S#t$r|cYSwxYwN)oswaitstatus_to_exitcode ValueError)statuss rr"r"/s.((00  s  %%ceZdZdZdfd ZfdZdZdZdZdZ d Z dd Z dd Z dd Z d Z ddddddddZ dddddddddZdZdZdZdZxZS)_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Nc2t||i|_yr )super__init___signal_handlers)selfselector __class__s rr)z_UnixSelectorEventLoop.__init__?s " "rc0t|tjs,t |j D]}|j |y|j r;tjd|dt||j jyy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) r(closesys is_finalizinglistr*remove_signal_handlerwarningswarnResourceWarningclear)r+sigr-s rr1z_UnixSelectorEventLoop.closeCs    "D112**3/3$$ 1$:HI.%) + %%++- %rc:|D]}|s|j|yr )_handle_signal)r+datars r_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs F    ' rcRtj|stj|r td|j ||j  t j|jjtj|||d}||j |< t j |t"t j$|dy#ttf$r}tt|d}~wwxYw#t$r}|j |=|j sI t jdn2#ttf$r }t'j(d|Yd}~nd}~wwxYw|j*t*j,k(rtd|dd}~wwxYw)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)r iscoroutineiscoroutinefunction TypeError _check_signal _check_closedsignal set_wakeup_fd_csockfilenor#OSError RuntimeErrorstrrHandler*r siginterruptrinfoerrnoEINVAL)r+r:callbackargsexchandlenexcs radd_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsq  " "8 ,..x889 9 3  )  !3!3!5 6xtT:%+c"  MM#/ 0   U +G$ )s3x( ( ) %%c*((F((,"G,FKK >EEFyyELL("T#.?#@AA sZ-C-0D D-DD F&F!,EF!E1E,'F!,E110F!!F&c|jj|}|y|jr|j|y|j |y)z2Internal helper that is the actual signal handler.N)r*get _cancelledr5_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signalsE&&**3/ >      & &s +  ) )& 1rc|j| |j|=|tjk(rtj }ntj } tj|||js tjdyy#t$rYywxYw#t$r2}|jtjk(rtd|dd}~wwxYw#ttf$r }tjd|Yd}~yd}~wwxYw)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. FrBrCNr@rAT)rGr*KeyErrorrISIGINTdefault_int_handlerSIG_DFLrMrSrTrNrJr#rrR)r+r:handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handlers 3 %%c* &-- 00GnnG  MM#w '$$ A$$R(-   yyELL("T#.?#@AA  ( A :C@@ AsA BB8C BB C'-CCD +DD ct|tstd||tjvrt d|y)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintrFrI valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signalsJ #s#6sg>? ? f**, ,5cU;< < -rc t|||||Sr )_UnixReadPipeTransportr+pipeprotocolwaiterextras r_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transports%dD(FEJJrc t|||||Sr )_UnixWritePipeTransportrks r_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transports&tT8VUKKrc lKtj5tjdtt j } ddd 5| j s td|j} t||||||||f| |d| } | j| j|j|  | d{ ddd| S#1swYxYw7#ttf$rt$r+| j!| j#d{7wxYw#1swY SxYww)NignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6catch_warnings simplefilterDeprecationWarningrget_child_watcher is_activerN create_future_UnixSubprocessTransportadd_child_handlerget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr1_wait) r+rmrVshellstdinstdoutstderrbufsizerokwargswatcherrntransps r_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transports/ $ $ &  ! !(,> ?..0G'$$& #$GHH'')F-dHdE,16676396/56F  % %fnn&6$($@$@& J  !0 9' &( 12    lln$$ '0 seD4/C D4A-D'>C!CC! D4CD4C!!;D$DD$$D''D1,D4c<|j|j|yr )call_soon_threadsafe_process_exited)r+pid returncoders rrz._UnixSelectorEventLoop._child_watcher_callbacks !!&"8"8*Er)sslsockserver_hostnamessl_handshake_timeoutssl_shutdown_timeoutcK|r |2td| td| td| td|| tdtj|}tjtjtj d} |j d|j||d{nf| td|jtjk7s|jtj k7rtd ||j d|j|||||| d{\}} || fS7#|jxYw7#w) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl0ssl_shutdown_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rr) r#r!fspathsocketAF_UNIX SOCK_STREAM setblocking sock_connectr1familytype_create_connection_transport) r+protocol_factorypathrrrrr transportrms rcreate_unix_connectionz-_UnixSelectorEventLoop.create_unix_connections & EGG* !NOO$0 GII#/ FHH   IKK99T?D==1C1CQGD   '''d333 | !BCC v~~-II!3!33 DTHMOO   U #$($E$E "C"7!5%F%77 8(""%4  7s=BE#&E 7E 8E E# E EE#dT)rbacklogrrr start_servingc Kt|tr td| |s td| |s td|| tdt j |}t j t jt j}|ddvrH tjt j|jrt j| |j#|nU| td |j*t jk7s|j,t jk7rtd ||j/d t1j2||g|||||} |r-| j5t7j8dd{| S#t$rYt$r!} tj d|| Yd} ~ d} ~ wwxYw#t$rT} |j%| j&t&j(k(r!d|d } tt&j(| dd} ~ w|j%xYw7w) Nz*ssl argument must be an SSLContext or Nonerrrr)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrF)rfboolrFr#r!rrrrstatS_ISSOCKst_moderemoveFileNotFoundErrorrMrerrorbindr1rS EADDRINUSErrrrServer_start_servingr sleep) r+rrrrrrrrerrrWmsgservers rcreate_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7 c4 HI I ,SCE E +CBD D   IKK99T?D==1C1CDDAwk)6}}RWWT]%:%:; $  $| CEE v~~-II!3!33 DTHMOO ##D4&2B$'2G$8:   ! ! #++a.  S)6LL"*+/666  99 0 00%TH,>?C!%"2"2C8dB  & !siBIAF'"G3B-I I!I' G0I2G:GIGI I 'AH66I  Ic K tj |j } tj|j}|r|n|}|sy|j} |j| d|||||d| d{S#t$rtjdwxYw#tt jf$r}tjdd}~wwxYw#t$rtjdwxYw7~w)Nzos.sendfile() is not availableznot a regular filer) r!sendfileAttributeErrorr SendfileNotAvailableErrorrLioUnsupportedOperationfstatst_sizerMr{_sock_sendfile_native_impl) r+rfileoffsetcountrLrfsize blocksizefuts r_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs 2 KK M[[]F MHHV$,,E#E   " ''T4(.y! Ey% 26602 2 2  7 78 M667KL L M M667KL L MsVC<BB"C6C<;C:<C<BC<"C;CCC<C77C<c |j} ||j||jr|j|||y|r/||z }|dkr%|j||||j |y t j | |||} | dk(r%|j||||j |y|| z }|| z }||j|||j| |j|| |||||| y#ttf$r;||j|||j| |j|| |||||| Yyt$r} |Q| jtjk(r4t| t ur#t!dtj} | | _| } |dk(r:t%j&d} |j||||j)| n)|j||||j)| Yd} ~ yYd} ~ yd} ~ wt*t,f$rt.$r.} |j||||j)| Yd} ~ yd} ~ wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL remove_writer cancelled_sock_sendfile_update_filepos set_resultr!r_sock_add_cancellation_callback add_writerrBlockingIOErrorInterruptedErrorrMrSENOTCONNrConnectionError __cause__r r set_exceptionrrr)r+r registered_fdrrLrrr total_sentfdsentrWnew_excrs rrz1_UnixSelectorEventLoop._sock_sendfile_native_implysT [[]  $   } - ==?  . .vvz J   *IA~2266:Nz*1 F;;r669=DJqy2266:Nz*$d"  (88dCD$C$CS "D& &y*F[ !12 B$44S$? OOB ? ?f"E9j B ')II/I_4 *-u~~?$'!Q !::-/2266:N!!#&2266:N!!#&&'-.   #  . .vvz J   c " " #s,:C??AIIB6HI+$IIcZ|dkDr&tj||tjyyNr)r!lseekSEEK_SET)r+rLrrs rrz4_UnixSelectorEventLoop._sock_sendfile_update_fileposs" > HHVVR[[ 1 rc6fd}|j|y)Ncv|jr(j}|dk7rj|yyy)Nr@)rrLr)rrr+rs rcbzB_UnixSelectorEventLoop._sock_add_cancellation_callback..cbs6}}[[]8&&r*r)add_done_callback)r+rrrs` ` rrz6_UnixSelectorEventLoop._sock_add_cancellation_callbacks + b!rr NN)__name__ __module__ __qualname____doc__r)r1r>rZr<r5rGrprsrrrrrrrr __classcell__r-s@rr&r&9s # .(+Z2@ =@D(,KAE)-L 04BF*.0#4 "&!% 0#f*.Gs"&!% GR.DFL2"rr&ceZdZdZdfd ZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZddZdZdZxZS)rjic4t||||jd<||_||_|j |_||_d|_d|_ tj|j j}tj|sJtj|s5tj |s d|_d|_d|_t#dtj$|j d|jj'|jj(||jj'|j*|j |j,|,|jj't.j0|dyy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)_extra_loop_piperL_fileno _protocol_closing_pausedr!rrrS_ISFIFOrS_ISCHRr# set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r+looprlrmrnromoder-s rr)z_UnixReadPipeTransport.__init__s. " F  {{} !  xx %-- d# d# T"DJDL!DNHI I  e, T^^;;TB T--!\\4+;+; =   JJ !E!E!' / rc^|jsy|jj||yr ) is_readingrr)r+rrUs rrz"_UnixReadPipeTransport._add_readers#  r8,rc:|j xr |j Sr )rrr+s rrz!_UnixReadPipeTransport.is_readings<<5 $55rct|jjg}|j|jdn|jr|jd|jd|j t |jdd}|jW|Utj||j tj}|r|jdnA|jdn/|j|jdn|jddjd j|S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r-rrappendrrgetattrrr _test_selector_event selectors EVENT_READformatjoin)r+rRr,r s r__repr__z_UnixReadPipeTransport.__repr__s''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (<(<>G I& F# ZZ # KK  KK !}}SXXd^,,rch tj|j|j}|r|jj |y|j jrtjd|d|_ |j j|j|j j|jj|j j|jdy#tt f$rYyt"$r}|j%|dYd}~yd}~wwxYw)N%r was closed by peerTz"Fatal read error on pipe transport)r!readrmax_sizer data_receivedr get_debugrrRr_remove_readerr eof_received_call_connection_lostrrrM _fatal_error)r+r=rWs rrz"_UnixReadPipeTransport._read_ready s G774<<7D ,,T2::'')KK 7> $  ))$,,7 $$T^^%@%@A $$T%?%?F !12   I   c#G H H Is*C<<D1 D1D,,D1c|jsyd|_|jj|j|jj rt jd|yy)NTz%r pauses reading)rrrrrrrdebugrs r pause_readingz$_UnixReadPipeTransport.pause_readingsP   !!$,,/ ::   ! LL,d 3 "rc|js |jsyd|_|jj|j|j |jj rtjd|yy)NFz%r resumes reading) rrrrrrrrr#rs rresume_readingz%_UnixReadPipeTransport.resume_reading%s[ ==   t||T-=-=> ::   ! LL-t 4 "rc||_yr rr+rms r set_protocolz#_UnixReadPipeTransport.set_protocol- !rc|jSr r(rs r get_protocolz#_UnixReadPipeTransport.get_protocol0 ~~rc|jSr rrs r is_closingz!_UnixReadPipeTransport.is_closing3 }}rc@|js|jdyyr )r_closers rr1z_UnixReadPipeTransport.close6s}} KK rcv|j-|d|t||jjyyNzunclosed transport r/rr8r1r+_warns r__del__z_UnixReadPipeTransport.__del__:5 :: ! 'x0/$ O JJ    "rc<t|trQ|jtjk(r4|jj rDt jd||dn*|jj||||jd|j|yNz%r: %sTexc_info)message exceptionrrm) rfrMrSEIOrrrr#call_exception_handlerrr4r+rWr@s rr!z#_UnixReadPipeTransport._fatal_error?sr sG $eii)?zz##% XtWtD JJ - -" ! NN /  Crcd|_|jj|j|jj |j |yNT)rrrrrr r+rWs rr4z_UnixReadPipeTransport._closeMs9  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwr rconnection_lostrr1rrGs rr z,_UnixReadPipeTransport._call_connection_lostRg  NN * *3 / JJ   DJ!DNDJ JJ   DJ!DNDJ A 1A>rzFatal error on pipe transport)rrrrr)rrrrr$r&r*r-r1r1r6r7r:r!r4r rrs@rrjrjs]H/<- 6-*G$45"%MM > rrjceZdZdfd ZdZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZdZddZddZdZxZS)rrct |||||jd<||_|j |_||_t|_d|_ d|_ tj|j j}tj|}tj |}tj"|} |s$|s"| s d|_d|_d|_t%dtj&|j d|j(j+|j j,|| s!|rdt.j0j3dsE|j(j+|j(j4|j |j6|,|j(j+t8j:|dyy)NrlrFz?Pipe transport is only for pipes, sockets and character devicesaix)r(r)rrrLrr bytearray_buffer _conn_lostrr!rrrrrrr#rrrrr2platform startswithrrr r) r+rrlrmrnroris_charis_fifo is_socketr-s rr)z _UnixWritePipeTransport.__init___si %" F {{} ! {  xx %--,,t$--%MM$' 7iDJDL!DNDE E  e, T^^;;TB )@)@)G JJ !7!7!%t/?/? A   JJ !E!E!' / rc|jjg}|j|jdn|jr|jd|jd|j t |jdd}|j{|ytj||j tj}|r|jdn|jd|j}|jd|n/|j|jdn|jdd jd j|S) Nrrr r r r zbufsize=r rr)r-rrrrrrrr rr EVENT_WRITEget_write_buffer_sizerr)r+rRr,r rs rrz _UnixWritePipeTransport.__repr__s ''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (=(=?G I& F#002G KK(7), - ZZ # KK  KK !}}SXXd^,,rc,t|jSr )lenrRrs rr[z-_UnixWritePipeTransport.get_write_buffer_sizes4<<  rc|jjrtjd||jr|j t y|j y)Nr)rrrrRrRr4BrokenPipeErrorrs rrz#_UnixWritePipeTransport._read_readys@ ::   ! KK/ 6 << KK) * KKMrct|tr t|}|sy|js |jrH|jt j k\rtjd|xjdz c_y|jss tj|j|}|t'|k(ry|dkDrt||d}|j(j+|j|j,|xj|z c_ |j/y#ttf$rd}Ytt f$rt"$r1}|xjdz c_|j%|dYd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr#Fatal write error on pipe transport)rfrQ memoryviewrSrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrRr!writerrrrrrr!r]r _add_writer _write_ready_maybe_pause_protocol)r+r=nrWs rrez_UnixWritePipeTransport.writes7 dI &d#D  ??dmm)"M"MM HI OOq O || HHT\\40CI~Q!$'+ JJ " "4<<1B1B C   ""$$%56  12   1$!!#'LM s D$$E?7E?'E::E?c tj|j|j}|t |jk(r|jj |j j|j|j|jr6|j j|j|jdy|dkDr|jd|=yy#ttf$rYyttf$rt $rp}|jj |xj"dz c_|j j|j|j%|dYd}~yd}~wwxYw)Nrrra)r!rerrRr]r9r_remove_writer_maybe_resume_protocolrrr rrrrrrSr!)r+rirWs rrgz$_UnixWritePipeTransport._write_readys. %t||4AC %% ""$ ))$,,7++-==JJ--dll;..t4QLL!$) !12  -.   J LL   OOq O JJ % %dll 3   c#H I I  Js*C,,F=FA&E??FcyrFrrs r can_write_eofz%_UnixWritePipeTransport.can_write_eofrc|jryd|_|jsL|jj|j|jj |j dyyrF)rrRrrrrr rs r write_eofz!_UnixWritePipeTransport.write_eofsO ==  || JJ % %dll 3 JJ !;!;T Brc||_yr r(r)s rr*z$_UnixWritePipeTransport.set_protocolr+rc|jSr r(rs rr-z$_UnixWritePipeTransport.get_protocolr.rc|jSr r0rs rr1z"_UnixWritePipeTransport.is_closingr2rcX|j|js|jyyyr )rrrqrs rr1z_UnixWritePipeTransport.closes$ :: !$-- NN +8 !rcv|j-|d|t||jjyyr6r7r8s rr:z_UnixWritePipeTransport.__del__r;rc&|jdyr )r4rs rabortz_UnixWritePipeTransport.aborts Drct|tr4|jjrDt j d||dn*|jj ||||jd|j|yr=) rfrMrrrr#rCrr4rDs rr!z$_UnixWritePipeTransport._fatal_error sc c7 #zz##% XtWtD JJ - -" ! NN /  Crc>d|_|jr%|jj|j|jj |jj |j|jj|j|yrF) rrRrrkrr9rrr rGs rr4z_UnixWritePipeTransport._closesf << JJ % %dll 3  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwr rIrGs rr z-_UnixWritePipeTransport._call_connection_lostrKrLrrMr )rrrr)rr[rrergrnrqr*r-r1r1r6r7r:rxr!r4r rrs@rrrrr\sd#/J-0!!%F%8C" %MM  >rrrceZdZdZy)r|c d}|tjk(r6tjj drt j \}} tj|f||||d|d||_|=|jt|jd||j_ d}|!|j|jyy#|!|j|jwwxYw)NrPF)rrrruniversal_newlinesrwb) buffering) subprocessPIPEr2rTrUr socketpairPopen_procr1r detachr) r+rVrrrrrrstdin_ws r_startz_UnixSubprocessTransport._start+s JOO # (?(?(F $..0NE7 #))E!vf#('E=CEDJ" #'(8$'#R  "  #w"  #s A!C%C7N)rrrrrrrr|r|)s rr|cBeZdZdZd dZdZdZdZdZdZ d Z d Z y) raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. Nc\|jtk7rtjdddyy)NrP{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.r)rrr6 _deprecated)clss r__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs, >>X %  !7;%, . &rct)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. NotImplementedErrorr+rrUrVs rr}z&AbstractChildWatcher.add_child_handler_s "##rct)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.rr+rs rremove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs "##rct)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. rr+rs r attach_loopz AbstractChildWatcher.attach_looprs "##rct)zlClose the watcher. This must be called to make sure that any underlying resource is freed. rrs rr1zAbstractChildWatcher.close|s "##rct)zReturn ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. rrs rrzzAbstractChildWatcher.is_actives "##rct)zdEnter the watcher's context and allow starting new processes This function must return selfrrs r __enter__zAbstractChildWatcher.__enter__s "##rct)zExit the watcher's contextrr+abcs r__exit__zAbstractChildWatcher.__exit__s !##r)returnN) rrrrrr}rrr1rzrrrrrrrAs/,. $$$$$$ $rrc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) ra6Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. c|Sr rrs rrzPidfdChildWatcher.__enter__ rcyr r)r+exc_type exc_value exc_tracebacks rrzPidfdChildWatcher.__exit__ rcyrFrrs rrzzPidfdChildWatcher.is_activerorcyr rrs rr1zPidfdChildWatcher.closerrcyr rrs rrzPidfdChildWatcher.attach_looprrctj}tj|}|j ||j ||||yr )rget_running_loopr! pidfd_openr_do_wait)r+rrUrVrpidfds rr}z#PidfdChildWatcher.add_child_handlers:&&( c"  sE8TJrc$tj}|j| tj|d\}}t |}tj||||g|y#t $rd}tjd|YCwxYw)NrzJchild process pid %d exit status already read: will report returncode 255) rrrr!waitpidr"ChildProcessErrorrrdr1) r+rrrUrVr_r$rs rrzPidfdChildWatcher._do_waits&&( E" 8 3*IAv07J j(4(! J NN.   sA++!BBcyrFrrs rrz&PidfdChildWatcher.remove_child_handlerrN) rrrrrrrzr1rr}rrrrrrrs0    K )&rrc6eZdZdZdZdZdZdZdZdZ y) BaseChildWatcherc d|_i|_yr )r _callbacksrs rr)zBaseChildWatcher.__init__s rc&|jdyr )rrs rr1zBaseChildWatcher.closes rcV|jduxr|jjSr )r is_runningrs rrzzBaseChildWatcher.is_actives#zz%A$***?*?*AArctr r)r+ expected_pids r _do_waitpidzBaseChildWatcher._do_waitpid !##rctr rrs r_do_waitpid_allz BaseChildWatcher._do_waitpid_allrrc^|j(|&|jrtjdt|j)|jj t j||_|;|jt j|j|jyy)NzCA loop is being detached from a child watcher with pending handlers) rrr6r7RuntimeWarningr5rISIGCHLDrZ _sig_chldrrs rrzBaseChildWatcher.attach_loops :: !dlt MM= :: ! JJ , ,V^^ <    # #FNNDNN C  " rc |jy#ttf$rt$r(}|jj d|dYd}~yd}~wwxYw)N$Unknown exception in SIGCHLD handler)r@rA)rrrrrrCrGs rrzBaseChildWatcher._sig_chldsX   "-.    JJ - -A /    sAAAN) rrrr)r1rzrrrrrrrrrs&B$$#( rrcPeZdZdZfdZfdZdZdZdZdZ dZ d Z xZ S) rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cRt|tjdddy)Nrrrr)r(r)r6rr+r-s rr)zSafeChildWatcher.__init__s' /;%, .rcV|jjt| yr )rr9r(r1rs rr1zSafeChildWatcher.closes   rc|Sr rrs rrzSafeChildWatcher.__enter__rrcyr rrs rrzSafeChildWatcher.__exit__rrcH||f|j|<|j|yr )rrrs rr}z"SafeChildWatcher.add_child_handler"s% ($/ rc> |j|=y#t$rYywxYwNTFrr`rs rrz%SafeChildWatcher.remove_child_handler(( $    cZt|jD]}|j|yr r4rrrs rrz SafeChildWatcher._do_waitpid_all/s#(C   S !)rc tj|tj\}}|dk(ryt|}|jj rt jd|| |jj|\}}|||g|y#t$r|}d}t jd|YOwxYw#t$r7|jj rt jd|dYyYywxYw)Nr$process %s exited with returncode %sr8Unknown child process pid %d, will report returncode 255'Child watcher got an unexpected pid: %rTr>) r!rWNOHANGr"rrrr#rrdrpopr`)r+rrr$rrUrVs rrzSafeChildWatcher._do_waitpid4s 7**\2::>KCax/7Jzz##% C):7 -!__005NHd S* ,t ,7! CJ NNJ   ( 3zz##%H"T3& 3s#'B-B?#B<;B<?;C?>C?) rrrrr)r1rrr}rrrrrs@rrrs0.  " -rrcJeZdZdZfdZfdZdZdZdZdZ dZ xZ S) raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). ct|tj|_i|_d|_tjdddy)Nrrrrr) r(r) threadingLock_lock_zombies_forksr6rrs rr)zFastChildWatcher.__init__asC ^^%   /;%, .rc|jj|jjt|yr )rr9rr(r1rs rr1zFastChildWatcher.closeks,    rct|j5|xjdz c_|cdddS#1swYyxYw)Nr)rrrs rrzFastChildWatcher.__enter__ps$ ZZ KK1 KZZs.7c>|j5|xjdzc_|js |js dddyt|j}|jj dddt j dy#1swY xYw)Nrz5Caught subprocesses termination from unknown pids: %s)rrrrOr9rrd)r+rrrcollateral_victimss rrzFastChildWatcher.__exit__vsp ZZ KK1 K{{$-- Z "%T]]!3  MM   !  C  Zs/B/BBc|j5 |jj|} ddd||g|y#t$r||f|j|<YdddywxYw#1swYA#A&"A##A&&A/c> |j|=y#t$rYywxYwrrrs rrz%FastChildWatcher.remove_child_handlerrrc tjdtj\}}|dk(ryt|}|j 5 |j j|\}}|jjrtjd|| dddtjd||n |||g#t$rYywxYw#t$r\|jrK||j|<|jjrtjd||Yddd4d}YwxYw#1swYxYw)Nr@rrz,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!rrr"rrrrrrrr#r`rrrd)r+rr$rrUrVs rrz FastChildWatcher._do_waitpid_alls8 < jjRZZ8 V !83F; 6%)__%8%8%=NHdzz++- %K%(*6!& #Z1j040K%   ${{-7 c*:://1"LL*>),j:! $H $sN'CD= C'2D= CCAD:*D=5D:7D=9D::D==E) rrrrr)r1rrr}rrrrs@rrrWs+.    )(1rrcReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zy )ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cPi|_d|_tjdddy)Nrrrr)r_saved_sighandlerr6rrs rr)zMultiLoopChildWatcher.__init__s*!%4;%, .rc|jduSr )rrs rrzzMultiLoopChildWatcher.is_actives%%T11rcZ|jj|jytjtj }||j k7rtjdd|_ytjtj |jd|_y)Nz+SIGCHLD handler was changed by outside code) rr9rrI getsignalrrrrd)r+rds rr1zMultiLoopChildWatcher.closesz   ! ! ) ""6>>2 dnn $ NNH I"& MM&..$*@*@ A!%rc|Sr rrs rrzMultiLoopChildWatcher.__enter__rrcyr rr+rexc_valexc_tbs rrzMultiLoopChildWatcher.__exit__rrcrtj}|||f|j|<|j|yr )rrrr)r+rrUrVrs rr}z'MultiLoopChildWatcher.add_child_handlers5&&( $h5 rc> |j|=y#t$rYywxYwrrrs rrz*MultiLoopChildWatcher.remove_child_handlerrrc8|jytjtj|j|_|j*t j dtj |_tjtjdy)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rrIrrrrdrcrQrs rrz!MultiLoopChildWatcher.attach_loopso  ! ! - !'v~~t~~!N  ! ! ) NNJ K%+^^D " FNNE2rcZt|jD]}|j|yr rrs rrz%MultiLoopChildWatcher._do_waitpid_alls#(C   S !)rc* tj|tj\}}|dk(ryt|}d} |jj|\}}}|jrt j d||y|r'|jrt jd|||j|||g|y#t$r|}d}t j d|d}YwxYw#t$rt j d|d YywxYw) NrTrrF%Loop %r that handles pid %r is closedrrr>)r!rrr"rrrdrr is_closedrr#rr`) r+rrr$r debug_logrrUrVs rrz!MultiLoopChildWatcher._do_waitpids  **\2::>KCax/7JI L#'??#6#6s#; D(D~~FcR!1LL!G!-z;)))(CKdK=! CJ NNJ I $ / NND / /s"'CC.%C+*C+.!DDc |jy#ttf$rt$rt j ddYywxYw)NrTr>)rrrrrrd)r+rrs rrzMultiLoopChildWatcher._sig_chld<sE R  "-.   R NNAD Q Rs/AAN)rrrrr)rzr1rrr}rrrrrrrrrrsA $.2 & 3""#LJRrrcdeZdZdZdZdZdZdZdZe jfdZ dZ d Z d Zd Zy ) raAThreaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. cFtjd|_i|_yr) itertoolsr _pid_counter_threadsrs rr)zThreadedChildWatcher.__init__Rs%OOA. rcyrFrrs rrzzThreadedChildWatcher.is_activeVrorcyr rrs rr1zThreadedChildWatcher.closeYrrc|Sr rrs rrzThreadedChildWatcher.__enter__\rrcyr rrs rrzThreadedChildWatcher.__exit___rrct|jjDcgc]}|jr|}}|r||jdt |yycc}w)Nz0 has registered but not finished child processesr/)r4r valuesis_aliver-r8)r+r9threadthreadss rr:zThreadedChildWatcher.__del__bse(,T]]-A-A-C(D)(Dfoo'(D)  T^^$$TU!  )sA!ctj}tj|jdt |j ||||fd}||j|<|jy)Nzasyncio-waitpid-T)targetnamerVdaemon) rrrThreadrnextr r start)r+rrUrVrrs rr}z&ThreadedChildWatcher.add_child_handlerjsf&&(!!)9)9)9$t?P?P:Q9R'S(,c8T'B)-/$ c rcyrFrrs rrz)ThreadedChildWatcher.remove_child_handlersrrcyr rrs rrz ThreadedChildWatcher.attach_loopyrrc tj|d\}}t|}|jrt j d|| |jrt jd||n|j|||g||jj|y#t $r|}d}t jd|Y~wxYw)Nrrrrr) r!rr"rrr#rrdrrr r)r+rrrUrVrr$rs rrz ThreadedChildWatcher._do_waitpid|s 7**\15KC07J~~ C):7 >>  NNBD# N %D % %hZ G$ G ,''! CJ NNJ   sB''#C  C N)rrrrr)rzr1rrr6r7r:r}rrrrrrrrEsB   %MM  (rrcttdsy tj}tjtj|dy#t $rYywxYw)NrFrT)hasattrr!getpidr1rrM)rs r can_use_pidfdr#sO 2| $iik sA&'  s=A AAcBeZdZdZeZfdZdZfdZdZ dZ xZ S)_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.c0t|d|_yr )r(r)_watcherrs rr)z$_UnixDefaultEventLoopPolicy.__init__s  rctj5|j)trt |_nt |_dddy#1swYyxYwr )rrr'r#rrrs r _init_watcherz)_UnixDefaultEventLoopPolicy._init_watchers6 \\}}$ ?$5$7DM$8$:DM \\s 6AAct|||jEtjtj ur|jj |yyy)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)r(set_event_loopr'rcurrent_thread main_threadr)r+rr-s rr+z*_UnixDefaultEventLoopPolicy.set_event_loopsS t$ MM %((*i.C.C.EE MM % %d +F &rc|j|jtjddd|jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. ryrrr)r'r)r6rrs rryz-_UnixDefaultEventLoopPolicy.get_child_watchers@ ==    0:BI K}}rc|j|jj||_tjdddy)z$Set the watcher for child processes.Nset_child_watcherrrr)r'r1r6r)r+rs rr0z-_UnixDefaultEventLoopPolicy.set_child_watchers? == $ MM   ! 0:BI Kr) rrrrr& _loop_factoryr)r)r+ryr0rrs@rr%r%s%D*M; ,  Krr%)4rrSrr r!rrIrrrr2rr6rrrrrr r r r r logr__all__rT ImportErrorrr"BaseSelectorEventLoopr& ReadTransportrj_FlowControlMixinWriteTransportrrBaseSubprocessTransportr|rrrrrrrr#BaseDefaultEventLoopPolicyr%rrrrrr<se8     <<7 C DD P"_BBP"f MZ55M`Jj::(77JZ FF 0S$S$l7,7t2+2jN-'N-bj1'j1Z~R0~RBO(/O(b 6K&"C"C6Kr+4r__pycache__/trsock.cpython-312.pyc000064400000011731152343231170012770 0ustar00 ֦i  ddlZGddZy)NceZdZdZdZdej fdZedZedZ edZ dZ d Z d Z d Zd Zd ZdZdZdZdZdZdZdZdZy)TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _socksockc||_yNr)selfrs '/usr/lib64/python3.12/asyncio/trsock.py__init__zTransportSocket.__init__s  c.|jjSr )rfamilyr s r rzTransportSocket.familyszz   r c.|jjSr )rtypers r rzTransportSocket.typeszzr c.|jjSr )rprotors r rzTransportSocket.protoszzr crd|jd|jd|jd|j}|jdk7r4 |j }|r|d|} |j}|r|d|}|dS#t j $rY4wxYw#t j $rY3wxYw) Nz)filenorrr getsocknamesocketerror getpeername)r sladdrraddrs r __repr__zTransportSocket.__repr__s*4;;=/:kk_GDII=9ZZL " ;;=B  ((*#XeW-A ((*#XeW-AAw<<   <<  s$B)B BB B65B6ctd)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrs r __getstate__zTransportSocket.__getstate__5sIJJr c6|jjSr )rrrs r rzTransportSocket.fileno8szz  ""r c6|jjSr )rduprs r r&zTransportSocket.dup;szz~~r c6|jjSr )rget_inheritablers r r(zTransportSocket.get_inheritable>szz))++r c:|jj|yr )rshutdown)r hows r r*zTransportSocket.shutdownAs C r c:|jj|i|Sr )r getsockoptr argskwargss r r-zTransportSocket.getsockoptFs$tzz$$d5f55r c<|jj|i|yr )r setsockoptr.s r r2zTransportSocket.setsockoptIs t.v.r c6|jjSr )rrrs r rzTransportSocket.getpeernameLzz%%''r c6|jjSr )rrrs r rzTransportSocket.getsocknameOr4r c6|jjSr )r getsockbynamers r r7zTransportSocket.getsockbynameRszz''))r c$|dk(rytd)Nrzr r rrsIV]]!!  .K# ,! 6/((*L Cr r)rrr>r r rIs ^C^Cr __pycache__/windows_events.cpython-312.opt-1.pyc000064400000121007152343231170015476 0ustar00 ֦iKdZddlZejdk7redddlZddlZddlZddlmZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZdZej6Zej8ZdZdZdZdZ GddejBZ"GddejBZ#Gdde#Z$Gdde#Z%Gdde&Z'Gdd ejPZ)Gd!d"ejTZ+Gd#d$Z,Gd%d&ejZZ.e)Z/Gd'd(ej`Z1Gd)d*ej`Z2e2Z3y)+z.Selector and proactor event loops for Windows.Nwin32z win32 only)partial)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cXeZdZdZddfd ZfdZdZd fd ZfdZfd Z xZ S) _OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcft|||jr |jd=||_yNr)super__init___source_traceback_ov)selfovr __class__s //usr/lib64/python3.12/asyncio/windows_events.pyrz_OverlappedFuture.__init__7s1 d#  ! !&&r*ct|}|jH|jjrdnd}|j dd|d|jj dd|S)Npending completedrz overlapped=)r _repr_inforr&insertaddressr infostater"s r#r*z_OverlappedFuture._repr_info=s\w!# 88 !%!1!1I{E KK\%4883C3CB2GqI J r$c|jy |jjd|_y#t$rM}d||d}|jr|j|d<|jj |Yd}~d|_yd}~wwxYw)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)r exccontexts r#_cancel_overlappedz$_OverlappedFuture._cancel_overlappedDs 88   7 HHOO  7C G %%.2.D.D*+ JJ - -g 6 6 7s1 B r$cd|_yrB)r)r futs r#_unregister_wait_cbz)_BaseWaitHandleFuture._unregister_wait_cbs r$c|jsyd|_|j}d|_ tj||jdy#t$rh}|j tj k7rAd||d}|jr|j|d<|jj|Yd}~yYd}~~d}~wwxYwNFz$Failed to unregister the wait handler1r5) rTrS _overlappedUnregisterWaitr7winerrorERROR_IO_PENDINGrr8r9rdr rVr:r;s r#_unregister_waitz&_BaseWaitHandleFuture._unregister_waits  ''     & &{ 3   & ||{;;;E!$" ))262H2HG./ 11':< sA CAB<<CcD|jt| |Sr>)rlrr6r@s r#r6z_BaseWaitHandleFuture.cancels  w~#~&&r$cD|jt| |yrB)rlrrCrDs r#rCz#_BaseWaitHandleFuture.set_exceptions  i(r$cD|jt| |yrB)rlrrFrGs r#rFz _BaseWaitHandleFuture.set_results  6"r$rB) rIrJrKrLrr]r*rdrlr6rCrFrMrNs@r#rPrPas6<8<  '  '0')##r$rPcBeZdZdZddfd ZdZfdZfdZxZS)_WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrc:t|||||d|_y)Nr)rr_done_callback)r r!eventrVrr"s r#rz_WaitCancelFuture.__init__s! UKd;"r$ctd)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr\s r#r6z_WaitCancelFuture.cancelsDEEr$c`t|||j|j|yyrB)rrFrsrGs r#rFz_WaitCancelFuture.set_results/ 6"    *    % +r$c`t|||j|j|yyrB)rrCrsrDs r#rCz_WaitCancelFuture.set_exceptions/ i(    *    % +r$) rIrJrKrLrr6rFrCrMrNs@r#rqrqs'8<# F& &&r$rqc4eZdZddfd ZfdZdZxZS)_WaitHandleFutureNrct|||||||_d|_t j dddd|_d|_y)NrTF)rr _proactor_unregister_proactorrg CreateEvent_event _event_fut)r r!rUrVproactorrr"s r#rz_WaitHandleFuture.__init__sG V[t<!$(!!--dD%F r$c|j-tj|jd|_d|_|jj |j d|_t|!|yrB) rrY CloseHandlerr| _unregisterrrrd)r rcr"s r#rdz%_WaitHandleFuture._unregister_wait_cbsY ;; "    ,DK"DO ""488, #C(r$c|jsyd|_|j}d|_ tj||j|jj|j|j|_y#t $rh}|j tjk7rAd||d}|jr|j|d<|jj|Yd}~yYd}~d}~wwxYwrf)rTrSrgUnregisterWaitExrr7rirjrr8r9r| _wait_cancelrdrrks r#rlz"_WaitHandleFuture._unregister_waits  ''     ( (dkk B..55dkk6:6N6NP ||{;;;E!$" ))262H2HG./ 11':< s A?? C0AC++C0)rIrJrKrrdrlrMrNs@r#rzrzsBF)$Pr$rzc2eZdZdZdZdZdZdZdZeZ y) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. c||_tj|_d|_d|_|j d|_yNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)r r,s r#rzPipeServer.__init__s; &0 #' --d3 r$cL|j|jdc}|_|S)NF)rr)r tmps r#_get_unconnected_pipez PipeServer._get_unconnected_pipes% **d&>&>u&ETZ r$c ,|jrytjtjz}|r|tjz}tj |j |tjtjztjztjtjtjtjtj}tj|}|j j#||SrB)closedrYPIPE_ACCESS_DUPLEXFILE_FLAG_OVERLAPPEDFILE_FLAG_FIRST_PIPE_INSTANCECreateNamedPiperPIPE_TYPE_MESSAGEPIPE_READMODE_MESSAGE PIPE_WAITPIPE_UNLIMITED_INSTANCESr BUFSIZENMPWAIT_WAIT_FOREVERNULL PipeHandleradd)r firstflagshpipes r#rzPipeServer._server_pipe_handles ;;=**W-I-II  W:: :E  # # MM5  % %(E(E E      , ,  ! !=#8#8  ( (',,  8''*   & r$c|jduSrB)rr\s r#rzPipeServer.closed s %&r$c |j!|jjd|_|jJ|jD]}|j d|_d|_|jj yyrB)rr6rrcloserclear)r rs r#rzPipeServer.close#sp  # # /  $ $ + + -'+D $ == $,, -DJ DM  & & ( %r$N) rIrJrKrLrrrrr__del__r$r#rrs'4$' )Gr$rceZdZdZy)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)rIrJrKrLrr$r#rr2s1r$rcDeZdZdZdfd ZfdZdZdZ ddZxZ S)rz2Windows version of proactor event loop using IOCP.c<| t}t| |yrB)rrr)r rr"s r#rzProactorEventLoop.__init__9s  #~H "r$c |j|jt| |ja|jj }|jj |'|js|jj|d|_yy#|ja|jj }|jj |'|js|jj|d|_wwxYwrB) call_soon_loop_self_readingr run_forever_self_reading_futurerr6r&r|r)r r!r"s r#rzProactorEventLoop.run_forever>s 1 NN422 3 G  !((4..22))002>"**NN..r2,0)5t((4..22))002>"**NN..r2,0)5s )BA/D cK|jj|}|d{}|}|j||d|i}||fS7%w)Naddrextra)r| connect_pipe_make_duplex_pipe_transport)r protocol_factoryr,frprotocoltranss r#create_pipe_connectionz(ProactorEventLoop.create_pipe_connectionQsZ NN ' ' 0w#%00x8>7H1Jh s!A A &A cfKtdfd jgSw)NcJd} |ri|j}jj|jr|j y}j ||dij }|yjj|}|_ |jy#t$r9|r#|jdk7r|j jYyt$rz}|r9|jdk7r&jd||d|j n$j rt#j$d|djYd}~yd}~wt&j($r|r|j YyYywxYw) NrrrzPipe accept failed)r2r3rzAccept pipe failed on pipe %rT)exc_info)rHrdiscardrrrrr| accept_piperadd_done_callbackBrokenPipeErrorfilenorr7r9_debugrwarningr CancelledError) rrrr:r,loop_accept_piperr servers r#rz>ProactorEventLoop.start_serving_pipe..loop_accept_pipe\stD) 688:D**2248}} /1H44hvw.?5A335<NN..t4*./*##$45+# 1DKKMR/JJL/0 1DKKMR///#7%( $1 JJL[[NN#B#'$8/00,, !JJL !s1A B7/B7B77?F"8F"A0E55(F"!F"rB)rr)r rr,rrs```@@r#start_serving_pipez$ProactorEventLoop.start_serving_pipeYs2G$+ 6+ 6Z '(xs*1c K|j} t||||||||f| |d| } | d{| S7#ttf$rt$r+| j | j d{7wxYww)N)waiterr) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionr_wait) r rargsshellstdinstdoutstderrbufsizerkwargsrtransps r#_make_subprocess_transportz,ProactorEventLoop._make_subprocess_transports##%,T8T5-2FFG74:%7067 LL  -.    LLN,,.  s1'A>868A>8;A;3A64A;;A>rB) rIrJrKrLrrrrrrMrNs@r#rr6s%<# 1&1j04r$rceZdZdZefdZdZdZdZd!dZ dZ e d Z e d Zd"d Zd"d Zd"d Zd"dZd#dZd"dZdZdZdZdZdZd!dZdZdZdZdZdZdZ d!dZ!dZ"dZ#d Z$y)$rz#Proactor implementation using IOCP.cd|_g|_tjtjt d||_i|_tj|_ g|_ tj|_ yrX) r8_resultsrgCreateIoCompletionPortINVALID_HANDLE_VALUEr_iocp_cacherrrT _unregistered_stopped_serving)r concurrencys r#rzIocpProactor.__init__s_   77  , ,dA{D  "??, ' 1r$c2|j tdy)NzIocpProactor is closed)rrvr\s r# _check_closedzIocpProactor._check_closeds :: 78 8 r$cdt|jzdt|jzg}|j|j dd|j j ddj|dS)Nzoverlapped#=%sz result#=%sr< r))lenrrrrar"rIjoin)r r.s r#__repr__zIocpProactor.__repr__s_ 3t{{#33s4==113 ::  KK ! NN33SXXd^DDr$c||_yrB)r8)r rs r#set_loopzIocpProactor.set_loops  r$Ncz|js|j||j}g|_ |d}S#d}wxYwrB)rr])r timeoutrs r#selectzIocpProactor.selects:}} JJw mm  C$Cs6:c\|jj}|j||SrB)r8rrF)r valuercs r#_resultzIocpProactor._results%jj&&( u r$c |jS#t$rD}|jtjtj fvrt |jd}~wwxYwrB) getresultr7rirgERROR_NETNAME_DELETEDERROR_OPERATION_ABORTEDConnectionResetErrorr)rkeyr!r:s r#finish_socket_funczIocpProactor.finish_socket_funcsY <<> ! || A A + C C EE*CHH55  s A?AAc |j|||S#t$r,}|jtjk(r |dfcYd}~Sd}~wwxYwrB)rr7rirgERROR_PORT_UNREACHABLE)clsrrr! empty_resultr:s r#_finish_recvfromzIocpProactor._finish_recvfromsN ))%b9 9 ||{AAA#T))  s A  AA AA c|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYw)Nr$) _register_with_iocprg Overlappedr isinstancesocketWSARecvrReadFilerr _registerrr connnbytesrr!s r#recvzIocpProactor.recvs   &  # #D ) %$ . 4;;=&%8 DKKM62~~b$(?(?@@ %<<$ $ %AB%%CCc|j|tjt} t |t j r"|j |j||n |j|j||j|||jS#t$r|jdcYSwxYwrX) r rgr rr r  WSARecvIntor ReadFileIntorrrrr rbufrr!s r# recv_intozIocpProactor.recv_intos   &  # #D ) #$ .t{{}c59 s3~~b$(?(?@@ #<<? " #rc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)N)r$Nr$r) r rgr r WSARecvFromrrrrrrrs r#recvfromzIocpProactor.recvfroms   &  # #D ) - NN4;;=&% 8~~b$0E0E=@)BC C -<< , , -!A55BBc*|j|tjt} |j |j |||j||t|jdS#t $r|jdcYSwxYw)NrNrr) r rgr rWSARecvFromIntorrrrrrrs r# recvfrom_intozIocpProactor.recvfrom_intos   &  # #D ) +   t{{}c5 9~~b$0E0E=>)@A A +<< * * +rc|j|tjt}|j |j ||||j |||jSrB)r rgr r WSASendTorrr)r rrrrr!s r#sendtozIocpProactor.sendtosQ   &  # #D ) T[[]C5~~b$(?(?@@r$cH|j|tjt}t |t j r"|j |j||n |j|j||j|||jSrB) r rgr rr r WSASendr WriteFilerrrs r#sendzIocpProactor.sendsq   &  # #D ) dFMM * JJt{{}c5 1 LL ,~~b$(?(?@@r$c||j|jjtjt }|j jjfd}d}|j||}||}tj||j|S)Nc,|jtjdj}j t j tj|jjjfS)Nz@P) rstructpackr setsockoptr  SOL_SOCKETrgSO_UPDATE_ACCEPT_CONTEXT settimeout gettimeout getpeername)rrr!rrlisteners r# finish_acceptz*IocpProactor.accept..finish_accept*sl LLN++dHOO$56C OOF--'@@# G OOH//1 2))++ +r$cvK |d{y7#tj$r|jwxYwwrB)r rr)r4rs r# accept_coroz(IocpProactor.accept..accept_coro3s2  ,,   s 99%69r) r _get_accept_socketfamilyrgr rAcceptExrrr ensure_futurer8)r r5r!r6r8r4corors ` @r#acceptzIocpProactor.accept$s   *&&x7  # #D ) HOO%t{{}5 , Hm<64( Dtzz2 r$cjtjk(rQtjj ||j j}|jd|S|j tjj jtj"t$}|j'j |fd}|j)||S#t$r?}|jtjk7rj!ddk(rYd}~d}~wwxYw)Nrrc|jjtjtj dSrX)rr/r r0rgSO_UPDATE_CONNECT_CONTEXT)rrr!rs r#finish_connectz,IocpProactor.connect..finish_connectVs1 LLN OOF--'AA1 FKr$)typer  SOCK_DGRAMrg WSAConnectrr8rrFr  BindLocalr:r7rierrno WSAEINVAL getsocknamer r ConnectExr)r rr,rcer!rBs ` r#connectzIocpProactor.connect@s 99)) )  " "4;;=' :****,C NN4 J   &   ! !$++- = # #D ) T[[]G, ~~b$77! zzU__,!!$)*  s.D E  5EE c 6|j|tjt}|dz}|dz dz}|j |j t j|j |||dd|j|||jS)Nl r) r rgr r TransmitFilermsvcrt get_osfhandlerr)r sockfileoffsetcountr! offset_low offset_highs r#sendfilezIocpProactor.sendfile_s   &  # #D )k) |{2   ,,T[[];"Kq! % ~~b$(?(?@@r$c|jtjt}|j j }|r|j Sfd}|j||S)Nc(|jSrB)r)rrr!rs r#finish_accept_pipez4IocpProactor.accept_pipe..finish_accept_pipevs LLNKr$)r rgr rConnectNamedPiperrr)r rr! connectedr[s ` r#rzIocpProactor.accept_pipeksf   &  # #D )'' 6 <<% % ~~b$(:;;r$c<Kt} tj|} tj|S#t$r(}|jtj k7rYd}~nd}~wwxYwt |dzt}tj|d{7w)N) CONNECT_PIPE_INIT_DELAYrg ConnectPiper7riERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr r)r r,delayrUr:s r#rzIocpProactor.connect_pipe|s' $009''// <<;#>#>>?   #9:E++e$ $ $s6B6B A'A"B"A''.BBBc(|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)r rUrs r#wait_for_handlezIocpProactor.wait_for_handles $$VWe<.finish_wait_for_handles779 r$r)rrYINFINITEmathceilrgr rRegisterWaitWithQueuerr,rqr8rzrr) r rUr _is_cancelmsr!rVrors @r#rhzIocpProactor._wait_for_handles  ?!!B7S=)B # #D )!77 DJJ B0 !"fk KA!"fk4'+zz3A  ##B' $%b!-C"D BJJr$c||jvrL|jj|tj|j |j ddyyrX)rTrrgrrrr objs r#r z IocpProactor._register_with_iocpsI d&& &     %  . .szz|TZZA N 'r$c^|jt||j}|jr |jd=|js |dd|}|j |||||f|j|j<|S#t $r}|j|Yd}~>d}~wwxYwr) rrr8rr&rFr7rCrr,)r r!rxcallbackrrrKs r#rzIocpProactor._registers  btzz 2  ##B'zz  $ tR0 U#$%b#x"8 BJJ #"" #s B B,B''B,cZ|j|jj|y)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrra)r r!s r#rzIocpProactor._unregisters$  !!"%r$cRtj|}|jd|SrX)r r2)r r:ss r#r9zIocpProactor._get_accept_sockets MM& ! Qr$c "|t}n<|dkr tdtj|dz}|tk\r td t j |j |}|nd}|\}}}} |jj|\}} } } | |j vr|j#nI|j%s9 | ||| } |j'| |j(j+|d}|j0D](} |jj| j2d*|j0j5y#t$rl|jjr%|jjdd||||fzd|dtjfvrtj|Y}wxYw#t,$r7} |j/| |j(j+|Yd} ~ d} ~ wwxYw#d}wxYw)Nrznegative timeoutrmztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r2status)rp ValueErrorrqrrrgGetQueuedCompletionStatusrrpopKeyErrorr8 get_debugr9rrYrrr6donerFrrar7rCrr,r)r rrurerr transferredrr,rr!rxrzrrKs r#r]zIocpProactor._polls ?B q[/0 07S=)BX~ !233 ::4::rJF~B-3 *Cc7 '+{{w'?$2sH d+++ VVX $[#r:E LL'MM((+AMR$$B KKOOBJJ -%   "E ::'')JJ55%7#N&);W%E$F7q+"B"BCC'', ,,OOA&MM((++,AsC4 E G,H A1GG H,H<H HH Hc:|jj|yrB)rrrws r# _stop_servingzIocpProactor._stop_serving2s !!#&r$c4|jyt|jjD]:\}}}}|j rt |t r* |j<d}tj}||z} |jrx| tjkrCtjd|tj|z tj|z} |j!||jrxg|_t%j&|jd|_y#t$rS}|j>++ K!4>>#3j#@B>>+j8 JJz "kk DJJ' ; Czz-'C),&)# 00:=:O:OG$67 99'B CsD;; FAFFc$|jyrB)rr\s r#rzIocpProactor.__del__gs  r$rB)rr!)%rIrJrKrLrprrrrrr staticmethodr classmethodrrrrr#r&r*r>rLrXrrrirrhr rrr9r]rrrrr$r#rrs-#+29E     A A C AAA88> A<"0&= DO@& 7#r' -^r$rceZdZdZy)rc tj|f|||||d|_fd}jjj t jj} | j|y)N)rrrrrc\jj}j|yrB)_procpoll_process_exited)r returncoder s r#rzz4_WindowsSubprocessTransport._start..callbackrs!*J   ,r$) r Popenrr8r|riintrRr) r rrrrrrrrzrs ` r#_startz"_WindowsSubprocessTransport._startmso"(( 'U6&'%'  - JJ 0 0TZZ5G5G1H I H%r$N)rIrJrKrrr$r#rrks &r$rceZdZeZy)rN)rIrJrKr _loop_factoryrr$r#rr}%Mr$rceZdZeZy)rN)rIrJrKrrrr$r#rrrr$r)4rLsysplatform ImportErrorrgrYrG functoolsrrqrPr r-rrrrrr r r r r logr__all__rrpERROR_CONNECTION_REFUSEDERROR_CONNECTION_ABORTEDr`rdFuturerrPrqrzobjectrBaseSelectorEventLooprBaseProactorEventLooprrBaseSubprocessTransportrrBaseDefaultEventLoopPolicyrrrrr$r#rs\4 <<7 l ##   ||    --`G#GNNG#T&-&01P-1Ph88v2 E E2g==gTHHV &/"I"I &.&V%F%F&&V%F%F&8r$__pycache__/selector_events.cpython-312.opt-1.pyc000064400000173316152343231170015636 0ustar00 ֦i̼dZdZddlZddlZddlZddlZddlZddlZddlZddl 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 0/usr/lib64/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_connectionsXwA" )![[] 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*cr|jry |jj|j}|j ||j |j s|jj|j|j|jjd|jr|jdy|jr*|jjt j"yyy#t$t&f$rYyt(t*f$rt,$r}|jj|j|j j/|j1|d|j |jj3|Yd}~yYd}~yd}~wwxYwNr)r;rrr_adjust_leftover_buffer_maybe_resume_protocolr:rGrrrwrr<r_rvshutdownrTSHUT_WRrar`rrrrhrfr)r)rrs rryz'_SelectorSocketTransport._write_sendmsgIsV ??  8ZZ''(@(@(BCF  ( ( 0  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6s:DF6F6/A8F11F6rreturnc|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|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_sendpss ??  8\\))+F 'ACK ''qr 3  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6sA!D..G?GA8GGc|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*c t||d|_|j%|jj t dyy#d|_|j%|jj t dwwxYw)NzConnection is closed by peer)rr_rzrwrConnectionError)r)rr"s rr_z._SelectorSocketTransport._call_connection_losts E G )# . $D !!-""00#$BCE.!%D !!-""00#$BCE.s A :Bc|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*c0d|_t| yr/)rurrJrKs 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 )E""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#--_4DZ1Zzl1!3Z5Q5Ql1Y% C$  s#C&:C3&C0/C03C=<C=__pycache__/mixins.cpython-312.opt-1.pyc000064400000002006152343231170013724 0ustar00 ֦iRdZddlZddlmZejZGddZy)zEvent loop mixins.N)eventsceZdZdZdZy)_LoopBoundMixinNctj}|j"t5|j||_ddd||jurt |d|S#1swY'xYw)Nz# is bound to a different event loop)r_get_running_loop_loop _global_lock RuntimeError)selfloops '/usr/lib64/python3.12/asyncio/mixins.py _get_loopz_LoopBoundMixin._get_loop sa'') :: ::%!%DJ tzz !$)LMN N s A!!A*)__name__ __module__ __qualname__r rrrr s E rr)__doc__ threadingrLockr rrrrrs&y~~   r__pycache__/selector_events.cpython-312.opt-2.pyc000064400000167365152343231170015646 0ustar00 ֦i̼ dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd lmZeejd Zer ej2dZdZGdde j:ZGddej>ej@Z!Gdde!Z"Gdde!ejFZ$y#e $rdZ YwxYw#e$rdZYpwxYw))BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggersendmsg SC_IOV_MAXFct |j|}t|j|zS#t$rYywxYwNF)get_keyboolrKeyError)selectorfdeventkeys 0/usr/lib64/python3.12/asyncio/selector_events.py_test_selector_eventr*sA(r"CJJ&'' s + 77ceZdZ d2fd Zd2ddddZ d2ddddej ejddZ d3dZ fd Z d Z d Z d Z d ZdZdddej ejfdZdddej ejfdZddej ejfdZdZdZdZdZdZdZdZdZdZdZd2dZdZdZd Z d!Z!d"Z"d4d#Z#d$Z$d%Z%d&Z&d'Z'd(Z(d)Z)d*Z*d2d+Z+d,Z,d-Z-d.Z.d/Z/d0Z0d1Z1xZ2S)5rNct||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_connectionsXwA" )![[] 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$rYywxYwNFT) rHr$rrr\rr unregisterrrrr)rrrrrs rrMz$BaseSelectorEventLoop._remove_reader&s >>  ..((,C&)ZZ "D"66 Y))) )D))"-%%b$v?!   sB// 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$rYywxYwr) rHr$rrr\rrrrrrrs r_remove_writerz$BaseSelectorEventLoop._remove_writerKs' >>  ..((,C&)ZZ "D"66 Y*** *D))"-%%b$?!   sB00 B<;B<cP |j||j||g|yr/)r0rWr)rrrs r add_readerz BaseSelectorEventLoop.add_readerbs*$ $$R(X--r*cH |j||j|Sr/)r0rMr)rs r remove_readerz#BaseSelectorEventLoop.remove_readerg$' $$R(""2&&r*cP |j||j||g|yr/)r0rrs r add_writerz BaseSelectorEventLoop.add_writerls*% $$R(X--r*cH |j||j|Sr/)r0rrs r remove_writerz#BaseSelectorEventLoop.remove_writerqrr*cK tj||jr|jdk7r t d |j |S#t tf$rYnwxYw|j}|j}|j||j||j|||}|jtj|j |||d{7SwNrthe socket must be non-blockingr)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 Hyy7AC6AC6A'$C6&A''B C60C31C6cL||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 " " #rcK tj||jr|jdk7r t d |j |S#t tf$rYnwxYw|j}|j}|j||j||j|||}|jtj|j |||d{7Swr)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 " " #rcK tj||jr|jdk7r t d|s t |} |j ||S#ttf$rYnwxYw|j}|j}|j||j||j||||}|jtj |j"|||d{7Swr)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 Hyys7ADA#"D#A52D4A55B D?DDc|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 *K tj||jr|jdk7r t d |j |}|t|k(ry|j}|j}|j||j||j||t||g}|jt!j"|j$|||d{S#t tf$rd}YwxYw7wr)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 s7ADC:B D5D6D:D D DDc:|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?BBcK tj||jr|jdk7r t d |j ||S#t tf$rYnwxYw|j}|j}|j||j||j||||}|jtj|j |||d{7Swr)rrrhrrsendtorar`rrOr0r _sock_sendtorrrr)r)r2r\rCrrrs r sock_sendtoz!BaseSelectorEventLoop.sock_sendtoMs  %%d+ ;;4??,1>? ? ;;tW- -!12     " [[] $$R(!!"d&7&7dD")+    d33R G Iyys7AC8AC8A(%C8'A((B C82C53C8c|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"K tj||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)Nrr)familytypeprotoloop)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<CDD2D8D=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,B11B44B8cK tj||jr|jdk7r t d|j }|j |||d{S7w)Nrr)rrrhrrr _sock_accept)r)r2rs r sock_acceptz!BaseSelectorEventLoop.sock_acceptsd  %%d+ ;;4??,1>? ?  " #t$yysA(A1*A/+A1c|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)3r# __module__ __qualname__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#rappendr9r_looprHrr$rrrget_write_buffer_sizeformatjoin)r)infor?staters 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) _protocolr2)r)r3s rr3z_SelectorTransport.set_protocolFs!#' r*c|jSr/)rPrRs r get_protocolz_SelectorTransport.get_protocolJs ~~r*c|jSr/)r9rRs 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:rDrMr 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) r9r:rWr _read_readyrDrVr 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) r9rDrMrr7r8r 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) rrgrDrVr r!rrPrL)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|yrZ) r8r7clearrDrrr9rMr[r\)r)rs rrLz_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/)r2rPconnection_lostrrJrDr4_detach)r)rr-s rr\z(_SelectorTransport._call_connection_losts $''..s3 JJ   DJ!DNDJ\\F! # " JJ   DJ!DNDJ\\F! # "s 'A??ACcHttt|jSr/)summaprr7rRs rrEz(_SelectorTransport.get_write_buffer_sizes3sDLL)**r*cb|jsy|jj||g|yr/)rrDrWrs rrWz_SelectorTransport._add_readers*  r83d3r*)NN)zFatal error on transport)r#r$r%max_sizerrrJrMr3rRrrrrrJwarningswarnrarcrLr\rErWr(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_nodelayrrDr[rPconnection_maderWrrXr_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_bufferrr_read_ready__data_receivedrr3)r)r3r"s rr3z%_SelectorSocketTransport.set_protocols< h : : ;"&">">D "&"A"AD  X&r*c$|jyr/)rrrRs rrXz$_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.)r8rP get_bufferrrGrrrrcrrrar`_read_ready__on_eofbuffer_updated)r)rrrs rr~z0_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.) r8rr_rmrar`rrrrcrrP 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.) rDrVr r!rP eof_receivedrrrrcrMrrJ)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#rsrGrtr8r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningr7rrfrar`rrrrcrDrrrwrC_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/) itertoolsislicer7rrRs r_get_sendmsg_bufferz,_SelectorSocketTransport._get_sendmsg_bufferFs j99r*cr|jry |jj|j}|j ||j |j s|jj|j|j|jjd|jr|jdy|jr*|jjt j"yyy#t$t&f$rYyt(t*f$rt,$r}|jj|j|j j/|j1|d|j |jj3|Yd}~yYd}~yd}~wwxYwNr)r8rrr_adjust_leftover_buffer_maybe_resume_protocolr7rDrrrtrr9r\rsshutdownrTSHUT_WRrar`rrrrercr)r)rrs rrvz'_SelectorSocketTransport._write_sendmsgIsV ??  8ZZ''(@(@(BCF  ( ( 0  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6s:DF6F6/A8F11F6rreturnc|j}|r?|j}t|}||kr||z}n|j||dy|r>yyr/)r7popleftr appendleft)r)rbufferbb_lens rrz0_SelectorSocketTransport._adjust_leftover_bufferesO AFE%!!!FG*-r*c|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)r8r7rrrfrrrrDrrrtrr9r\rsrrTrrar`rrrrercr)r)rrrs rrxz$_SelectorSocketTransport._write_sendpss ??  8\\))+F 'ACK ''qr 3  ' ' )<< ))$--8%%1&&11$7==..t4YYJJ''7   !12  -.   6 JJ % %dmm 4 LL     c#J K!!-""0055.  6sA!D..G?GA8GGc|js |jryd|_|js*|jj t j yyrO)r9rsr7rrrTrrRs 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) rsrGrtr7extendrrwrDrrr)r) list_of_datar\s r writelinesz#_SelectorSocketTransport.writeliness 99KL L    )NO O  ,G,$Z-,GH  << JJ " "4==$2C2C D  & & ( Hs CcyrOrZrRs r can_write_eofz&_SelectorSocketTransport.can_write_eofsr*c t||d|_|j%|jj t dyy#d|_|j%|jj t dwwxYw)NzConnection is closed by peer)rr\rwrtrConnectionError)r)rr"s rr\z._SelectorSocketTransport._call_connection_losts E G )# . $D !!-""00#$BCE.!%D !!-""00#$BCE.s A :Bc|j td|jj|_|js|jj d|jS)NzEmpty waiter is already set)rtrGrDrr7rrRs rrz+_SelectorSocketTransport._make_empty_waitersV    )<= =!ZZ557||    ) )$ /!!!r*cd|_yr/)rtrRs rrz,_SelectorSocketTransport._reset_empty_waiters !r*c0d|_t| yr/)rrrrJrKs rrJz_SelectorSocketTransport.closes"  r*r#)r#r$r%_start_tls_compatibler _SendfileMode TRY_NATIVE_sendfile_compatiblerr3rXr~rrrrrvrrrxrrrr\rrrJr(r)s@rr1r1s $22==48$(/2'#LJK2*%%N:88 c d 8>0 )E""r*r1cVeZdZejZ dfd ZdZdZddZ dZ xZ S)rBcxt|||||||_d|_|jj |j j||jj |j|j|j|,|jj tj|dyyr) rr_address _buffer_sizerDr[rPrzrWrrXrr{)r)rr2r3rCr4r,r"s rrz#_SelectorDatagramTransport.__init__s tXu5  T^^;;TB T--!]]D,<,< >   JJ !E!E!' / r*c|jSr/)rrRs rrEz0_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)r8rrrmrPdatagram_receivedrar`rgerror_receivedrrrrcr)r\rrs rrXz&_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#rrr8rrr rr7r.rrfrrar`rDrr _sendto_readyrgrPrrrrrcrCrrrrs 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)r7rrrr.rrfrrar`rrgrPrrrrrcrrDrrr9r\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%r5r6_buffer_factoryrrErXrrr(r)s@rrBrBs.!''O59$( /!9 *%X1r*rB)%__all__r5rzrrosrrTrnr&ssl ImportErrorrrrrr r r r logr hasattrrusysconfrrgr BaseEventLoopr_FlowControlMixin Transportr+r1DatagramTransportrBrZr*rrs #   v}}i0 RZZ - (I K55I X_455#--_4DZ1Zzl1!3Z5Q5Ql1Y% C$  s#C%9C2%C/.C/2C<;C<__pycache__/sslproto.cpython-312.opt-2.pyc000064400000111753152343231170014315 0ustar00 ֦i|zddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl m Z eejejfZGdd ejZGd d ejZd Zd ZGdde j(e j*ZGddej.Zy#e$rdZYwxYw)N) constants) exceptions) protocols) transports)loggerc eZdZdZdZdZdZdZy)SSLProtocolState UNWRAPPED DO_HANDSHAKEWRAPPEDFLUSHINGSHUTDOWNN)__name__ __module__ __qualname__r r r rr)/usr/lib64/python3.12/asyncio/sslproto.pyr r sI!LGHHrr ceZdZdZdZdZdZy)AppProtocolState STATE_INITSTATE_CON_MADE STATE_EOFSTATE_CON_LOSTN)rrrrrrrrrrrrsJ%NI%NrrcZ|r tdtj}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslcreate_default_contextcheck_hostname) server_sideserver_hostname sslcontexts r_create_transport_contextr$/s2CDD ++-J $) ! rc|||dz}n |}d|z}n|}||dz}n|}||cxk\rdk\sntd|d|d||fS)Nirzhigh (z) must be >= low (z) must be >= 0)r)highlowkbhilos radd_flowcontrol_defaultsr,=sh | ;dBBRB  { 1W  =q=b"# # r6MrceZdZdZej j ZdZddZ dZ dZ dZ dZ efd Zd Zd Zd Zdd ZdZdZddZdZdZedZdZdZdZdZdZdZ dZ!y)_SSLProtocolTransportTc.||_||_d|_yNF)_loop _ssl_protocol_closed)selfloop ssl_protocols r__init__z_SSLProtocolTransport.__init__Xs ) rNc< |jj||SN)r2_get_extra_infor4namedefaults rget_extra_infoz$_SSLProtocolTransport.get_extra_info]s1!!11$@@rc:|jj|yr9)r2_set_app_protocol)r4protocols r set_protocolz"_SSLProtocolTransport.set_protocolas ,,X6rc.|jjSr9)r2 _app_protocolr4s r get_protocolz"_SSLProtocolTransport.get_protocolds!!///rcR|jxs|jjSr9)r3r2_is_transport_closingrEs r is_closingz _SSLProtocolTransport.is_closinggs ||It11GGIIrcp |js"d|_|jjyd|_yNT)r3r2_start_shutdownrEs rclosez_SSLProtocolTransport.closejs1 ||DL    . . 0!%D rcX|jsd|_|jdtyy)NTz9unclosed transport )r3warnResourceWarning)r4 _warningss r__del__z_SSLProtocolTransport.__del__xs)||DL NN* ,rc0|jj Sr9)r2_app_reading_pausedrEs r is_readingz _SSLProtocolTransport.is_readings%%9999rc: |jjyr9)r2_pause_readingrEs r pause_readingz#_SSLProtocolTransport.pause_readings ))+rc: |jjyr9)r2_resume_readingrEs rresume_readingz$_SSLProtocolTransport.resume_readings **,rcr |jj|||jjyr9)r2_set_write_buffer_limits_control_app_writingr4r'r(s rset_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limitss1 $ 33D#> //1rcZ|jj|jjfSr9)r2_outgoing_low_water_outgoing_high_waterrEs rget_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits*""66""779 9rc8 |jjSr9)r2_get_write_buffer_sizerEs rget_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_sizes;!!88::rcr |jj|||jjyr9)r2_set_read_buffer_limits_control_ssl_readingr_s rset_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limitss1 $ 224= //1rcZ|jj|jjfSr9)r2_incoming_low_water_incoming_high_waterrEs rget_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limitsrerc8 |jjSr9)r2_get_read_buffer_sizerEs rget_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_sizes9!!7799rc.|jjSr9)r2_app_writing_pausedrEs r_protocol_pausedz&_SSLProtocolTransport._protocol_pauseds!!555rc t|tttfs!t dt |j |sy|jj|fy)Nz+data: expecting a bytes-like instance, got ) isinstancebytes bytearray memoryview TypeErrortyperr2_write_appdatar4datas rwritez_SSLProtocolTransport.writes] $ : >?##':#6#6"79: :  ))4'2rc< |jj|yr9)r2r~)r4 list_of_datas r writelinesz _SSLProtocolTransport.writeliness )),7rc tr9)NotImplementedErrorrEs r write_eofz_SSLProtocolTransport.write_eofs "!rc yr0rrEs r can_write_eofz#_SSLProtocolTransport.can_write_eofsOrc( |jdyr9) _force_closerEs rabortz_SSLProtocolTransport.aborts $rcbd|_|j|jj|yyrK)r3r2_abortr4excs rrz"_SSLProtocolTransport._force_closes.    )    % %c * *rc|jjj||jxjt |z c_yr9)r2_write_backlogappend_write_buffer_sizelenrs r_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7 ))006 --T:-rr9NN)"rrr_start_tls_compatibler _SendfileModeFALLBACK_sendfile_compatibler7r>rBrFrIrMwarningsrRrUrXr[r`rdrhrlrprspropertyrvrrrrrrrrrrr.r.Rs!$22;; A70J &!),:,-2,9;2,9:66 38" + ;rr.c eZdZdZdZdZdZ d+dZdZd,dZ dZ dZ dZ d Z d Zd Zd Zd,d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d-d"Z&d#Z'd$Z(d%Z)d-d&Z*d'Z+d(Z,d)Z-d.d*Z.y)/ SSLProtocoliNc t tdt|j|_t |j|_|tj}n|dkrtd|| tj} n| dkrtd| |s t||}||_ |r |s||_ nd|_ ||_t||_t#j$|_d|_||_||_|j/|d|_d|_d|_||_| |_tj:|_tj:|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j|_)d|_*d|_+d|_,d|_-d|_.|j_d|_0d|_1d|_2d|_3|ji|jky)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r RuntimeErrorrzmax_size _ssl_bufferr{_ssl_buffer_viewrSSL_HANDSHAKE_TIMEOUTrSSL_SHUTDOWN_TIMEOUTr$ _server_side_server_hostname _sslcontextdict_extra collectionsdequerr_waiterr1r@_app_transport_app_transport_created _transport_ssl_handshake_timeout_ssl_shutdown_timeout MemoryBIO _incoming _outgoingr r _state _conn_lostrr _app_staterwrap_bio_sslobj_ssl_writing_pausedrT_ssl_reading_pausedrornrj _eof_receivedrurcrbr]_get_app_transport) r4r5 app_protocolr#waiterr!r"call_connection_madessl_handshake_timeoutssl_shutdown_timeouts rr7zSSLProtocol.__init__sE ;@A A$T]]3 *4+;+; < ($-$C$C ! "a ',-/0 0 '#,#A#A !Q &+,./ /2_.J( ;$3D !$(D !%j1 *//1"#   |,"&+#&;#%9"&00  .99DO.==DO''00 NNDNN)) 1113 $) #( #( $%!#$  $$&"#( $%!#$  %%' !rc||_t|drDt|tjr*|j |_|j|_d|_ yd|_ y)N get_bufferTF) rDhasattrrxrBufferedProtocolr_app_protocol_get_bufferbuffer_updated_app_protocol_buffer_updated_app_protocol_is_buffer)r4rs rr@zSSLProtocol._set_app_protocolasP) L, /<)C)CD,8,C,CD )0<0K0KD -+/D (+0D (rc|jy|jjs@|#|jj|d|_y|jjdd|_yr9)r cancelled set_exception set_resultrs r_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ <<  ||%%' **3/  ''- rc|j9|jr tdt|j||_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)rrrr.r1rEs rrzSSLProtocol._get_app_transportvsJ    &**"#IJJ"7 D"ID *.D '"""rcV|jduxr|jjSr9)rrIrEs rrHz!SSLProtocol._is_transport_closing~s#d*Kt/I/I/KKrc4 ||_|jyr9)r_start_handshake)r4 transports rconnection_madezSSLProtocol.connection_mades $ rcJ |jj|jj|xjdz c_|j d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$||j'tj(d|_d|_d|_|j-||j.r!|j.j1d|_|j2r"|j2j1d|_yy)NrT)rclearrreadrrr3rr r rrrrrr1 call_soonrDconnection_lost _set_stater rr_shutdown_timeout_handlecancel_handshake_timeout_handlers rrzSSLProtocol.connection_losts> !!#  1    **.D   ' ;;*77 7#3#B#BB#3#=#=="2"A"A $$T%7%7%G%GM (223"! C  ( (  ) ) 0 0 2,0D )  ) )  * * 1 1 3-1D * *rc|}|dks||jkDr |j}t|j|kr*t||_t |j|_|j SNr)rrrrzr{r)r4nwants rrzSSLProtocol.get_buffers` 19t}},==D t 4 '(D $.t/?/?$@D !$$$rc|jj|jd||jtj k(r|j y|jtjk(r|jy|jtjk(r|jy|jtjk(r|jyyr9) rrrrr r _do_handshaker _do_readr _do_flushr _do_shutdown)r4nbytess rrzSSLProtocol.buffer_updateds T227F;< ;;*77 7    [[,44 4 MMO [[,55 5 NN  [[,55 5    6rc d|_ |jjrtjd||j t jk(r|jty|j t jk(r=|jt j|jry|jy|j t jk(r@|j|jt j |j#y|j t j k(r|j#yy#t$$r|j&j)wxYw)NTz%r received EOF)rr1 get_debugrdebugrr r _on_handshake_completeConnectionResetErrorr rrrTr _do_writerr ExceptionrrMrEs r eof_receivedzSSLProtocol.eof_receiveds " zz##% .5{{.;;;++,@A 0 8 88 0 9 9:++NN$ 0 9 99  0 9 9:!!# 0 9 99!!#:  OO ! ! #  s&A"E-AE6EAE$-E%E8c||jvr|j|S|j|jj||S|Sr9)rrr>r;s rr:zSSLProtocol._get_extra_infosC 4;; ;;t$ $ __ (??11$@ @Nrc&d}|tjk(rd}n|jtjk(r|tjk(rd}n|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tj k(rd}|r||_ytdj|j|)NFTz!cannot switch state from {} to {}) r r rr r rrrformat)r4 new_statealloweds rrzSSLProtocol._set_states (22 2G KK+55 5 )66 6G KK+88 8 )11 1G KK+33 3 )22 2G KK+44 4 )22 2G #DK3::KK,- -rcnjjr6tjdjj _nd_j tjjjjfd_ jy)Nz%r starts SSL handshakec$jSr9)_check_handshake_timeoutrEsrz.SSLProtocol._start_handshake..$s$*G*G*Ir) r1rrrtime_handshake_start_timerr r call_laterrrrrEs`rrzSSLProtocol._start_handshakes ::   ! LL2D 9)-):D &)-D & (556 JJ ! !$"="="I K & rc|jtjk(r+d|jd}|j t |yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)rr r r _fatal_errorConnectionAbortedError)r4msgs rrz$SSLProtocol._check_handshake_timeout(sN ;;*77 76../0*+    4S9 : 8rc |jj|jdy#t$r|j Yyt j $r}|j|Yd}~yd}~wwxYwr9)r do_handshakerSSLAgainErrors_process_outgoingrSSLErrorrs rrzSSLProtocol._do_handshake1sb . LL % % '  ' ' -  %  " " $|| -  ' ' , , -s.A6 A6A11A6c|j!|jjd|_|j} | |jtj n||j }|jjrA|jj!|j"z }t%j&d||dz|j(j+||j-|j/||j0t2j4k(r>t2j6|_|j8j;|j=|j|j?y#t$rm}d}|jtjt|tjrd}nd}|j|||j|Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compression ssl_object) rrrrr r getpeercertrr rxrCertificateErrorrrr1rrrrrrupdater r rrrrrDrrr)r4 handshake_excsslobjr rrdts rrz"SSLProtocol._on_handshake_complete;s  ) ) 5  * * 1 1 3-1D * $ 0 8 89##))+H ::   !"T%?%??B LL94c J H"(--/'-'9'9';&,  . ??.99 9.==DO    . .t/F/F/H I  1  M OO,66 7#s334I,   c3 '    $  s4F G7 A#G22G7cjtjtjtjfvryj dj _jtjk(rjdyjtjjjjfd_ jy)NTc$jSr9)_check_shutdown_timeoutrEsrrz-SSLProtocol._start_shutdown..us446r)rr rrr rr3r rrr1rrrrrEs`rrLzSSLProtocol._start_shutdownds KK )) )) **      **.D   ' ;;*77 7 KK  OO,55 6,0JJ,A,A**6-D ) NN rc|jtjtjfvr/|jj t jdyy)NzSSL shutdown timed out)rr rrrrr TimeoutErrorrEs rrz#SSLProtocol._check_shutdown_timeoutysN KK )) ))  OO ( (''(@A C  rc|j|jtj|j yr9)rrr rrrEs rrzSSLProtocol._do_flushs*  (112 rcJ |js|jj|j|j |j dy#t $r|jYytj$r}|j |Yd}~yd}~wwxYwr9) rrunwrapr_call_eof_received_on_shutdown_completerrrrs rrzSSLProtocol._do_shutdowns -%% ##%  " " $  # # %  & &t , %  " " $|| ,  & &s + + ,s&AB"5B"BB"c|j!|jjd|_|r|j|y|jj |j j yr9)rrrr1rrrM)r4 shutdown_excs rrz!SSLProtocol._on_shutdown_completesU  ( ( 4  ) ) 0 0 2,0D )    l + JJ !6!6 7rc|jtj|j|jj |yyr9)rr r rrrs rrzSSLProtocol._aborts6 (223 ?? & OO ( ( - 'rc8|jtjtjtjfvrH|j t jk\rtjd|xj dz c_y|D];}|jj||xjt|z c_ = |jtjk(r|jyy#t $r}|j#|dYd}~yd}~wwxYw)NzSSL connection is closedrFatal error on SSL protocol)rr rrr rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrrrr rrr)r4rrexs rr~zSSLProtocol._write_appdatas KK )) )) **  )"M"MM9: OOq O  D    & &t ,  # #s4y 0 #! A{{.666 7 A   b"? @ @ As-C44 D=DDc~ |jr|jd}|jj|}t|}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr|j y#t $rYwxYwr)rrrrrrr)r4rcountdata_lens rrzSSLProtocol._do_writes %%**1- **40t98#-1%&\D''*++u4+++A.++x7+%%     sBB00 B<;B<c|js@|jj}t|r|jj ||j yr9)rrrrrrr^rs rrzSSLProtocol._process_outgoingsB''>>&&(D4y%%d+ !!#rc|jtjtjfvry |jsZ|j r|j n|j|jr|jn|j|jy#t$r}|j|dYd}~yd}~wwxYw)Nr!)rr r rrTr_do_read__buffered_do_read__copiedrrrrkrr)r4r$s rrzSSLProtocol._do_reads KK (( ))    A++//++-))+&&NN$**,  % % ' A   b"? @ @ AsA6B&& C /CC cd}d}jj}t|} jj ||}|dkDrY|}||kr4jj ||z ||d}|dkDr||z }nn$||kr4j j fd|dkDrj||s!jjyy#t$rYEwxYw)Nrrc$jSr9)rrEsrrz0SSLProtocol._do_read__buffered..s r) rrrrrrr1rrrrrL)r4offsetr&bufwantss` rr*zSSLProtocol._do_read__buffereds++D,F,F,HIC LL%%eS1Eqyun LL--efnc&'lKEqy% unJJ(()@A A:  - -f 5  # # %  "    sAC% C%% C10C1cd}d}d} |jj|j}|sn$|rd}d}|}n|rd}|g}nj|L |r|j j n,|s*|j j dj|s!|j|jyy#t$rYywxYw)N1TFr) rrrrrrD data_receivedjoinrrL)r4chunkzeroonefirstrs rr+zSSLProtocol._do_read__copied s  ))$--8 DC!EC!5>DKK&     , ,U 3    , ,SXXd^ <  # # %  "    sA C CCc> |jtjk(rHtj|_|jj }|rt jdyyy#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received()) rrrrrDrrr#KeyboardInterrupt SystemExit BaseExceptionr)r4 keep_openr$s rrzSSLProtocol._call_eof_received(s B"2"A"AA"2"<"< ..;;= NN$BCB ":.   B   b"@ A A BsA#A((BBBcZ|j}||jk\r/|js#d|_ |jj y||jkr0|jr#d|_ |jjyyy#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exceptionrrAFz protocol.resume_writing() failed) rgrcrurD pause_writingr:r;r<r1call_exception_handlerrrbresume_writing)r4sizers rr^z SSLProtocol._control_app_writing7s$**, 4,, ,T5M5M'+D $ ""002T-- -$2J2J',D $ ""1133K -&z2    11@!$!%!4!4 $ 3 &z2    11A!$!%!4!4 $ 3 s/B2CC'*CCD*6*D%%D*cH|jj|jzSr9)rpendingrrEs rrgz"SSLProtocol._get_write_buffer_sizeTs~~%%(?(???rc\t||tj\}}||_||_yr9)r,r!FLOW_CONTROL_HIGH_WATER_SSL_WRITErcrbr_s rr]z$SSLProtocol._set_write_buffer_limitsWs., #yBBD c$(!#& rcd|_yrK)rTrEs rrWzSSLProtocol._pause_reading_s #' rcnjr(d_fd}jj|yy)NFcjtjk(rjyjtjk(rj yjtj k(rjyyr9)rr r rrrrrrEsrresumez+SSLProtocol._resume_reading..resumefs`;;"2":"::MMO[[$4$=$==NN$[[$4$=$==%%'>r)rTr1r)r4rMs` rrZzSSLProtocol._resume_readingbs2  # #',D $ ( JJ  ( $rc|j}||jk\r.|js"d|_|jj y||j kr/|jr"d|_|jj yyy)NTF)rrrorrrXrnr[)r4rEs rrkz SSLProtocol._control_ssl_readingqsu))+ 4,, ,T5M5M'+D $ OO ) ) + T-- -$2J2J',D $ OO * * ,3K -rc\t||tj\}}||_||_yr9)r,r FLOW_CONTROL_HIGH_WATER_SSL_READrornr_s rrjz#SSLProtocol._set_read_buffer_limitszs., #yAAC c$(!#& rc.|jjSr9)rrGrEs rrrz!SSLProtocol._get_read_buffer_sizes~~%%%rc d|_yrK)rrEs rrBzSSLProtocol.pause_writings $( rc4 d|_|jyr0)rrrEs rrDzSSLProtocol.resume_writings $)   rcf|jr|jj|t|tr5|jj rt jd||dyyt|tjs+|jj|||j|dyy)Nz%r: %sT)exc_infor?) rrrxOSErrorr1rrrrCancelledErrorrC)r4rr@s rrzSSLProtocol._fatal_errors ?? OO ( ( - c7 #zz##% XtWtD&C!:!:; JJ - -" !__ / ras  ?**C,?,?@Ntyy &tyy & *r;J88&00r;jZ ),,Z { CsB00B:9B:__pycache__/transports.cpython-312.pyc000064400000033266152343231170013711 0ustar00 ֦i)dZdZGddZGddeZGddeZGdd eeZGd d eZGd d eZGddeZy)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc<eZdZdZdZd dZd dZdZdZdZ d Z y) rzBase class for transports._extraNc|i}||_yNr )selfextras +/usr/lib64/python3.12/asyncio/transports.py__init__zBaseTransport.__init__s =E c:|jj||S)z#Get optional transport information.)r get)r namedefaults rget_extra_infozBaseTransport.get_extra_infos{{tW--rct)z2Return True if the transport is closing or closed.NotImplementedErrorr s r is_closingzBaseTransport.is_closing!!rct)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. rrs rclosezBaseTransport.close "!rct)zSet a new protocol.r)r protocols r set_protocolzBaseTransport.set_protocol%rrct)zReturn the current protocol.rrs r get_protocolzBaseTransport.get_protocol)rrr ) __name__ __module__ __qualname____doc__ __slots__rrrrr"r$rrrr s($I .""""rrc&eZdZdZdZdZdZdZy)rz#Interface for read-only transports.r*ct)z*Return True if the transport is receiving.rrs r is_readingzReadTransport.is_reading3rrct)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. rrs r pause_readingzReadTransport.pause_reading7 "!rct)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. rrs rresume_readingzReadTransport.resume_reading?r0rN)r%r&r'r(r)r-r/r2r*rrrr.s-I"""rrcFeZdZdZdZd dZdZdZdZdZ d Z d Z d Z y) rz$Interface for write-only transports.r*Nct)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. rr highlows rset_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs &"!rct)z,Return the current size of the write buffer.rrs rget_write_buffer_sizez$WriteTransport.get_write_buffer_sizebrrct)zGet the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.rrs rget_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs "!rct)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. r)r datas rwritezWriteTransport.writelr0rcHdj|}|j|y)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. rN)joinr?)r list_of_datar>s r writelineszWriteTransport.writelinests xx % 4rct)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. rrs r write_eofzWriteTransport.write_eof} "!rct)zAReturn True if this transport supports write_eof(), False if not.rrs r can_write_eofzWriteTransport.can_write_eofrrctzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. rrs rabortzWriteTransport.abortrFrNN) r%r&r'r(r)r8r:r<r?rCrErHrKr*rrrrHs2.I"*"" """"rrceZdZdZdZy)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r*N)r%r&r'r(r)r*rrrrs(Irrc"eZdZdZdZddZdZy)rz(Interface for datagram (UDP) transports.r*Nct)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. r)r r>addrs rsendtozDatagramTransport.sendtorrctrJrrs rrKzDatagramTransport.abortrFrr )r%r&r'r(r)rQrKr*rrrrs2I""rrc4eZdZdZdZdZdZdZdZdZ y) rr*ct)zGet subprocess id.rrs rget_pidzSubprocessTransport.get_pidrrct)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode rrs rget_returncodez"SubprocessTransport.get_returncoder0rct)z&Get transport for pipe with number fd.r)r fds rget_pipe_transportz&SubprocessTransport.get_pipe_transportrrct)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal r)r signals r send_signalzSubprocessTransport.send_signalr0rct)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate rrs r terminatezSubprocessTransport.terminates "!rct)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill rrs rkillzSubprocessTransport.kills "!rN) r%r&r'r)rUrWrZr]r_rar*rrrrs%I"""" " "rrcPeZdZdZdZd fd ZdZdZdZd dZ d dZ d Z xZ S) _FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_watercht|||J||_d|_|j y)NF)superrrdre_set_write_buffer_limits)r rloop __class__s rrz_FlowControlMixin.__init__s7  % %%'rc@|j}||jkry|js#d|_ |jj yy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exception transportr!) r:rfre _protocol pause_writing SystemExitKeyboardInterrupt BaseExceptionrdcall_exception_handler)r sizeexcs r_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols))+ 4## # $$$(D ! ,,.% 12    11@!$!% $ 3 sAB)*BBc<|jrA|j|jkr#d|_ |jj yyy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NFz protocol.resume_writing() failedrn) rer:rgrrresume_writingrtrurvrdrw)r rys r_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's  ! !**,?$)D ! --/@ "  12    11A!$!% $ 3 sAB'*BBc2|j|jfSr )rgrfrs rr<z)_FlowControlMixin.get_write_buffer_limits7s!1!122rc| |d}nd|z}||dz}||cxk\rdk\sntd|d|d||_||_y)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorrfrgr5s rrjz*_FlowControlMixin._set_write_buffer_limits:sh <{ 3w ;!)Csa 23'HJ J rcJ|j|||jy)N)r6r7)rjrzr5s rr8z)_FlowControlMixin.set_write_buffer_limitsJs! %%4S%9 ""$rctr rrs rr:z'_FlowControlMixin.get_write_buffer_sizeNs!!rrL) r%r&r'r(r)rrzr}r<rjr8r: __classcell__)rls@rrcrcs3 KI($ 3 %"rrcN) r(__all__rrrrrrrcr*rrrsj  """"J"M"4I"]I"X ~0" "23"-3"lT" T"r__pycache__/__init__.cpython-312.opt-2.pyc000064400000002577152343231170014172 0ustar00 ֦i ddlZddlddlddlddlddlddlddlddlddl ddl ddl ddl ddl ddlddlddlej"ej"zej"zej"zej"zej"zej"zej"ze j"ze j"ze j"ze j"ze j"zej"zej"zej"zZej$dk(rddleej"z Zyddleej"z Zy)N)*win32)sys base_events coroutinesevents exceptionsfutureslocks protocolsrunnersqueuesstreams subprocesstasks taskgroupstimeoutsthreads transports__all__platformwindows_events unix_events)/usr/lib64/python3.12/asyncio/__init__.pyrsZ-         >>      ??   ==        ??  >>  ??      ==      ??         "<<7! ~%%%G {"""Gr__pycache__/proactor_events.cpython-312.opt-2.pyc000064400000125222152343231170015641 0ustar00 ֦i܂ dZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZd ZGddej(ej*ZGddeej.ZGddeej2ZGddeZGddeej8ZGddeeej<ZGddeeej<Z Gdde jBZ"y))BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggerctj||jd< |j|jd<d|jvr |j|jd<yy#tj $r5|j jrtjd|dYuwxYw#tj $rd|jd<YywxYw)Nsocketsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extra getsocknamererror_loop get_debugr warning getpeername) transportsocks 0/usr/lib64/python3.12/asyncio/proactor_events.py_set_socket_extrars!'!7!7!=IXC'+'7'7'9 $ ))) 0+/+;+;+=I  Z (* <<C ?? $ $ & NN,dT CC|| 0+/I  Z ( 0s$A/B:/AB76B7:"CCceZdZ d fd ZdZdZdZdZdZdZ e jfdZ dd Z d Zd Zd ZxZS)_ProactorBasePipeTransportct||||j|||_|j |||_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ |j |j j|jj!|j"j$||,|jj!t&j(|dyy)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing_called_connection_lost _eof_written_attachr call_soon _protocolconnection_mader_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__s rr$z#_ProactorBasePipeTransport.__init__2s %   (#   ',$! << # LL " T^^;;TB   JJ !E!E!' / c|jjg}|j|jdn|jr|jd|j,|jd|jj |j |jd|j |j|jd|j|jr'|jdt|j|jr|jddjd j|S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r=__name__r&appendr.filenor*r+r)lenr0formatjoin)r7infos r__repr__z#_ProactorBasePipeTransport.__repr__Is''( ::  KK ! ]] KK " :: ! KK#djj//123 4 >> % KK%12 3 ?? & KK& 34 5 << KK.T\\):(;< =    KK &}}SXXd^,,r>c"||jd<y)Npipe)rr7rs rr%z%_ProactorBasePipeTransport._set_extra[s" Fr>c||_yNr3)r7r9s rr'z'_ProactorBasePipeTransport.set_protocol^s !r>c|jSrOrPr7s r get_protocolz'_ProactorBasePipeTransport.get_protocolas ~~r>c|jSrO)r.rRs r is_closingz%_ProactorBasePipeTransport.is_closingds }}r>c.|jryd|_|xjdz c_|js2|j&|jj |j d|j"|jjd|_yy)NTr) r.r-r)r+rr2_call_connection_lostr*cancelrRs rclosez _ProactorBasePipeTransport.closegsq ==   1|| 7 JJ !;!;T B >> % NN ! ! #!DN &r>cv|j-|d|t||jjyy)Nzunclosed transport )source)r&ResourceWarningrY)r7_warns r__del__z"_ProactorBasePipeTransport.__del__rs5 :: ! 'x0/$ O JJ    "r>c0 t|tr4|jjrDt j d||dn*|jj ||||jd|j|y#|j|wxYw)Nz%r: %sTr)message exceptionrr9) isinstanceOSErrorrrr debugcall_exception_handlerr3 _force_close)r7excr`s r _fatal_errorz'_ProactorBasePipeTransport._fatal_errorwsy ##w'::'')LL44H 11&!$!% $ 3   c "D  c "s A.BBcH|jS|jjs9||jjdn|jj||jr |j ryd|_|xj dz c_|jr!|jjd|_|jr!|jjd|_ d|_ d|_ |jj|j|y)NTrr) _empty_waiterdone set_result set_exceptionr.r/r-r+rXr*r,r)rr2rW)r7rgs rrfz'_ProactorBasePipeTransport._force_closes    )$2D2D2I2I2K{""--d3""005 ==T99   1 ?? OO " " $"DO >> NN ! ! #!DN  T77=r>c|jry |jj|t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_y#t|jdrF|jj dk7r)|jj tj|jjd|_|j}||jd|_ d|_wxYw)NshutdownT) r/r3connection_losthasattrr&rEror SHUT_RDWRrYr(_detach)r7rgr<s rrWz0_ProactorBasePipeTransport._call_connection_losts  ' '  0 NN * *3 / tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (tzz:.4::3D3D3F"3L ##F$4$45 JJ   DJ\\F! # +/D (s CB+E?cf|j}|j|t|jz }|SrO)r,r)rF)r7sizes rget_write_buffer_sizez0_ProactorBasePipeTransport.get_write_buffer_sizes/"" << # C % %D r>NNN)zFatal error on pipe transport)rC __module__ __qualname__r$rJr%r'rSrUrYwarningswarnr^rhrfrWrw __classcell__r=s@rr!r!.sQ448$(/.-$#" "%MM #>(0(r>r!cLeZdZ dfd ZdZdZdZdZdZd dZ xZ S) _ProactorReadPipeTransportcd|_d|_t| ||||||t ||_|j j|jd|_y)NrpTF) _pending_data_length_pausedr#r$ bytearray_datarr2 _loop_reading) r7r8rr9r:r;r< buffer_sizer=s rr$z#_ProactorReadPipeTransport.__init__sT$&!  tXvufE{+  T//0 r>c:|j xr |j SrO)rr.rRs r is_readingz%_ProactorReadPipeTransport.is_readings<<5 $55r>c|js |jryd|_|jjrt j d|yy)NTz%r pauses reading)r.rrrr rdrRs r pause_readingz(_ProactorReadPipeTransport.pause_readings? ==DLL   ::   ! LL,d 3 "r>c|js |jsyd|_|j&|jj |j d|j }d|_|dkDr4|jj |j|jd|||jjrtjd|yy)NFrpz%r resumes reading) r.rr*rr2rr_data_receivedrrr rd)r7lengths rresume_readingz)_ProactorReadPipeTransport.resume_readings ==  >> ! JJ !3!3T :**$&! B; JJ !4!4djj&6I6 R ::   ! LL-t 4 "r>c.|jjrtjd| |jj }|s|jyy#t tf$rt$r}|j|dYd}~yd}~wwxYw)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rdr3 eof_received SystemExitKeyboardInterrupt BaseExceptionrhrY)r7 keep_openrgs r _eof_receivedz(_ProactorReadPipeTransport._eof_receiveds ::   ! LL*D 1 335I JJL-.      H J  sA B8BBc|jr||_y|dk(r|jyt|jt j r" t j|j|y|jj|y#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nrz3Fatal error: protocol.buffer_updated() call failed.) rrrrbr3r BufferedProtocol_feed_data_to_buffered_protorrrrh data_received)r7datarrgs rrz)_ProactorReadPipeTransport._data_receiveds <<)/D %  Q;     dnni&@&@ A 66t~~tL NN ( ( . 12   !!##12  s B C%B<<CcJd}d} |xd|_|jrQ|j}|dk(r |dkDr|j||yyt t |j d|}n|j|jr |dkDr|j||yy|js?|jjj|j|j |_|js&|jj|j |dkDr|j||yy#t $rZ}|js|j#|dn1|jj%rt'j(ddYd}~wd}~wt*$r}|j-|Yd}~d}~wt.$r}|j#|dYd}~d}~wt0j2$r|jsYwxYw#|dkDr|j||wwxYw)Nrprz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)r*rkresultrbytes memoryviewrrXr.rr _proactor recv_intor&add_done_callbackrConnectionAbortedErrorrhrr rdConnectionResetErrorrfrcrCancelledError)r7futrrrgs rrz(_ProactorReadPipeTransport._loop_readings. 2"&88: ZZ\F{F{##D&1A!DJJ!7!@ADJJL}}2{##D&1)<D<&A D<12H< HAFH H&F<7H< HGH#HHHHH")NNNirO) rCryrzr$rrrrrrr}r~s@rrrs/#486;64&5$ /212r>rcPeZdZ dZfdZdZd dZdZdZdZ dZ d Z xZ S) _ProactorBaseWritePipeTransportTc2t||i|d|_yrO)r#r$rjr7argskwr=s rr$z(_ProactorBaseWritePipeTransport.__init__Ns $%"%!r>ct|tttfs!t dt |j |jr td|j td|sy|jrH|jtjk\rtjd|xjdz c_ y|j|j!t|y|j"s!t||_|j%y|j"j'||j%y)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)r)rbrrr TypeErrortyperCr0 RuntimeErrorrjr-r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr+ _loop_writingr)_maybe_pause_protocolextend)r7rs rwritez%_ProactorBaseWritePipeTransport.writeRs$ : >?Dz**+-. .   ;< <    )IJ J  ??)"M"MM@A OOq O  ?? "   E$K  0$T?DL  & & ( LL   %  & & (r>c  ||j |jryd|_d|_|r|j||j}d|_|sx|jr&|j j |jd|jr)|jjtj|jn|j jj|j||_|jj!sFt#||_|jj%|j&|j)n%|jj%|j&|j*)|j|j*j-dyyy#t.$r}|j1|Yd}~yd}~wt2$r}|j5|dYd}~yd}~wwxYw)Nrz#Fatal write error on pipe transport)r+r.r,rr)rr2rWr0r&rorSHUT_WR_maybe_resume_protocolrsendrkrFrrrrjrlrrfrcrh)r7frrgs rrz-_ProactorBaseWritePipeTransport._loop_writingxs& J}!8T]]"DO"#D  |||# ==JJ(()C)CTJ$$JJ''7 ++-"&**"6"6";";DJJ"M++-*-d)D'OO55d6H6HI..0OO55d6H6HI!!-$//2I""--d33J-# #   c " " J   c#H I I Js)F<FF<< HG H'G>>HcyNTrRs r can_write_eofz-_ProactorBaseWritePipeTransport.can_write_eofr>c$|jyrO)rYrRs r write_eofz)_ProactorBaseWritePipeTransport.write_eofs  r>c&|jdyrOrfrRs rabortz%_ProactorBaseWritePipeTransport.abort $r>c|j td|jj|_|j|jj d|jS)NzEmpty waiter is already set)rjrr create_futurer+rlrRs r_make_empty_waiterz2_ProactorBaseWritePipeTransport._make_empty_waitersY    )<= =!ZZ557 ?? "    ) )$ /!!!r>cd|_yrO)rjrRs r_reset_empty_waiterz3_ProactorBaseWritePipeTransport._reset_empty_waiters !r>NN) rCryrz_start_tls_compatibler$rrrrrrrr}r~s@rrrHs7$ "$)L'JR ""r>rc$eZdZfdZdZxZS)_ProactorWritePipeTransportct||i||jjj |j d|_|j j|jy)N) r#r$rrrecvr&r*r _pipe_closedrs rr$z$_ProactorWritePipeTransport.__init__sO $%"%--224::rB (():):;r>c|jry|jryd|_|j|j t y|j yrO) cancelledr.r*r+rfBrokenPipeErrorrY)r7rs rrz(_ProactorWritePipeTransport._pipe_closedsC ==?  ==  ?? &   o/ 0 JJLr>)rCryrzr$rr}r~s@rrrs < r>rcReZdZdZ d fd ZdZdZdZd dZd dZ d dZ xZ S) _ProactorDatagramTransportic||_d|_d|_t||||||t j |_|jj|jy)Nr)r:r;) _addressrj _buffer_sizer#r$ collectionsdequer)rr2r)r7r8rr9addressr:r;r=s rr$z#_ProactorDatagramTransport.__init__s^ ! tXfEJ#((*  T//0r>ct||yrOrrMs rr%z%_ProactorDatagramTransport._set_extra $%r>c|jSrO)rrRs rrwz0_ProactorDatagramTransport.get_write_buffer_sizes   r>c&|jdyrOrrRs rrz _ProactorDatagramTransport.abortrr>crt|tttfst dt ||sy|j (|d|j fvrtd|j |jrT|j rH|jtjk\rtjd|xjdz c_y|jjt||f|xjt!|z c_|j"|j%|j'y)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rbrrrrrr ValueErrorr-rrr rr)rDrrFr+rr)r7raddrs rsendtoz!_ProactorDatagramTransport.sendtos$ : >?J J( (  == $dDMM5J)J3DMM?CE E ??t}})"M"MMBC OOq O  U4[$/0 SY& ?? "     ""$r>cz |jryd|_|r|j|jr|jr?|jr3|j r&|j j|jdy|jj\}}|xjt|zc_ |j6|j jj|j||_n7|j jj|j|||_|jj!|j"|j%y#t&$r%}|j(j+|Yd}~yd}~wt,$r}|j/|dYd}~yd}~wwxYw)N)rz'Fatal write error on datagram transport)r-r+rr)rr.rr2rWpopleftrrFrrr&rrrrrcr3error_received Exceptionrh)r7rrrrgs rrz(_ProactorDatagramTransport._loop_writingsT *#DO <!>tzz?C}}"N~~)001C1CD00t< / NN ) )# . .(( ==! 00t<sM F#'F#9,F#B F#2G5# G2,G G5 #G2/G51G22G55!HrxrO) rCryrzrr$r%rwrrrrr}r~s@rrrs2H59$( 1&! %: *D)=r>rceZdZ dZdZy)_ProactorDuplexPipeTransportcy)NFrrRs rrz*_ProactorDuplexPipeTransport.can_write_eofUsr>ctrO)NotImplementedErrorrRs rrz&_ProactorDuplexPipeTransport.write_eofXs!!r>N)rCryrzrrrr>rrrPs&"r>rcdeZdZ ejj Z dfd ZdZdZ dZ xZ S)_ProactorSocketTransportcXt|||||||tj|yrO)r#r$r _set_nodelayr6s rr$z!_ProactorSocketTransport.__init__cs( tXvufE  &r>ct||yrOrrMs rr%z#_ProactorSocketTransport._set_extrahrr>cyrrrRs rrz&_ProactorSocketTransport.can_write_eofkrr>c|js |jryd|_|j*|jj t j yyr)r.r0r+r&rorrrRs rrz"_ProactorSocketTransport.write_eofnsA ==D--   ?? " JJ   / #r>rx) rCryrzr _SendfileMode TRY_NATIVE_sendfile_compatibler$r%rrr}r~s@rrr\s4+$22==48$(' &0r>rceZdZfdZ ddZ dddddddddZ ddZ d dZ d d Z d d Z fd Z d Z d Z dZ d!dZdZdZdZdZdZdZdZdZddZdZ d"dZdZdZdZxZS)#rct|tjd|jj ||_||_d|_i|_ |j||jtjtjur.tj |j"j%yy)NzUsing proactor: %s)r#r$r rdr=rCr _selector_self_reading_future_accept_futuresset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockrE)r7proactorr=s rr$zBaseProactorEventLoop.__init__xs  )8+=+=+F+FG!!$(!!$   # # %)>)>)@ @  !3!3!5 6 Ar>Nc"t||||||SrO)r)r7rr9r:r;r<s r_make_socket_transportz,BaseProactorEventLoop._make_socket_transports'dHf(-v7 7r>F) server_sideserver_hostnamer;r<ssl_handshake_timeoutssl_shutdown_timeoutc ttj||||||| | } t||| ||| jS)N)rrr;r<)r SSLProtocolr_app_transport) r7rawsockr9 sslcontextr:rrr;r<rr ssl_protocols r_make_ssl_transportz)BaseProactorEventLoop._make_ssl_transportsI  ++h F_&;%9 ; !w ',V =***r>c"t||||||SrO)r)r7rr9rr:r;s r_make_datagram_transportz.BaseProactorEventLoop._make_datagram_transports)$h*0%9 9r>c t|||||SrO)rr7rr9r:r;s r_make_duplex_pipe_transportz1BaseProactorEventLoop._make_duplex_pipe_transports+D,0(FEK Kr>c t|||||SrO)rrs r_make_read_pipe_transportz/BaseProactorEventLoop._make_read_pipe_transports)$hNNr>c t|||||SrO)rrs r_make_write_pipe_transportz0BaseProactorEventLoop._make_write_pipe_transports+4+/65J Jr>c|jr td|jrytjtj urt jd|j|j|jjd|_ d|_ t|-y)Nz!Cannot close a running event looprp) is_runningr is_closedrrrr r _stop_accept_futures_close_self_piperrYrr#)r7r=s rrYzBaseProactorEventLoop.closes ?? BC C >>    # # %)>)>)@ @   $ !!#    r>cVK|jj||d{S7wrO)rr)r7rns r sock_recvzBaseProactorEventLoop.sock_recvs#^^((q1111 )')cVK|jj||d{S7wrO)rr)r7rbufs rsock_recv_intoz$BaseProactorEventLoop.sock_recv_intos#^^--dC8888r,cVK|jj||d{S7wrO)rr)r7rbufsizes r sock_recvfromz#BaseProactorEventLoop.sock_recvfroms#^^,,T7;;;;r,crK|s t|}|jj|||d{S7wrO)rFr recvfrom_into)r7rr.nbytess rsock_recvfrom_intoz(BaseProactorEventLoop.sock_recvfrom_intos1XF^^11$VDDDDs .757cVK|jj||d{S7wrO)rr)r7rrs r sock_sendallz"BaseProactorEventLoop.sock_sendalls#^^((t4444r,cZK|jj||d|d{S7w)Nr)rr)r7rrrs r sock_sendtoz!BaseProactorEventLoop.sock_sendtos'^^**4q'BBBBs "+)+cK|jr|jdk7r td|jj ||d{S7w)Nrzthe socket must be non-blocking)_debug gettimeoutrrconnect)r7rrs r sock_connectz"BaseProactorEventLoop.sock_connectsD ;;4??,1>? ?^^++D'::::sA A A AcTK|jj|d{S7wrO)racceptrMs r sock_acceptz!BaseProactorEventLoop.sock_accepts!^^**40000s (&(cK |j} t j|j}|r|n|}|syt|d}|rt||z|n|} t||}d} t| |z |}|dkr| | dkDr|j|SS|jj||||d{||z }| |z } ^#ttjf$r}t j dd}~wwxYw#t$rt j dwxYw7g#| dkDr|j|wwxYww)Nznot a regular filerl)rEAttributeErrorioUnsupportedOperationrSendfileNotAvailableErrorosfstatst_sizercminseekrsendfile) r7rfileoffsetcountrEerrfsize blocksizeend_pos total_sents r_sock_sendfile_nativez+BaseProactorEventLoop._sock_sendfile_natives_ M[[]F MHHV$,,E#E  ;/ 05#fune,5VU#  "& 0)< >% A~ &! nn--dD&)LLL)#i'  7 78 M667KL L M M667KL L MMA~ &!shEC D6E+D$E!D$:D";D$ C=#C88C==EDE"D$$D==EcjK|j}|j|jd{ |j|j|||dd{|j |r|j SS7P7)#|j |r|j wwxYww)NF)fallback)rrr sock_sendfiler&rr)r7transprNrOrPrs r_sendfile_nativez&BaseProactorEventLoop._sendfile_natives**,''))) (++FLL$5:,<<  & & (%%' *<  & & (%%'s84B3BB3#B B  B #%B3 B %B00B3c |j!|jjd|_|jjd|_|jjd|_|xj dzc_y)Nr)rrX_ssockrYr  _internal_fdsrRs rr(z&BaseProactorEventLoop._close_self_pipesg  $ $ 0  % % , , .(,D %     ar>ctj\|_|_|jj d|jj d|xj dz c_y)NFr)r socketpairr]r  setblockingr^rRs rrz%BaseProactorEventLoop._make_self_pipesN#)#4#4#6  T[ & & ar>ct ||j|j|ury|jj|jd}||_|j |j y#tj$rYyttf$rt$r}|jd||dYd}~yd}~wwxYw)Niz.Error on reading from the event loop self pipe)r`rar8) rrrrr]r_loop_self_readingrrrrrre)r7rrgs rrcz(BaseProactorEventLoop._loop_self_readings 9} ((1##DKK6A)*D %   7 7 8((  -.     ' 'K )   s" A,&A,,B7B7B22B7c|j}|y |jdy#t$r(|jrt j ddYyYywxYw)Nz3Fail to write a null byte into the self-pipe socketTr)r rrcr<r rd)r7csocks r_write_to_selfz$BaseProactorEventLoop._write_to_self4sU   =  , JJu  ,{{ 0&*, ,s#,AAc Pdfd jy)Nc  |s|j\}}jrtjd||} j || dd|i nj ||d|ij ryjj }|j j<|jy#t$r} jdk7r9jd|tj d j!n.jrtjd d Yd}~yYd}~yYd}~yd}~wt"j$$r j!YywxYw) Nz#%r got a new connection from %r: %rTr)rr;r<rrrrpzAccept failed on a socket)r`rarzAccept failed on socket %rr)rr<r rdrrr&rrArrErrcrer rrYrr) rconnrr9rgr8protocol_factoryr7r<rrrrs rr8z2BaseProactorEventLoop._start_serving..loopKsw# *=!"JD${{ %J%+T49/1H!-00 (JD#-t"4V2G1E 1G 33 (#-t"4V4E>>#NN))$/78$$T[[]3##D) 6;;=B&//#>%("("8"8">1 JJL[[LL!=!%66!!,,   s%BC C FA0E&FFrO)r2) r7rkrrr<backlogrrr8s ````` ``@r_start_servingz$BaseProactorEventLoop._start_servingFs $ *$ *L tr>cyrOr)r7 event_lists r_process_eventsz%BaseProactorEventLoop._process_eventsss r>c|jjD]}|j|jjyrO)rvaluesrXclear)r7futures rr'z*BaseProactorEventLoop._stop_accept_futuresws6**113F MMO4 ""$r>c|jj|jd}|r|j|jj ||j yrO)rpoprErXr _stop_servingrY)r7rrts rrwz#BaseProactorEventLoop._stop_serving|sG%%))$++->  MMO $$T* r>rxrOr)r)NNdNN)rCryrzr$rrrrr!r#rYr+r/r2r6r8r:r?rBrVr[r(rrcrgrmrpr'rwr}r~s@rrrvs 7=A267 9= + $t"&!% + CG9 BF*.K @D(,OAE)-J (29<E 5C; 1": (  98,&>A-1,0+Z % r>r)#__all__rErHrr{r rrrrrrr r r r logr r_FlowControlMixin BaseTransportr! ReadTransportrWriteTransportrrDatagramTransportr Transportrr BaseEventLooprrr>rrs #  0$D!=!=!+!9!9DNP2!;!+!9!9P2fk"&@&0&?&?k"\"A,A=!;!+!=!=A=H "#=#B#-#7#7 "09>)3304KK55Kr>__pycache__/timeouts.cpython-312.opt-1.pyc000064400000016645152343231170014304 0ustar00 ֦iddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZ Gd d ejZ eGd d Zd eedefdZdeedefdZy)N) TracebackType)finalOptionalType)events) exceptions)tasks)Timeouttimeout timeout_atc eZdZdZdZdZdZdZy)_StatecreatedactiveexpiringexpiredfinishedN)__name__ __module__ __qualname__CREATEDENTEREDEXPIRINGEXPIREDEXITED)/usr/lib64/python3.12/asyncio/timeouts.pyrrsGGHG Frrc eZdZdZdeeddfdZdeefdZdeeddfdZde fdZ de fd Z dd Z d eeed eed eedee fdZddZy)r zAsynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. whenreturnNcXtj|_d|_d|_||_y)zSchedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. N)rr_state_timeout_handler_task_when)selfr!s r__init__zTimeout.__init__!s%nn >B+/  rc|jS)zReturn the current deadline.)r'r(s rr!z Timeout.when.s zzrc|jtjurJ|jtjur t dt d|jj d||_|j|jj|d|_ytj}||jkr!|j|j|_y|j||j|_y)zReschedule the timeout.zTimeout has not been enteredzCannot change state of z TimeoutN)r$rrr RuntimeErrorvaluer'r%cancelrget_running_looptime call_soon _on_timeoutcall_at)r(r!loops r reschedulezTimeout.reschedule2s ;;fnn ,{{fnn,"#ABB)$++*;*;))r$rrr'roundappendjoinr.)r(infor!info_strs r__repr__zTimeout.__repr__Msst ;;&.. (+/::+A5Q'tD KK%v '88D>DKK--.az;;rcJK|jtjur tdt j }| tdtj |_||_|jj|_ |j|j|Sw)Nz Timeout has already been enteredz$Timeout should be used inside a task) r$rrr-r current_taskrr& cancelling _cancellingr6r')r(tasks r __aenter__zTimeout.__aenter__Us} ;;fnn ,AB B!!# <EF Fnn  ::002  # sB!B#exc_typeexc_valexc_tbcK|j!|jjd|_|jtjurVtj |_|j j|jkr|tjurt|y|jtjurtj|_ywN)r%r/r$rrrr&uncancelrGr CancelledError TimeoutErrorrr)r(rJrKrLs r __aexit__zTimeout.__aexit__as  ,  ! ! ( ( *$(D ! ;;&// ) ..DKzz""$(8(88XIbIb=b#/[[FNN * --DKsCCcp|jjtj|_d|_yrN)r&r/rrr$r%r+s rr3zTimeout._on_timeoutys% oo $r)r"r )r"N)rrr__doc__rfloatr)r!r6boolrstrrCrIr BaseExceptionrrRr3rrrr r s Xe_  huoMxM4M.@@<#< 4 ./-('  $ 0%rr delayr"crtj}t||j|zSdS)a Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. N)rr0r r1)rYr5s rr r s5  " " $D %*;499;& FF FFrr!ct|S)abSchedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. )r )r!s rr r s& 4=r)enumtypesrtypingrrrr9rr r __all__Enumrr rUr r rrrras (( TYYc%c%c%LG8E?GwG(Xe_r__pycache__/coroutines.cpython-312.opt-2.pyc000064400000007066152343231170014623 0ustar00 ֦i dZddlZddlZddlZddlZddlZdZeZ dZ ejejjfZeZdZdZy))iscoroutinefunction iscoroutineNctjjxsEtjj xr(t t j jdS)NPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvironget+/usr/lib64/python3.12/asyncio/coroutines.py_is_debug_moder sF 99   Ncii&B&B"B#M"&rzz~~6J'K"LNrcX tj|xst|ddtuS)N _is_coroutine)inspectrgetattrr)funcs rrrs0@  ' ' - B D/4 0M ACrc t|tvryt|tr1t tdkrtj t|yy)NTdF)type_iscoroutine_typecache isinstance_COROUTINE_TYPESlenadd)objs rrr sH3 Cy**#'( % & , " & &tCy 1rcd}d}d}t|dr|jr |j}n$t|dr|jr |j}||}|s||r|dS|Sd}t|dr|jr |j}n$t|dr|jr |j}|j xsd}d }||j }|d |d |}|S|j}|d |d |}|S) Nct|dr|jr |j}n>t|dr|jr |j}ndt|jd}|dS)N __qualname____name__z())hasattrr#r$r)coro coro_names rget_namez#_format_coroutine..get_name3sc 4 (T->->))I T: &4== IDJ//00BCIBrct |jS#t$r  |jcYS#t$rYYywxYwwxYw)NF) cr_runningAttributeError gi_running)r's r is_runningz%_format_coroutine..is_runningAsA ?? "  &!   s  7 &7 3737cr_codegi_codez runninggi_framecr_framezrz running at :z done, defined at )r&r/r0r1r2 co_filenamef_linenoco_firstlineno) r'r)r. coro_coder( coro_framefilenamelineno coro_reprs r_format_coroutiner<0s  ItYDLLLL y !dllLL I  d [) ) JtZ T]]]] z "t}}]] $$=(=H F$$ khZqA )) k!3H:QvhG r)__all__collections.abc collectionsrr rtypesrobjectrr CoroutineTypeabc Coroutinersetrrr<rrrrFs] . N C'')B)BC  =r__pycache__/protocols.cpython-312.opt-2.pyc000064400000007273152343231170014455 0ustar00 ֦i-| dZGddZGddeZGddeZGddeZGd d eZd Zy ) ) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc*eZdZ dZdZdZdZdZy)rcyNr)self transports */usr/lib64/python3.12/asyncio/protocols.pyconnection_madezBaseProtocol.connection_made cyr rr excs r connection_lostzBaseProtocol.connection_lostrrcyr rr s r pause_writingzBaseProtocol.pause_writing%s rcyr rrs r resume_writingzBaseProtocol.resume_writing; rN)__name__ __module__ __qualname__ __slots__rrrrrrr rr s"I   , rrceZdZ dZdZdZy)rrcyr r)r datas r data_receivedzProtocol.data_received^rrcyr rrs r eof_receivedzProtocol.eof_receiveddrrN)rrrrr"r$rrr rrBs2I  rrc$eZdZ dZdZdZdZy)rrcyr r)r sizehints r get_bufferzBufferedProtocol.get_buffers rcyr r)r nbytess r buffer_updatedzBufferedProtocol.buffer_updated rcyr rrs r r$zBufferedProtocol.eof_receivedrrN)rrrrr(r+r$rrr rrms.I    rrceZdZ dZdZdZy)rrcyr r)r r!addrs r datagram_receivedz"DatagramProtocol.datagram_receiveds4rcyr rrs r error_receivedzDatagramProtocol.error_receivedrrN)rrrrr1r3rrr rrs*I5 rrc$eZdZ dZdZdZdZy)rrcyr r)r fdr!s r pipe_data_receivedz%SubprocessProtocol.pipe_data_receivedr,rcyr r)r r6rs r pipe_connection_lostz'SubprocessProtocol.pipe_connection_lostr,rcyr rrs r process_exitedz!SubprocessProtocol.process_exiteds0rN)rrrrr7r9r;rrr rrs6I  1rrct|}|rr|j|}t|}|s td||k\r||d||j|y|d||d||j|||d}t|}|rqyy)Nz%get_buffer() returned an empty buffer)lenr( RuntimeErrorr+)protor!data_lenbufbuf_lens r _feed_data_to_buffered_protorCs4yH x(c(FG G h !C N   *  'NCM   )>D4yH rN)__all__rrrrrrCrrr rEsQ%  6 6 r( |( V2 |2 j  |  11.!r__pycache__/subprocess.cpython-312.opt-2.pyc000064400000027262152343231170014621 0ustar00 ֦i92dZddlZddlmZddlmZddlmZddlmZddlmZejZ ejZ ejZ Gd d ejejZGd d Zdddej fd Zdddej ddZy))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercJeZdZ fdZdZdZdZdZdZdZ dZ xZ S) SubprocessStreamProtocolct||||_dx|_x|_|_d|_d|_g|_|jj|_ y)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loop create_future _stdin_closed)selflimitr __class__s +/usr/lib64/python3.12/asyncio/subprocess.pyrz!SubprocessStreamProtocol.__init__sZ d# 155 5T[4;$!ZZ557cl|jjg}|j|jd|j|j|jd|j|j |jd|j dj dj|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinfos r__repr__z!SubprocessStreamProtocol.__repr__s''( :: ! KK&/ 0 ;; " KK'$++1 2 ;; " KK'$++1 2}}SXXd^,,rcn||_|jd}|ftj|j|j |_|j j||jjd|jd}|ftj|j|j |_ |jj||jjd|jd}|)tj||d|j |_ yy)Nrrrr)protocolreaderr) rget_pipe_transportr StreamReaderrrr set_transportrr#r StreamWriterr)r transportstdout_transportstderr_transportstdin_transports rconnection_madez(SubprocessStreamProtocol.connection_made(s#$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $$77:  '!..T[[48JJ@DK KK % %&6 7 NN ! !! $#66q9  & --o7;5937::?DJ 'rcx|dk(r |j}n|dk(r |j}nd}||j|yyNrr*)rr feed_data)rfddatar,s rpipe_data_receivedz+SubprocessStreamProtocol.pipe_data_received@s@ 7[[F 1W[[FF     T " rc |dk(rz|j}||j|j|||jj dy|jj |d|j_y|dk(r |j}n|dk(r |j}nd}|$||jn|j |||jvr|jj||jy)NrFrr*) rcloseconnection_lostr set_result set_exception_log_tracebackrrfeed_eofrremove_maybe_close_transport)rr9excpiper,s rpipe_connection_lostz-SubprocessStreamProtocol.pipe_connection_lostJs 7::D   %{""--d3  ""0055:""1  7[[F 1W[[FF  {!$$S)   NN ! !" % ##%rc2d|_|jy)NT)rrDrs rprocess_exitedz'SubprocessStreamProtocol.process_exitedhs# ##%rct|jdk(r/|jr"|jj d|_yyy)Nr)lenrrrr=rIs rrDz/SubprocessStreamProtocol._maybe_close_transportls: t~~ ! #(<(< OO ! ! #"DO)= #rc8||jur |jSyN)rr)rstreams r_get_close_waiterz*SubprocessStreamProtocol._get_close_waiterqs TZZ %% % r) r" __module__ __qualname__rr'r5r;rGrJrDrP __classcell__)rs@rr r s.:8-?0#&<&# &rr cZeZdZdZdZedZdZdZdZ dZ dZ d Z d Z d d Zy )Processc||_||_||_|j|_|j|_|j |_|j |_yrN)r _protocolrrrrget_pidpid)rr1r+rs rrzProcess.__init__wsH#! ^^ oo oo $$&rcPd|jjd|jdS)N)rr"rYrIs rr'zProcess.__repr__s&4>>**+1TXXJa88rc6|jjSrN)rget_returncoderIs r returncodezProcess.returncodes--//rcTK |jjd{S7wrN)r_waitrIs rwaitz Process.waits"M__**,,,,s (&(c:|jj|yrN)r send_signal)rsignals rrdzProcess.send_signals ##F+rc8|jjyrN)r terminaterIs rrgzProcess.terminates !!#rc8|jjyrN)rkillrIs rriz Process.kills rcK|jj} |=|jj||r t j d|t ||jjd{|rt j d||jjy77#ttf$r#}|rt j d||Yd}~bd}~wwxYww)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugrLdrainBrokenPipeErrorConnectionResetErrorr=)rinputrmrEs r _feed_stdinzProcess._feed_stdins $$& H    'LL?s5zS**""$ $ $  LL6 =  %!56 H ;T3G  HsAC)AB4:B2;B4?3C)2B44C&C!C)!C&&C)c KywrNrIs r_noopz Process._noops scK|jj|}|dk(r |j}n |j}|jj r |dk(rdnd}t jd|||jd{}|jj r |dk(rdnd}t jd|||j|S7Pw)Nr*rrrz%r communicate: read %sz%r communicate: close %s) rr-rrrrkr rmreadr=)rr9r1rOnameoutputs r _read_streamzProcess._read_streamsOO66r: 7[[F[[F ::   !!Qw8HD LL2D$ ?{{}$ ::   !!Qw8HD LL3T4 @ %sBC C ACNcK|j|j|}n|j}|j|j d}n|j}|j |j d}n|j}t j|||d{\}}}|jd{||fS7$7 wr7) rrrrurrzrr gatherrb)rrqrrrs r communicatezProcess.communicates :: !$$U+EJJLE ;; "&&q)FZZ\F ;; "&&q)FZZ\F&+ll5&&&I Ivviik!Js$B%C'C (CC CCrN)r"rQrRrr'propertyr_rbrdrgrirrrurzr}rtrrrUrUvsH'900-,$(" rrUc Ktj  fd} j||f|||d|d{\}}t|| S7w)NctSNr)r r)srz)create_subprocess_shell..7e=A Crrrr)rget_running_loopsubprocess_shellrU) cmdrrrrkwdsprotocol_factoryr1r+rs ` @rrrsm  " " $DC 5 5 5 !!!Ix 9h -- s6AAA)rrrrc Ktj  fd} j||g||||d|d{\}} t|| S7w)NctSrrr)srrz(create_subprocess_exec..rrr)rrsubprocess_execrU) programrrrrargsrrr1r+rs ` @rrrsy  " " $DC 4 4 4!!F ! !Ix 9h -- s9AAA)__all__ subprocessrrrr logr PIPESTDOUTDEVNULLFlowControlMixinSubprocessProtocolr rU_DEFAULT_LIMITrrrtrrrs =      b&w77(;;b&JU U p.2$t(/(>(> .8)typerid_formatr+s r__repr__zQueue.__repr__Bs54:&&'tBtHR=$,,.9IKKrcVdt|jd|jdS)Nr;r<r=)r>rr@r+s r__str__z Queue.__str__Es)4:&&'q(8::rcPd|j}t|ddr|dt|jz }|jr|dt |jdz }|j r|dt |j dz }|jr|d|jz }|S)Nzmaxsize=r(z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr(rlenrr)r#results rr@z Queue._formatJsDMM,- 44 ( dkk!2 56 6F ==  3t}}#5"6a8 8F ==  3t}}#5"6a8 8F  ! !  6 678 8F rc. t|jSr')rHr(r+s rqsizez Queue.qsizeVs+4;;rc |jSr')rr+s rr$z Queue.maxsizeZs3}}rc |j Sr'r(r+s remptyz Queue.empty_sA;;rc^ |jdkry|j|jk\S)NrF)rrKr+s rfullz Queue.fullcs- ==A ::<4==0 0rcK |jrU|jj}|jj | |d{|jrU|j|S7&#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYwwr') rQ _get_loop create_futurerr/cancelremove ValueError cancelledr9 put_nowait)r#r1putters rputz Queue.putns iik^^%335F MM  (  iik&t$$  MM((0!yy{6+;+;+=%%dmm4sZA C9A<A:A<C9)C9:A<<C6B+*C6+ B74C66B77?C66C9c |jrt|j||xjdz c_|jj |j |jy)Nr )rQrr2rrclearr9rr0s rrYzQueue.put_nowaitsU  99;O $ !#  $--(rcK |jrU|jj}|jj | |d{|jrU|jS7%#|j  |jj |n#t$rYnwxYw|js+|js|j|jxYwwr') rOrSrTrr/rUrVrWrXr9 get_nowait)r#getters rgetz Queue.gets jjl^^%335F MM  (  jjl&    MM((0!zz|F,<,<,>%%dmm4sZA C8A;A9A;C8)C89A;;C5B*)C5* B63C55B66?C55C8c |jrt|j}|j|j|Sr')rOrr,r9rr0s rr_zQueue.get_nowaits:  ::< yy{ $--( rc |jdkr td|xjdzc_|jdk(r|jjyy)Nrz!task_done() called too many timesr )rrWrr r+s r task_donezQueue.task_donesW   ! !Q &@A A !#  ! !Q & NN    'rcvK |jdkDr#|jjd{yy7wr)rrwaitr+s rjoinz Queue.joins9   ! !A %..%%' ' ' & 's .979N)r)rrrr%r!r,r2r9rArC classmethodr__class_getitem__r@rKpropertyr$rOrQr[rYrar_rdrgrrrrrs~  *%! L;$L1   1%6 )!4 !( (rrcPeZdZ dZej fdZejfdZy)rcg|_yr'rNr"s rr!zPriorityQueue._init  rc*||j|yr'rN)r#r1heappushs rr2zPriorityQueue._putsd#rc&||jSr'rN)r#heappops rr,zPriorityQueue._getst{{##rN) rrrr!heapqror2rqr,rrrrrs( #(..$!==$rrc eZdZ dZdZdZy)rcg|_yr'rNr"s rr!zLifoQueue._initrmrc:|jj|yr'r.r0s rr2zLifoQueue._putr3rc6|jjSr')r(popr+s rr,zLifoQueue._gets{{  rN)rrrr!r2r,rrrrrsO!!rr)__all__rrrtypesrr r Exceptionrr_LoopBoundMixinrrrrrrr}s^ L     B(F " "B(J $E $ ! !r__pycache__/coroutines.cpython-312.opt-1.pyc000064400000007216152343231170014617 0ustar00 ֦i dZddlZddlZddlZddlZddlZdZeZ dZ ejejjfZeZdZdZy))iscoroutinefunction iscoroutineNctjjxsEtjj xr(t t j jdS)NPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvironget+/usr/lib64/python3.12/asyncio/coroutines.py_is_debug_moder sF 99   Ncii&B&B"B#M"&rzz~~6J'K"LNrcVtj|xst|ddtuS)z6Return True if func is a decorated coroutine function. _is_coroutineN)inspectrgetattrr)funcs rrrs-  ' ' - B D/4 0M ACrct|tvryt|tr1t tdkrtj t|yy)z)Return True if obj is a coroutine object.TdF)type_iscoroutine_typecache isinstance_COROUTINE_TYPESlenadd)objs rrr sE Cy**#'( % & , " & &tCy 1rcd}d}d}t|dr|jr |j}n$t|dr|jr |j}||}|s||r|dS|Sd}t|dr|jr |j}n$t|dr|jr |j}|j xsd}d }||j }|d |d |}|S|j}|d |d |}|S) Nct|dr|jr |j}n>t|dr|jr |j}ndt|jd}|dS)N __qualname____name__z())hasattrr#r$r)coro coro_names rget_namez#_format_coroutine..get_name3sc 4 (T->->))I T: &4== IDJ//00BCIBrct |jS#t$r  |jcYS#t$rYYywxYwwxYw)NF) cr_runningAttributeError gi_running)r's r is_runningz%_format_coroutine..is_runningAsA ?? "  &!   s  7 &7 3737cr_codegi_codez runninggi_framecr_framezrz running at :z done, defined at )r&r/r0r1r2 co_filenamef_linenoco_firstlineno) r'r)r. coro_coder( coro_framefilenamelineno coro_reprs r_format_coroutiner<0s  ItYDLLLL y !dllLL I  d [) ) JtZ T]]]] z "t}}]] $$=(=H F$$ khZqA )) k!3H:QvhG r)__all__collections.abc collectionsrr rtypesrobjectrr CoroutineTypeabc Coroutinersetrrr<rrrrFs] . N C'')B)BC  =r__pycache__/tasks.cpython-312.opt-1.pyc000064400000116372152343231170013556 0ustar00 ֦idZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZej&dj(Zd/d Zd/d ZdZGddej2ZeZ ddlZej4xZZddddZej"j@Z ej"jBZ!ej"jDZ"de"ddZ#dZ$dZ%dZ&dZ'dddZ(ejRdZ*d/dZ+dddZ,Gdd ejZZ.d!d"d#Z/d$Z0d%Z1d&Z2e2eZ3e jhZ5e6Z7iZ8d'Z9d(Z:d)Z;d*Zd-Z?eZ@e9ZAe:ZBe>ZCe?ZDe;ZEeZ>m?Z?m;Z;mZKe?ZLe;ZMeD!  #t+AFFH D >>   FADy   >sB0B"BBc| |j}||yy#t$rtjdtdYywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.) stacklevel)set_nameAttributeErrorwarningswarnDeprecationWarning)tasknamer8s r&_set_task_namer?FsM  }}H TN 8 MM9)Q 8 8s %AAceZdZdZdZdddddfd ZfdZeeZ dZ d Z d Z d Z d Zd ZdZdddZddddZddZdZdZdZddZfdZdZxZS)rz A coroutine wrapped in a Future.TNFr%r>context eager_startcFt|||jr |jd=tj|sd|_t d||dt|_nt||_d|_ d|_ d|_ ||_ |tj|_n||_|r+|j"j%r|j'y|j"j)|j*|j t-|y)Nr$Fza coroutine was expected, got zTask-rrB)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr_num_cancels_requested _must_cancel _fut_waiter_coro contextvars copy_context_context_loop is_running_Task__eager_start call_soon _Task__stepr)selfcoror%r>rBrC __class__s r&rHz Task.__init__os d#  ! !&&r*%%d+).D %>r'cd|_|jry|xjdz c_|j|jj |ryd|_||_y)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. FrmsgT)_log_tracebackr0rPrRcancelrQ_cancel_message)r\rs r&rz Task.cancelsf,$ 99; ##q(#    '&&3&/ "r'c|jS)zReturn the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). rPris r& cancellingzTask.cancellings ***r'cb|jdkDr|xjdzc_|jS)zDecrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. rrrris r&uncancelz Task.uncancels/  & & *  ' '1 , '***r'cpt|j|} t| |jj |j dt | t|j|}|jr d|_d}yt|y#t |wxYw#|jr d|_d}wt|wxYw# t|j|}|jr d|_d}wt|w#|jr d|_d}wt|wxYwxYwrg) _swap_current_taskrW_register_eager_taskrVrun!_Task__step_run_and_handle_result_unregister_eager_taskr0rSr)r\ prev_taskcurtasks r& __eager_startzTask.__eager_starts&tzz48  )  & - !!$"C"CTJ&t, ),TZZC99;!%DJD"4('t, 99;!%DJD"4( ),TZZC99;!%DJD"4( 99;!%DJD"4(sF C &B C B# B  C #'C  D5D %&D5 'D22D5c|jrtjd|d||jr1t |tj s|j }d|_d|_t|j| |j|t|j|d}y#t|j|d}wxYw)Nz_step(): already done: z, F) r0rInvalidStateErrorrQ isinstanceCancelledError_make_cancelled_errorrRrrWrr)r\excs r&__stepz Task.__step#s 99;..)$C7;= =   c:#<#<=002 %D DJJ%   - -c 2  D )D  D )Ds B11C c|j} ||jd}n|j|}t|dd}|lt j ||j urGtd|d|d}|j j|j||jd}y|r||urCtd|}|j j|j||jd}yd|_ |j|j|j||_|jrN|jj!|j"r'd|_ d}ytd |d |}|j j|j||j d}y|4|j j|j|jd}yt%j&|rFtd |d |}|j j|j||jd}ytd |}|j j|j||j d}yd}y#t($rS}|jr"d|_t*|A|j"nt*|Y|j.Yd}~d}yd}~wt0j2$r!}||_t*|AYd}~d}yd}~wt6t8f$r}t*|u|d}~wt<$r}t*|u|Yd}~d}yd}~wwxYw#d}wxYw) N_asyncio_future_blockingzTask z got Future z attached to a different looprFzTask cannot await on itself: Frz-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rSsendthrowgetattrrr/rWr,rZr[rVradd_done_callback _Task__wakeuprRrQrrinspect isgenerator StopIterationrGrwrsrr_cancelled_excKeyboardInterrupt SystemExitrz BaseException)r\rr]rvblockingnew_excr^s r&__step_run_and_handle_resultz!Task.__step_run_and_handle_result4sezzG {4C$v'A4HH#$$V,DJJ>*x|!*$ACDGJJ(( Wdmm)EPDM~".;D8D#F ,, KK$---IDD?;@700 MM4==1B+1(,,#//66(,(<(< 7 >49 10D-+##'(& <=GJJ(( Wdmm)E&D! $$T[[$--$HD$$V,&))-vjBC $$KK$--%AD ')=fZ'HI $$KK$--%AD4DA .  $)!4#7#78"399-tDs(( "%D  GN  lDk":.  G !# &  ' G !# & &bDe 'dDs%JA5M,AM5A0M)AM03M&AMAM MAKMM5L MM#L33 M?MMMMM!c |j|jd}y#t$r}|j|Yd}~d}yd}~wwxYwrg)rvr[r)r\futurers r&__wakeupz Task.__wakeupsH  MMO KKM  KK   s% A AA rg)__name__ __module__ __qualname____doc__rKrHre classmethodr__class_getitem__rjrlrorqr8rwrzr~rrrrrYr[rr __classcell__r^s@r&rrSs+. %)d"!> $L1+ IL"&7.$(d ?(T+ +)&"IVr'rr>rBctj}||j|}n|j||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. rF)rr!rr?)r]r>rBr%r=s r&rrsK  " " $D%g64 Kr')timeout return_whencKtj|stj|r!t dt |j |s td|tttfvrtd|t|}td|Dr t dtj}t||||d{S7w)a}Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3FK|]}tj|ywrg)rrJ).0fs r& zwait..s 1b: ! !! $bs!z6Passing coroutines is forbidden, use tasks explicitly.N)risfuturerrJrLtyper ValueErrorrrrsetanyrr!_wait)fsrrr%s r&rrs z55b98b9J9J8KLMM 9::?O]KK6{mDEE RB 1b 11PQQ  " " $Dr7K6 66 6sCC C CcH|js|jdyyrg)r0rw)waiterargss r&_release_waiterrs ;;=$ r'cK|T|dkrOt|}|jr|jSt|d{ |jStj|4d{|d{cdddd{S7N#tj $r }t |d}~wwxYw7C7;7-#1d{7swYyxYww)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. Nr) r r0rv_cancel_and_waitrr TimeoutErrorrr)futrrs r&rrsFw!|C  88:::< s### (::< ((y)(( $(( (C ' ())(((sACBC BC2B63C6B<<B8=B< C B: CB3'B..B33C8B<:C<CC C Cc0 K|j d ||j|t  t| fd}|D]}|j | d{  j |D]}|j | tt}}|D]5}|jr|j|%|j|7||fS7#  j |D]}|j |wxYww)zVInternal helper for wait(). The fs argument must be a collection of Futures. Ncdzdks2tk(s)tk(rW|jsF|j5j j sj dyyyyy)Nrr)rr cancelledryrr0rw)rcounterrtimeout_handlers r&_on_completionz_wait.._on_completionst1  qL ? * ? *AKKM01 0I)%%';;=!!$'!1J5B *r') create_future call_laterrlenrrremove_done_callbackrr0add) rrrr%rrr0pendingrrrs ` @@@r&rr s    !FN/6J"gG ( N+3  %  ! ! #A " "> 2E35'D  668 HHQK KKN  =   %  ! ! #A " "> 2s1ADC'#C%$C'(A=D%C'',DDc2Ktj}|j}tjt |}|j | |j|d{|j|y7#|j|wxYww)z._on_timeoutds2A " "> 2 OOD ! r'c|syj|j|sjyyyrg)removerr)rr0rrs r&rz$as_completed.._on_completionjs;  A 2  ! ! #3tr'cKjd{}|tj|jS7&wrg)r#rrrv)rr0s r& _wait_for_onez#as_completed.._wait_for_oners7((*  9)) )xxz sA>'A)rrrrJrLrrqueuesrrget_event_looprr rrranger) rrrr%rrr_rr0rrs @@@@r&r r Hs$z55b9=d2h>O>O=PQRR 7D  "D14R 9AM!$ ' 9DN $ N+ #+> 3t9 o9 :sA:DC=A.Dc#Kdyw)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nrr'r&__sleep0rs  sc0K|dkrtd{|Stj}|j}|j |t j ||} |d{|jS7g7#|jwxYww)z9Coroutine that completes after a given time (in seconds).rN)rrr!rrr_set_result_unless_cancelledr)delayrvr%rhs r&r r s zj  " " $D    !F << (A|     s:BA=A B#B(A?)B,B?BBBr$ctj|r&|"|tj|ur td|Sd}t j |s.t j|rd}||}d}n td|tj} |j|S#t$r|r|jwxYw)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. zRThe future belongs to a different loop than the one specified as the loop argumentTc"K|d{S7wrgr) awaitables r&_wrap_awaitablez&ensure_future.._wrap_awaitables&&s  Fz:An asyncio.Future, a coroutine or an awaitable is required)rrr/rrrJr isawaitablerLrrrr,close)coro_or_futurer% should_closers r&r r s '  G,=,=n,M MEF FL  ! !. 1   ~ . '-^._done_callbacks,Q =EJJL==?   }}//1##C(mmo?'',  G==?%33!119++-C--/C{!jjls# "&&//1##C(  ); r'rNr$Fr) rrrrwr rr/rKr0r rr) r coros_or_futuresr%r arg_to_fut done_futsargrrrrrs ` @@@@r&r r s < $$&""$  5*5*nJH EII D E j $/C|((-#~ ,1( QJE!JsOxxz  %%%n5S/C/ 2 XD 1E s Lr'ct|jrStj}|j fdfd}j j |S)aWait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. c0jr!|js|jy|jrjy|j}|j|yj |j yrg)rryrrzrwrv)innerrrs r&_inner_done_callbackz$shield.._inner_done_callbacksj ?? ??$!  ??  LLN//#C##C(  0r'cJjsjyyrg)r0r)rrrs r&_outer_done_callbackz$shield.._outer_done_callbacks zz|  & &'; <r')r r0rr/rr)rr%rrrrs @@@r&r r askB # E zz|   U #D    E1"= 01 01 Lr'ctjs tdtjj fd}j |S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc tjty#ttf$rt $r'}j rj|d}~wwxYw)Nr$)r _chain_futurer rrrset_running_or_notify_cancelrz)rr]rr%s r&callbackz*run_coroutine_threadsafe..callbacks]   ! !-4"@& I-.   224$$S)  s!%A$"AA$)rrJrL concurrentrFuturecall_soon_threadsafe)r]r%r"rs`` @r&rrsM  ! !$ '899    & & (F h' Mr'cdddfd }|S)a=Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. Nrc||||dS)NTrAr)r%r]r>rBcustom_task_constructors r&factoryz*create_eager_task_factory..factorys& t$TK Kr'r)r(r)s` r&rrs&%)$K Nr'c.tj|y)z;Register an asyncio Task scheduled to run on an event loop.N)r+rr=s r&rrsr'c.tj|y)z6Register an asyncio Task about to be eagerly executed.N)r*rr+s r&rrsTr'chtj|}|td|d|d|t|<y)NzCannot enter into task z while another task z is being executed.r"r#r,r%r=rs r&rrsL!%%d+L4TH=##/"22EGH HN4r'chtj|}||urtd|d|dt|=y)Nz Leaving task z! does not match the current task .r.r/s r&rrsJ!%%d+L4]4(3//;.>aAB Btr'cXtj|}| t|=|S|t|<|Srg)r"r#)r%r=rs r&rrs9""4(I | 4   $t r'c.tj|y)z'Unregister a completed, scheduled Task.N)r+discardr+s r&rrsT"r'c.tj|y)z6Unregister a task which finished its first eager step.N)r*r4r+s r&rr sr') rrrrrrrr+r*r"rrg)Pr__all__concurrent.futuresr#rTrrr-typesr:weakrefrr rrrrrrcount__next__rMrrr? _PyFuturer_PyTask_asyncio_CTask ImportErrorrrrrrrrrrr coroutinerr r r$rr r rrrWeakSetr+rr*r"rrrrrrr_py_current_task_py_register_task_py_register_eager_task_py_unregister_task_py_unregister_eager_task_py_enter_task_py_leave_task_py_swap_current_task_c_current_task_c_register_task_c_register_eager_task_c_unregister_task_c_unregister_eager_task _c_enter_task _c_leave_task_c_swap_current_taskrr'r&rSsM6   %Y__Q'00$>6 z7  zz " MM!D6#D $$$44$$44""00 # 7@ 0d)X%$!%6r  "+/@w~~:16CL?D.4/t4 #7??$u    #   ".&2*.((((#O%1)5MM-i  T  s$F5 G5F>=F>G G __pycache__/sslproto.cpython-312.opt-1.pyc000064400000121520152343231170014305 0ustar00 ֦i|zddlZddlZddlZ ddlZddlmZddlmZddlmZddlm Z ddl m Z eejejfZGdd ejZGd d ejZd Zd ZGdde j(e j*ZGddej.Zy#e$rdZYwxYw)N) constants) exceptions) protocols) transports)loggerc eZdZdZdZdZdZdZy)SSLProtocolState UNWRAPPED DO_HANDSHAKEWRAPPEDFLUSHINGSHUTDOWNN)__name__ __module__ __qualname__r r r rr)/usr/lib64/python3.12/asyncio/sslproto.pyr r sI!LGHHrr ceZdZdZdZdZdZy)AppProtocolState STATE_INITSTATE_CON_MADE STATE_EOFSTATE_CON_LOSTN)rrrrrrrrrrrrsJ%NI%NrrcZ|r tdtj}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslcreate_default_contextcheck_hostname) server_sideserver_hostname sslcontexts r_create_transport_contextr$/s2CDD ++-J $) ! rc|||dz}n |}d|z}n|}||dz}n|}||cxk\rdk\sntd|d|d||fS)Nirzhigh (z) must be >= low (z) must be >= 0)r)highlowkbhilos radd_flowcontrol_defaultsr,=sh | ;dBBRB  { 1W  =q=b"# # r6MrceZdZdZej j ZdZddZ dZ dZ dZ dZ efd Zd Zd Zd Zdd ZdZdZddZdZdZedZdZdZdZdZdZdZ dZ!y)_SSLProtocolTransportTc.||_||_d|_y)NF)_loop _ssl_protocol_closed)selfloop ssl_protocols r__init__z_SSLProtocolTransport.__init__Xs ) rNc:|jj||S)z#Get optional transport information.)r1_get_extra_infor3namedefaults rget_extra_infoz$_SSLProtocolTransport.get_extra_info]s!!11$@@rc:|jj|yN)r1_set_app_protocol)r3protocols r set_protocolz"_SSLProtocolTransport.set_protocolas ,,X6rc.|jjSr>)r1 _app_protocolr3s r get_protocolz"_SSLProtocolTransport.get_protocolds!!///rcR|jxs|jjSr>)r2r1_is_transport_closingrDs r is_closingz _SSLProtocolTransport.is_closinggs ||It11GGIIrcn|js"d|_|jjyd|_y)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)r2r1_start_shutdownrDs rclosez_SSLProtocolTransport.closejs,||DL    . . 0!%D rcX|jsd|_|jdtyy)NTz9unclosed transport )r2warnResourceWarning)r3 _warningss r__del__z_SSLProtocolTransport.__del__xs)||DL NN* ,rc0|jj Sr>)r1_app_reading_pausedrDs r is_readingz _SSLProtocolTransport.is_readings%%9999rc8|jjy)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r1_pause_readingrDs r pause_readingz#_SSLProtocolTransport.pause_readings ))+rc8|jjy)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r1_resume_readingrDs rresume_readingz$_SSLProtocolTransport.resume_readings **,rcp|jj|||jjy)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1_set_write_buffer_limits_control_app_writingr3r'r(s rset_write_buffer_limitsz-_SSLProtocolTransport.set_write_buffer_limitss,& 33D#> //1rcZ|jj|jjfSr>)r1_outgoing_low_water_outgoing_high_waterrDs rget_write_buffer_limitsz-_SSLProtocolTransport.get_write_buffer_limits*""66""779 9rc6|jjS)z-Return the current size of the write buffers.)r1_get_write_buffer_sizerDs rget_write_buffer_sizez+_SSLProtocolTransport.get_write_buffer_sizes!!88::rcp|jj|||jjy)aSet the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r1_set_read_buffer_limits_control_ssl_readingr]s rset_read_buffer_limitsz,_SSLProtocolTransport.set_read_buffer_limitss,& 224= //1rcZ|jj|jjfSr>)r1_incoming_low_water_incoming_high_waterrDs rget_read_buffer_limitsz,_SSLProtocolTransport.get_read_buffer_limitsrcrc6|jjS)z+Return the current size of the read buffer.)r1_get_read_buffer_sizerDs rget_read_buffer_sizez*_SSLProtocolTransport.get_read_buffer_sizes!!7799rc.|jjSr>)r1_app_writing_pausedrDs r_protocol_pausedz&_SSLProtocolTransport._protocol_pauseds!!555rct|tttfs!t dt |j |sy|jj|fy)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearray memoryview TypeErrortyperr1_write_appdatar3datas rwritez_SSLProtocolTransport.writesX $ : >?##':#6#6"79: :  ))4'2rc:|jj|y)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)r1r|)r3 list_of_datas r writelinesz _SSLProtocolTransport.writeliness )),7rct)zuClose the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. )NotImplementedErrorrDs r write_eofz_SSLProtocolTransport.write_eofs "!rcy)zAReturn True if this transport supports write_eof(), False if not.FrrDs r can_write_eofz#_SSLProtocolTransport.can_write_eofsrc&|jdy)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N) _force_closerDs rabortz_SSLProtocolTransport.aborts $rcbd|_|j|jj|yyNT)r2r1_abortr3excs rrz"_SSLProtocolTransport._force_closes.    )    % %c * *rc|jjj||jxjt |z c_yr>)r1_write_backlogappend_write_buffer_sizelenr}s r_test__append_write_backlogz1_SSLProtocolTransport._test__append_write_backlogs7 ))006 --T:-rr>NN)"rrr_start_tls_compatibler _SendfileModeFALLBACK_sendfile_compatibler6r<rArErHrKwarningsrPrSrVrYr^rbrfrjrnrqpropertyrtrrrrrrrrrrr.r.Rs!$22;; A70J &!),:,-2,9;2,9:66 38" + ;rr.c eZdZdZdZdZdZ d+dZdZd,dZ dZ dZ dZ d Z d Zd Zd Zd,d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#d Z$d!Z%d-d"Z&d#Z'd$Z(d%Z)d-d&Z*d'Z+d(Z,d)Z-d.d*Z.y)/ SSLProtocoliNc t tdt|j|_t |j|_|tj}n|dkrtd|| tj} n| dkrtd| |s t||}||_ |r |s||_ nd|_ ||_t||_t#j$|_d|_||_||_|j/|d|_d|_d|_||_| |_tj:|_tj:|_t@jB|_"d|_#|rtHjJ|_&ntHjN|_&|jjQ|j<|j>|j|j|_)d|_*d|_+d|_,d|_-d|_.|j_d|_0d|_1d|_2d|_3|ji|jky)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got z6ssl_shutdown_timeout should be a positive number, got )r#F)r!r")6r RuntimeErrorrxmax_size _ssl_bufferry_ssl_buffer_viewrSSL_HANDSHAKE_TIMEOUTrSSL_SHUTDOWN_TIMEOUTr$ _server_side_server_hostname _sslcontextdict_extra collectionsdequerr_waiterr0r?_app_transport_app_transport_created _transport_ssl_handshake_timeout_ssl_shutdown_timeout MemoryBIO _incoming _outgoingr r _state _conn_lostrr _app_staterwrap_bio_sslobj_ssl_writing_pausedrR_ssl_reading_pausedrmrlrh _eof_receivedrsrar`r[_get_app_transport) r3r4 app_protocolr#waiterr!r"call_connection_madessl_handshake_timeoutssl_shutdown_timeouts rr6zSSLProtocol.__init__sE ;@A A$T]]3 *4+;+; < ($-$C$C ! "a ',-/0 0 '#,#A#A !Q &+,./ /2_.J( ;$3D !$(D !%j1 *//1"#   |,"&+#&;#%9"&00  .99DO.==DO''00 NNDNN)) 1113 $) #( #( $%!#$  $$&"#( $%!#$  %%' !rc||_t|drDt|tjr*|j |_|j|_d|_ yd|_ y)N get_bufferTF) rChasattrrvrBufferedProtocolr_app_protocol_get_bufferbuffer_updated_app_protocol_buffer_updated_app_protocol_is_buffer)r3rs rr?zSSLProtocol._set_app_protocolasP) L, /<)C)CD,8,C,CD )0<0K0KD -+/D (+0D (rc|jy|jjs@|#|jj|d|_y|jjdd|_yr>)r cancelled set_exception set_resultrs r_wakeup_waiterzSSLProtocol._wakeup_waiterlsZ <<  ||%%' **3/  ''- rc|j9|jr tdt|j||_d|_|jS)Nz$Creating _SSLProtocolTransport twiceT)rrrr.r0rDs rrzSSLProtocol._get_app_transportvsJ    &**"#IJJ"7 D"ID *.D '"""rcV|jduxr|jjSr>)rrHrDs rrGz!SSLProtocol._is_transport_closing~s#d*Kt/I/I/KKrc2||_|jy)zXCalled when the low-level connection is made. Start the SSL handshake. N)r_start_handshake)r3 transports rconnection_madezSSLProtocol.connection_mades $ rcH|jj|jj|xjdz c_|j d|j _|jtjk7r|jtjk(s|jtjk(rEtj|_ |jj!|j"j$||j'tj(d|_d|_d|_|j-||j.r!|j.j1d|_|j2r"|j2j1d|_yy)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). rNT)rclearrreadrrr2rr r rrrrrr0 call_soonrCconnection_lost _set_stater rr_shutdown_timeout_handlecancel_handshake_timeout_handlers rrzSSLProtocol.connection_losts9 !!#  1    **.D   ' ;;*77 7#3#B#BB#3#=#=="2"A"A $$T%7%7%G%GM (223"! C  ( (  ) ) 0 0 2,0D )  ) )  * * 1 1 3-1D * *rc|}|dks||jkDr |j}t|j|kr*t||_t |j|_|j SNr)rrrrxryr)r3nwants rrzSSLProtocol.get_buffers` 19t}},==D t 4 '(D $.t/?/?$@D !$$$rc|jj|jd||jtj k(r|j y|jtjk(r|jy|jtjk(r|jy|jtjk(r|jyyr>) rrrrr r _do_handshaker _do_readr _do_flushr _do_shutdown)r3nbytess rrzSSLProtocol.buffer_updateds T227F;< ;;*77 7    [[,44 4 MMO [[,55 5 NN  [[,55 5    6rcd|_ |jjrtjd||j t jk(r|jty|j t jk(r=|jt j|jry|jy|j t jk(r@|j|jt j |j#y|j t j k(r|j#yy#t$$r|j&j)wxYw)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Tz%r received EOFN)rr0 get_debugrdebugrr r _on_handshake_completeConnectionResetErrorr rrrRr _do_writerr ExceptionrrKrDs r eof_receivedzSSLProtocol.eof_receiveds" zz##% .5{{.;;;++,@A 0 8 88 0 9 9:++NN$ 0 9 99  0 9 9:!!# 0 9 99!!#:  OO ! ! #  s&A"E,AE5EAE#-E%E7c||jvr|j|S|j|jj||S|Sr>)rrr<r9s rr8zSSLProtocol._get_extra_infosC 4;; ;;t$ $ __ (??11$@ @Nrc&d}|tjk(rd}n|jtjk(r|tjk(rd}n|jtjk(r|tjk(rd}ne|jtjk(r|tj k(rd}n2|jtj k(r|tj k(rd}|r||_ytdj|j|)NFTz!cannot switch state from {} to {}) r r rr r rrrformat)r3 new_statealloweds rrzSSLProtocol._set_states (22 2G KK+55 5 )66 6G KK+88 8 )11 1G KK+33 3 )22 2G KK+44 4 )22 2G #DK3::KK,- -rcnjjr6tjdjj _nd_j tjjjjfd_ jy)Nz%r starts SSL handshakec$jSr>)_check_handshake_timeoutrDsrz.SSLProtocol._start_handshake..$s$*G*G*Ir) r0rrrtime_handshake_start_timerr r call_laterrrrrDs`rrzSSLProtocol._start_handshakes ::   ! LL2D 9)-):D &)-D & (556 JJ ! !$"="="I K & rc|jtjk(r+d|jd}|j t |yy)Nz$SSL handshake is taking longer than z! seconds: aborting the connection)rr r r _fatal_errorConnectionAbortedError)r3msgs rrz$SSLProtocol._check_handshake_timeout(sN ;;*77 76../0*+    4S9 : 8rc |jj|jdy#t$r|j Yyt j $r}|j|Yd}~yd}~wwxYwr>)r do_handshakerSSLAgainErrors_process_outgoingrSSLErrorrs rrzSSLProtocol._do_handshake1sb . LL % % '  ' ' -  %  " " $|| -  ' ' , , -s.A6 A6A11A6c|j!|jjd|_|j} | |jtj n||j }|jjrA|jj!|j"z }t%j&d||dz|j(j+||j-|j/||j0t2j4k(r>t2j6|_|j8j;|j=|j|j?y#t$rm}d}|jtjt|tjrd}nd}|j|||j|Yd}~yd}~wwxYw)Nz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compression ssl_object) rrrrr r getpeercertrr rvrCertificateErrorrrr0rrrrrrupdater r rrrrrCrrr)r3 handshake_excsslobjrrrdts rrz"SSLProtocol._on_handshake_complete;s  ) ) 5  * * 1 1 3-1D * $ 0 8 89##))+H ::   !"T%?%??B LL94c J H"(--/'-'9'9';&,  . ??.99 9.==DO    . .t/F/F/H I  1  M OO,66 7#s334I,   c3 '    $  s4F G7 A#G22G7cjtjtjtjfvryj dj _jtjk(rjdyjtjjjjfd_ jy)NTc$jSr>)_check_shutdown_timeoutrDsrrz-SSLProtocol._start_shutdown..us446r)rr rrr rr2r rrr0rrrrrDs`rrJzSSLProtocol._start_shutdownds KK )) )) **      **.D   ' ;;*77 7 KK  OO,55 6,0JJ,A,A**6-D ) NN rc|jtjtjfvr/|jj t jdyy)NzSSL shutdown timed out)rr rrrrr TimeoutErrorrDs rrz#SSLProtocol._check_shutdown_timeoutysN KK )) ))  OO ( (''(@A C  rc|j|jtj|j yr>)rrr rrrDs rrzSSLProtocol._do_flushs*  (112 rcJ |js|jj|j|j |j dy#t $r|jYytj$r}|j |Yd}~yd}~wwxYwr>) rrunwrapr_call_eof_received_on_shutdown_completerrrrs rrzSSLProtocol._do_shutdowns -%% ##%  " " $  # # %  & &t , %  " " $|| ,  & &s + + ,s&AB"5B"BB"c|j!|jjd|_|r|j|y|jj |j j yr>)rrrr0rrrK)r3 shutdown_excs rrz!SSLProtocol._on_shutdown_completesU  ( ( 4  ) ) 0 0 2,0D )    l + JJ !6!6 7rc|jtj|j|jj |yyr>)rr r rrrs rrzSSLProtocol._aborts6 (223 ?? & OO ( ( - 'rc8|jtjtjtjfvrH|j t jk\rtjd|xj dz c_y|D];}|jj||xjt|z c_ = |jtjk(r|jyy#t $r}|j#|dYd}~yd}~wwxYw)NzSSL connection is closedrFatal error on SSL protocol)rr rrr rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrrrrr rrr)r3rr~exs rr|zSSLProtocol._write_appdatas KK )) )) **  )"M"MM9: OOq O  D    & &t ,  # #s4y 0 #! A{{.666 7 A   b"? @ @ As-C44 D=DDc~ |jr|jd}|jj|}t|}||kr(||d|jd<|xj|zc_n"|jd=|xj|zc_|jr|j y#t $rYwxYwr)rrrrrrr)r3r~countdata_lens rrzSSLProtocol._do_writes %%**1- **40t98#-1%&\D''*++u4+++A.++x7+%%     sBB00 B<;B<c|js@|jj}t|r|jj ||j yr>)rrrrrrr\r}s rrzSSLProtocol._process_outgoingsB''>>&&(D4y%%d+ !!#rc|jtjtjfvry |jsZ|j r|j n|j|jr|jn|j|jy#t$r}|j|dYd}~yd}~wwxYw)Nr )rr r rrRr_do_read__buffered_do_read__copiedrrrrirr)r3r#s rrzSSLProtocol._do_reads KK (( ))    A++//++-))+&&NN$**,  % % ' A   b"? @ @ AsA6B&& C /CC cd}d}jj}t|} jj ||}|dkDrY|}||kr4jj ||z ||d}|dkDr||z }nn$||kr4j j fd|dkDrj||s!jjyy#t$rYEwxYw)Nrrc$jSr>)rrDsrrz0SSLProtocol._do_read__buffered..s r) rrprrrr0rrrrrJ)r3offsetr%bufwantss` rr)zSSLProtocol._do_read__buffereds++D,F,F,HIC LL%%eS1Eqyun LL--efnc&'lKEqy% unJJ(()@A A:  - -f 5  # # %  "    sAC% C%% C10C1cd}d}d} |jj|j}|sn$|rd}d}|}n|rd}|g}nj|L |r|j j n,|s*|j j dj|s!|j|jyy#t$rYywxYw)N1TFr) rrrrrrC data_receivedjoinrrJ)r3chunkzeroonefirstr~s rr*zSSLProtocol._do_read__copied s  ))$--8 DC!EC!5>DKK&     , ,U 3    , ,SXXd^ <  # # %  "    sA C CCc> |jtjk(rHtj|_|jj }|rt jdyyy#ttf$rt$r}|j|dYd}~yd}~wwxYw)Nz?returning true from eof_received() has no effect when using sslzError calling eof_received()) rrrrrCrrr"KeyboardInterrupt SystemExit BaseExceptionr)r3 keep_openr#s rrzSSLProtocol._call_eof_received(s B"2"A"AA"2"<"< ..;;= NN$BCB ":.   B   b"@ A A BsA#A((BBBcZ|j}||jk\r/|js#d|_ |jj y||jkr0|jr#d|_ |jjyyy#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw#t t f$rt$r4}|jjd||j|dYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exceptionrr@Fz protocol.resume_writing() failed) rerarsrC pause_writingr9r:r;r0call_exception_handlerrr`resume_writing)r3sizers rr\z SSLProtocol._control_app_writing7s$**, 4,, ,T5M5M'+D $ ""002T-- -$2J2J',D $ ""1133K -&z2    11@!$!%!4!4 $ 3 &z2    11A!$!%!4!4 $ 3 s/B2CC'*CCD*6*D%%D*cH|jj|jzSr>)rpendingrrDs rrez"SSLProtocol._get_write_buffer_sizeTs~~%%(?(???rc\t||tj\}}||_||_yr>)r,r!FLOW_CONTROL_HIGH_WATER_SSL_WRITErar`r]s rr[z$SSLProtocol._set_write_buffer_limitsWs., #yBBD c$(!#& rcd|_yr)rRrDs rrUzSSLProtocol._pause_reading_s #' rcnjr(d_fd}jj|yy)NFcjtjk(rjyjtjk(rj yjtj k(rjyyr>)rr r rrrrrrDsrresumez+SSLProtocol._resume_reading..resumefs`;;"2":"::MMO[[$4$=$==NN$[[$4$=$==%%'>r)rRr0r)r3rLs` rrXzSSLProtocol._resume_readingbs2  # #',D $ ( JJ  ( $rc|j}||jk\r.|js"d|_|jj y||j kr/|jr"d|_|jj yyy)NTF)rprmrrrVrlrY)r3rDs rriz SSLProtocol._control_ssl_readingqsu))+ 4,, ,T5M5M'+D $ OO ) ) + T-- -$2J2J',D $ OO * * ,3K -rc\t||tj\}}||_||_yr>)r,r FLOW_CONTROL_HIGH_WATER_SSL_READrmrlr]s rrhz#SSLProtocol._set_read_buffer_limitszs., #yAAC c$(!#& rc.|jjSr>)rrFrDs rrpz!SSLProtocol._get_read_buffer_sizes~~%%%rcd|_y)z\Called when the low-level transport's buffer goes over the high-water mark. TN)rrDs rrAzSSLProtocol.pause_writings $( rc2d|_|jy)z^Called when the low-level transport's buffer drains below the low-water mark. FN)rrrDs rrCzSSLProtocol.resume_writings $)   rcf|jr|jj|t|tr5|jj rt jd||dyyt|tjs+|jj|||j|dyy)Nz%r: %sT)exc_infor>) rrrvOSErrorr0rrrrCancelledErrorrB)r3rr?s rrzSSLProtocol._fatal_errors ?? OO ( ( - c7 #zz##% XtWtD&C!:!:; JJ - -" !__ / r)zFatal error on transport)/rrrrrrrr6r?rrrGrrrrrr8rrrrrrJrrrrrr|rrrr)r*rr\rer[rUrXrirhrprArCrrrrrrsH  $#59&*'+&* Q"f 1#L "2H%  !F$-P ;.%R*C -8.A0! $A,#:#< B:@'( )-' & (! rr)renumrr ImportErrorrrrrlogrSSLWantReadErrorSSLSyscallErrorrEnumr rr$r,_FlowControlMixin Transportr.rrrrrr`s  ?**C,?,?@Ntyy &tyy & *r;J88&00r;jZ ),,Z { CsB00B:9B:__pycache__/threads.cpython-312.pyc000064400000002354152343231170013116 0ustar00 ֦i.dZddlZddlZddlmZdZdZy)z6High-level support for working with threads in asyncioN)events) to_threadcKtj}tj}t j |j |g|i|}|jd|d{S7w)aAsynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. N)rget_running_loop contextvars copy_context functoolspartialrunrun_in_executor)funcargskwargsloopctx func_calls (/usr/lib64/python3.12/asyncio/threads.pyrr s]  " " $D  " " $C!!#''4A$A&AI%%dI6 66 6sA"A+$A)%A+)__doc__r rr__all__rrrs<  7r__pycache__/windows_utils.cpython-312.opt-1.pyc000064400000016013152343231170015332 0ustar00 ֦idZddlZejdk7redddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ejZ ejZejZdde d d ZGd d ZGd dej&Zy)z)Various Windows specific bits and pieces.Nwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec tjdjtjt t }|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"} tj$||dtj"tj&|tj"} tj(| d} | j+d| | fS#| tj,| | tj,| xYw)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr )tempfilemktempformatosgetpidnext _mmap_counter_winapiPIPE_ACCESS_DUPLEX GENERIC_READ GENERIC_WRITEPIPE_ACCESS_INBOUNDFILE_FLAG_FIRST_PIPE_INSTANCEFILE_FLAG_OVERLAPPEDCreateNamedPipe PIPE_WAITNMPWAIT_WAIT_FOREVERNULL CreateFile OPEN_EXISTINGConnectNamedPipeGetOverlappedResult CloseHandle) rr r addressopenmodeaccessobsizeibsizeflags_and_attribsh1h2ovs ./usr/lib64/python3.12/asyncio/windows_utils.pyrr soo188 IIKm,./G--%%(=(== '..&&G 555H!}G000!}#88NB  $ $ Xw00 vvw;;W\\K   VQ g.C.C w||- % %bT : t$2v  >    # >    # s *B6F!!1Gc|eZdZdZdZdZedZdZe jddZ e jfdZd Zd Zy ) rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. c||_yN_handleselfhandles r/__init__zPipeHandle.__init__Vs  cx|jd|j}nd}d|jjd|dS)Nzhandle=closed< >)r4 __class____name__r5s r/__repr__zPipeHandle.__repr__YsB << #t||./FF4>>**+1VHA66r9c|jSr2r3r6s r/r7zPipeHandle.handle`s ||r9cH|j td|jS)NzI/O operation on closed pipe)r4 ValueErrorrCs r/filenozPipeHandle.filenods" << ;< <||r9)r%cP|j||jd|_yyr2r3)r6r%s r/closezPipeHandle.closeis$ << #  %DL $r9cb|j#|d|t||jyy)Nz unclosed )source)r4ResourceWarningrH)r6_warns r/__del__zPipeHandle.__del__ns- << # IdX& E JJL $r9c|Sr2rCs r/ __enter__zPipeHandle.__enter__ss r9c$|jyr2)rH)r6tvtbs r/__exit__zPipeHandle.__exit__vs  r9N)r@ __module__ __qualname____doc__r8rApropertyr7rFrr%rHwarningswarnrMrPrUrOr9r/rrQsR7 $+#6#6 %MM r9rc$eZdZdZdfd ZxZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. c dx}x}}dx} x} } |tk(r5tdd\} } tj| tj }n|}|tk(r&td\} } tj| d}n|}|tk(r&td\} }tj|d}n|t k(r|}n|} t| |f|||d|| t| |_ | t| |_ | t| |_ |tk(rt j||tk(rt j||tk(rt j|yy#| | | fD]}|tj|xYw#|tk(rt j||tk(rt j||tk(rt j|wwxYw)N)FTT)r r)TFrr)stdinstdoutstderr)rrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr8rr^r_r`rr%rH)r6argsr^r_r`kwds stdin_rfd stdout_wfd stderr_wfdstdin_wh stdout_rh stderr_rhstdin_rh stdout_wh stderr_whhr?s r/r8zPopen.__init__s/32 2J+///9y D=!%t!L Hh--h DII T>#'=#A Iy..y!#'=#A Iy..y!r{s/ <<7 l ##  0     ! \7+b&&X0%J  0%r9__pycache__/timeouts.cpython-312.opt-2.pyc000064400000013551152343231170014276 0ustar00 ֦iddlZddlmZddlmZmZmZddlmZddlm Z ddlm Z dZ Gd d ejZ eGd d Zd eedefdZdeedefdZy)N) TracebackType)finalOptionalType)events) exceptions)tasks)Timeouttimeout timeout_atc eZdZdZdZdZdZdZy)_StatecreatedactiveexpiringexpiredfinishedN)__name__ __module__ __qualname__CREATEDENTEREDEXPIRINGEXPIREDEXITED)/usr/lib64/python3.12/asyncio/timeouts.pyrrsGGHG Frrc eZdZ deeddfdZdeefdZdeeddfdZdefdZ de fdZ dd Z d ee ed eed eedeefd ZddZy)r whenreturnNcZ tj|_d|_d|_||_yN)rr_state_timeout_handler_task_when)selfr!s r__init__zTimeout.__init__!s* nn >B+/  rc |jSr$)r(r)s rr!z Timeout.when.s*zzrc |jtjurJ|jtjur t dt d|jj d||_|j|jj|d|_ytj}||jkr!|j|j|_y|j||j|_y)NzTimeout has not been enteredzCannot change state of z Timeout)r%rrr RuntimeErrorvaluer(r&cancelrget_running_looptime call_soon _on_timeoutcall_at)r)r!loops r reschedulezTimeout.reschedule2s% ;;fnn ,{{fnn,"#ABB)$++*;*;))r%rrr(roundappendjoinr/)r)infor!info_strs r__repr__zTimeout.__repr__Msst ;;&.. (+/::+A5Q'tD KK%v '88D>DKK--.az;;rcJK|jtjur tdt j }| tdtj |_||_|jj|_ |j|j|Sw)Nz Timeout has already been enteredz$Timeout should be used inside a task) r%rrr.r current_taskrr' cancelling _cancellingr7r()r)tasks r __aenter__zTimeout.__aenter__Us} ;;fnn ,AB B!!# <EF Fnn  ::002  # sB!B#exc_typeexc_valexc_tbcK|j!|jjd|_|jtjurVtj |_|j j|jkr|tjurt|y|jtjurtj|_ywr$)r&r0r%rrrr'uncancelrHr CancelledError TimeoutErrorrr)r)rKrLrMs r __aexit__zTimeout.__aexit__as  ,  ! ! ( ( *$(D ! ;;&// ) ..DKzz""$(8(88XIbIb=b#/[[FNN * --DKsCCcp|jjtj|_d|_yr$)r'r0rrr%r&r,s rr4zTimeout._on_timeoutys% oo $r)r"r )r"N)rrrrfloatr*r!r7boolrstrrDrJr BaseExceptionrrRr4rrrr r s Xe_  huoMxM4M.@@<#< 4 ./-('  $ 0%rr delayr"ct tj}t||j|zSdSr$)rr1r r2)rXr6s rr r s:  " " $D %*;499;& FF FFrr!c t|Sr$)r )r!s rr r s$ 4=r)enumtypesrtypingrrrr:rr r __all__Enumrr rTr r rrrr`s (( TYYc%c%c%LG8E?GwG(Xe_r__pycache__/events.cpython-312.opt-1.pyc000064400000107610152343231170013730 0ustar00 ֦irdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z GddZ Gdd e Z Gd d Z Gd d ZGddZGddeZdaej$ZGddej(ZeZdZdZdZdZdZdZdZdZdZdZ dZ!eZ"eZ#eZ$eZ% ddl&mZmZmZmZeZ'eZ(eZ)eZ*e,ed rd!Z-ej\e-"yy#e+$rY(wxYw)#z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpersc@eZdZdZdZd dZdZdZdZdZ d Z d Z y) rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNc"|tj}||_||_||_||_d|_d|_|jjr.tjtjd|_ yd|_ y)NFr) contextvars copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontexts '/usr/lib64/python3.12/asyncio/events.py__init__zHandle.__init__$sx ?!..0G  !  ::   !%3%A%A a &"D "&*D "ch|jjg}|jr|jd|j9|jt j |j|j|jr,|jd}|jd|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r$infoframes r) _repr_infozHandle._repr_info3s''( ?? KK $ >> % KK>> , -  ! !**2.E KK+eAhZqq ; < r+c|j |jS|j}djdj|S)Nz<{}> )rr6formatjoin)r$r4s r)__repr__zHandle.__repr__?s9 :: !::  }}SXXd^,,r+c|jSN)rr$s r) get_contextzHandle.get_contextEs }}r+c|js@d|_|jjrt||_d|_d|_yy)NT)rrr reprrrrr>s r)cancelz Handle.cancelHs@"DOzz##%"$Z !DNDJr+c|jSr=)rr>s r)r-zHandle.cancelledSs r+c |jj|jg|jd}y#tt f$rt $rw}tj|j|j}d|}|||d}|jr|j|d<|jj|Yd}~d}yd}~wwxYw)NzException in callback )message exceptionhandlesource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr3rrcall_exception_handler)r$exccbmsgr(s r)_runz Handle._runVs 7 DMM  dnn :tzz :-.   777 ,B*2$/C G %%.2.D.D*+ JJ - -g 6 6 7s16CA+CCr=) r1 __module__ __qualname____doc__ __slots__r*r6r;r?rBr-rQr+r)rrs/;I * -  r+rcjeZdZdZddgZdfd ZfdZdZdZdZ d Z d Z d Z fd Z d ZxZS)rz7Object returned by timed callback registration methods. _scheduled_whencxt||||||jr |jd=||_d|_y)Nr.F)superr*rrYrX)r$whenr%r&r'r(r0s r)r*zTimerHandle.__init__os; 4w7  ! !&&r* r+ct|}|jrdnd}|j|d|j|S)Nrzwhen=)r[r6rinsertrY)r$r4posr0s r)r6zTimerHandle._repr_infovs;w!#??a C5 -. r+c,t|jSr=)hashrYr>s r)__hash__zTimerHandle.__hash__|sDJJr+c`t|tr|j|jkStSr= isinstancerrYNotImplementedr$others r)__lt__zTimerHandle.__lt__% e[ ):: + +r+ct|tr,|j|jkxs|j|StSr=rfrrY__eq__rgrhs r)__le__zTimerHandle.__le__3 e[ ):: +At{{5/A Ar+c`t|tr|j|jkDStSr=rerhs r)__gt__zTimerHandle.__gt__rkr+ct|tr,|j|jkDxs|j|StSr=rmrhs r)__ge__zTimerHandle.__ge__rpr+ct|trj|j|jk(xrO|j|jk(xr4|j|jk(xr|j |j k(St Sr=)rfrrYrrrrgrhs r)rnzTimerHandle.__eq__sl e[ )JJ%++-8NNeoo58JJ%++-8OOu'7'77 9r+cp|js|jj|t|yr=)rr_timer_handle_cancelledr[rB)r$r0s r)rBzTimerHandle.cancels& JJ . .t 4 r+c|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). )rYr>s r)r\zTimerHandle.whens zzr+r=)r1rRrSrTrUr*r6rcrjrorrrtrnrBr\ __classcell__)r0s@r)rrjsBAw'I        r+rc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) rz,Abstract server returned by create_server().ct)z5Stop serving. This leaves existing connections open.NotImplementedErrorr>s r)closezAbstractServer.close!!r+ct)z4Get the event loop the Server object is attached to.r|r>s r)get_loopzAbstractServer.get_looprr+ct)z3Return True if the server is accepting connections.r|r>s r) is_servingzAbstractServer.is_servingrr+cKtw)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. r|r>s r) start_servingzAbstractServer.start_serving "! cKtw)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. r|r>s r) serve_foreverzAbstractServer.serve_forever "!rcKtw)z*Coroutine to wait until service is closed.r|r>s r) wait_closedzAbstractServer.wait_closed !!rcK|Swr=rVr>s r) __aenter__zAbstractServer.__aenter__s  sc`K|j|jd{y7wr=)r~r)r$rNs r) __aexit__zAbstractServer.__aexit__s!    s $.,.N) r1rRrSrTr~rrrrrrrrVr+r)rrs-6""""""!r+rc eZdZdZdZdZdZdZdZdZ dZ d Z d Z d d d Z d d dZd d dZdZdZd d ddZd d dZdZdZddddddZdJdZ dKd dddd d d d d d d d dZ dKej4ej6d dd d d d d dd d ZdLdd!d"Zd#d d d d$d%Z dMd d d d d d&d'Z dMd dd d d dd(d)Z d d d d*d+Z! dKdddd d d d d,d-Z"d.Z#d/Z$e%jLe%jLe%jLd0d1Z'e%jLe%jLe%jLd0d2Z(d3Z)d4Z*d5Z+d6Z,d7Z-d8Z.d9Z/dJd:Z0d;Z1d<Z2d=Z3d>Z4dLd d!d?Z5d@Z6dAZ7dBZ8dCZ9dDZ:dEZ;dFZdIZ?y )NrzAbstract event loop.ct)z*Run the event loop until stop() is called.r|r>s r) run_foreverzAbstractEventLoop.run_foreverrr+ct)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. r|)r$futures r)run_until_completez$AbstractEventLoop.run_until_completes "!r+ct)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. r|r>s r)stopzAbstractEventLoop.stops "!r+ct)z3Return whether the event loop is currently running.r|r>s r) is_runningzAbstractEventLoop.is_runningrr+ct)z*Returns True if the event loop was closed.r|r>s r) is_closedzAbstractEventLoop.is_closedrr+ct)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. r|r>s r)r~zAbstractEventLoop.closes "!r+cKtw)z,Shutdown all active asynchronous generators.r|r>s r)shutdown_asyncgensz$AbstractEventLoop.shutdown_asyncgensrrcKtw)z.Schedule the shutdown of the default executor.r|r>s r)shutdown_default_executorz+AbstractEventLoop.shutdown_default_executorrrct)z3Notification that a TimerHandle has been cancelled.r|)r$rGs r)rwz)AbstractEventLoop._timer_handle_cancelledrr+N)r(c0|jd|g|d|iS)Nrr() call_laterr$r%r(r&s r) call_soonzAbstractEventLoop.call_soon stq(CTC7CCr+ctr=r|)r$delayr%r(r&s r)rzAbstractEventLoop.call_later!!r+ctr=r|)r$r\r%r(r&s r)call_atzAbstractEventLoop.call_atrr+ctr=r|r>s r)timezAbstractEventLoop.timerr+ctr=r|r>s r) create_futurezAbstractEventLoop.create_futurerr+)namer(ctr=r|)r$cororr(s r) create_taskzAbstractEventLoop.create_taskrr+ctr=r|rs r)call_soon_threadsafez&AbstractEventLoop.call_soon_threadsafe"rr+ctr=r|)r$executorfuncr&s r)run_in_executorz!AbstractEventLoop.run_in_executor%rr+ctr=r|)r$rs r)set_default_executorz&AbstractEventLoop.set_default_executor(rr+r)familytypeprotoflagscKtwr=r|)r$hostportrrrrs r) getaddrinfozAbstractEventLoop.getaddrinfo-rrcKtwr=r|)r$sockaddrrs r) getnameinfozAbstractEventLoop.getnameinfo1 !!r) sslrrrsock local_addrserver_hostnamessl_handshake_timeoutssl_shutdown_timeouthappy_eyeballs_delay interleavec Ktwr=r|)r$protocol_factoryrrrrrrrrrrrrrs r)create_connectionz#AbstractEventLoop.create_connection4s"!rdT) rrrbacklogr reuse_address reuse_portrrrc Ktw)a#A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|)r$rrrrrrrrrrrrrs r) create_serverzAbstractEventLoop.create_server>sp"!r)fallbackcKtw)zRSend a file through a transport. Return an amount of sent bytes. r|)r$ transportfileoffsetcountrs r)sendfilezAbstractEventLoop.sendfilexrrF) server_siderrrcKtw)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. r|)r$rprotocol sslcontextrrrrs r) start_tlszAbstractEventLoop.start_tlss"!r)rrrrrcKtwr=r|)r$rpathrrrrrs r)create_unix_connectionz(AbstractEventLoop.create_unix_connectionrr)rrrrrrcKtw)aWA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. r|) r$rrrrrrrrs r)create_unix_serverz$AbstractEventLoop.create_unix_serversD"!r)rrrcKtw)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r|)r$rrrrrs r)connect_accepted_socketz)AbstractEventLoop.connect_accepted_sockets"!r)rrrrrallow_broadcastrcKtw)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. r|) r$rr remote_addrrrrrrrrs r)create_datagram_endpointz*AbstractEventLoop.create_datagram_endpointsB"!rcKtw)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.r|r$rpipes r)connect_read_pipez#AbstractEventLoop.connect_read_pipe"!rcKtw)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.r|rs r)connect_write_pipez$AbstractEventLoop.connect_write_piperr)stdinstdoutstderrcKtwr=r|)r$rcmdrrrkwargss r)subprocess_shellz"AbstractEventLoop.subprocess_shellrrcKtwr=r|)r$rrrrr&rs r)subprocess_execz!AbstractEventLoop.subprocess_exec rrctr=r|r$fdr%r&s r) add_readerzAbstractEventLoop.add_readerrr+ctr=r|r$rs r) remove_readerzAbstractEventLoop.remove_readerrr+ctr=r|rs r) add_writerzAbstractEventLoop.add_writerrr+ctr=r|rs r) remove_writerzAbstractEventLoop.remove_writer"rr+cKtwr=r|)r$rnbytess r) sock_recvzAbstractEventLoop.sock_recv'rrcKtwr=r|)r$rbufs r)sock_recv_intoz AbstractEventLoop.sock_recv_into*rrcKtwr=r|)r$rbufsizes r) sock_recvfromzAbstractEventLoop.sock_recvfrom-rrcKtwr=r|)r$rrr s r)sock_recvfrom_intoz$AbstractEventLoop.sock_recvfrom_into0rrcKtwr=r|)r$rdatas r) sock_sendallzAbstractEventLoop.sock_sendall3rrcKtwr=r|)r$rraddresss r) sock_sendtozAbstractEventLoop.sock_sendto6rrcKtwr=r|)r$rrs r) sock_connectzAbstractEventLoop.sock_connect9rrcKtwr=r|)r$rs r) sock_acceptzAbstractEventLoop.sock_accept<rrcKtwr=r|)r$rrrrrs r) sock_sendfilezAbstractEventLoop.sock_sendfile?rrctr=r|)r$sigr%r&s r)add_signal_handlerz$AbstractEventLoop.add_signal_handlerErr+ctr=r|)r$r$s r)remove_signal_handlerz'AbstractEventLoop.remove_signal_handlerHrr+ctr=r|)r$factorys r)set_task_factoryz"AbstractEventLoop.set_task_factoryMrr+ctr=r|r>s r)get_task_factoryz"AbstractEventLoop.get_task_factoryPrr+ctr=r|r>s r)get_exception_handlerz'AbstractEventLoop.get_exception_handlerUrr+ctr=r|)r$handlers r)set_exception_handlerz'AbstractEventLoop.set_exception_handlerXrr+ctr=r|r$r(s r)default_exception_handlerz+AbstractEventLoop.default_exception_handler[rr+ctr=r|r3s r)rMz(AbstractEventLoop.call_exception_handler^rr+ctr=r|r>s r)r zAbstractEventLoop.get_debugcrr+ctr=r|)r$enableds r) set_debugzAbstractEventLoop.set_debugfrr+)rNN)rNr=)@r1rRrSrTrrrrrr~rrrwrrrrrrrrrrrrsocket AF_UNSPEC AI_PASSIVErrrrrrrrr subprocessPIPErrrrr r rrrrrrrr r"r%r'r*r,r.r1r4rMr r9rVr+r)rrs?""""" """ "26D:>"6:""" )-d" =A""" "#!1""59"$4 "&!%!%$"598"&&##$DT"&!%8"t"#'"%*(,.2-1 "*."4 "&!% "*.""s"&!% ""L"&!% " EI!"./q59d7;$ !"J " "&0__&0oo&0oo"%/OO%/__%/__""""" """""""""(," "" "" """" ""r+rc.eZdZdZdZdZdZdZdZy)rz-Abstract policy for accessing the event loop.ct)a>Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.r|r>s r)r z&AbstractEventLoopPolicy.get_event_loopms "!r+ct)z3Set the event loop for the current context to loop.r|r$r's r)r z&AbstractEventLoopPolicy.set_event_loopwrr+ct)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.r|r>s r)r z&AbstractEventLoopPolicy.new_event_loop{s "!r+ct)z$Get the watcher for child processes.r|r>s r)r z)AbstractEventLoopPolicy.get_child_watcherrr+ct)z$Set the watcher for child processes.r|)r$watchers r)r z)AbstractEventLoopPolicy.set_child_watcherrr+N) r1rRrSrTr r r r r rVr+r)rrjs7"""""r+rcVeZdZdZdZGddej ZdZdZ dZ dZ y) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). NceZdZdZdZy)!BaseDefaultEventLoopPolicy._LocalNF)r1rRrSr _set_calledrVr+r)_LocalrKs  r+rMc.|j|_yr=)rM_localr>s r)r*z#BaseDefaultEventLoopPolicy.__init__skkm r+c|jj|jjstjtj urd} t jd}|rG|jjd}|dk(s|jdsn|j}|dz }|rF ddl }|jdt| |j!|j#|jj*t%d tjj&z|jjS#t$rYwxYw) zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nr^rr1asynciozasyncio.rzThere is no current event loop) stacklevelz,There is no current event loop in thread %r.)rOrrL threadingcurrent_thread main_threadr"r# f_globalsget startswithf_backAttributeErrorwarningswarnDeprecationWarningr r RuntimeErrorr)r$rRfmoduler[s r)r z)BaseDefaultEventLoopPolicy.get_event_loops/ KK   %KK++((*i.C.C.EEJ $MM!$ [[__Z8F"i/63D3DZ3PA!OJ   MM:,  E    3 3 5 6 ;;   $M!*!9!9!;!@!@ AB B{{   )"  sE EEcd|j_|2t|ts"t dt |j d||j_y)zSet the event loop.TNzs r)r z)BaseDefaultEventLoopPolicy.new_event_loops !!##r+) r1rRrSrTrerSlocalrMr*r r r rVr+r)rIrIs3 M$!B!$r+rIceZdZdZy) _RunningLoopr:N)r1rRrSloop_pidrVr+r)rhrhsHr+rhc4t}| td|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. zno running event loop)rr^r's r)rrs"  D |233 Kr+cbtj\}}||tjk(r|Syy)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_loopriosgetpid) running_looppids r)rrs5&..L#C299;$6%7r+cB|tjft_y)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rnrormrirks r)rrs#BIIK0Mr+c`t5t ddlm}|adddy#1swYyxYw)NrDefaultEventLoopPolicy)_lock_event_loop_policyrurts r)_init_event_loop_policyrys!   % 0!7!9  s$-c.t ttS)z"Get the current event loop policy.)rwryrVr+r)rrs!! r+cp|2t|ts"tdt|jd|ay)zZSet the current event loop policy. If policy is None, the default policy is restored.NzDpolicy must be an instance of AbstractEventLoopPolicy or None, not 'rb)rfrrcrr1rw)policys r)rrs> *V5L"M^_cdj_k_t_t^uuvwxxr+cNt}||StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. )rrr ) current_loops r)r r s*%&L " 1 1 33r+c6tj|y)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rks r)r r 0s**40r+c2tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr rVr+r)r r 5s " 1 1 33r+c2tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr rVr+r)r r :s " 4 4 66r+c4tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rGs r)r r ?s ! " 4 4W ==r+)rrrr forkcttjt_t dt j dy)Nr.)rwrIrMrOrsignal set_wakeup_fdrVr+r)on_forkr]s0  )(B(I(I(K  %$R r+)after_in_child)/rT__all__rrnrr;r>r"rSrxrrrrrrrIrwLockrvrfrhrmrrrryrrr r r r r _py__get_running_loop_py__set_running_loop_py_get_running_loop_py_get_event_loop_asyncio_c__get_running_loop_c__set_running_loop_c_get_running_loop_c_get_event_loop ImportErrorhasattrrregister_at_forkrVr+r)rs]'   JJZ<&<~'!'!TT"T"n ""DD$!8D$V  9??   1:  4 1 4 7 >*)'# '<< -,*& 2v!Bw/  s> C33C;:C;__pycache__/coroutines.cpython-312.pyc000064400000007273152343231170013663 0ustar00 ֦i dZddlZddlZddlZddlZddlZdZeZ dZ ejejjfZeZdZdZy))iscoroutinefunction iscoroutineNctjjxsEtjj xr(t t j jdS)NPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvironget+/usr/lib64/python3.12/asyncio/coroutines.py_is_debug_moder sF 99   Ncii&B&B"B#M"&rzz~~6J'K"LNrcVtj|xst|ddtuS)z6Return True if func is a decorated coroutine function. _is_coroutineN)inspectrgetattrr)funcs rrrs-  ' ' - B D/4 0M ACrct|tvryt|tr1t tdkrtj t|yy)z)Return True if obj is a coroutine object.TdF)type_iscoroutine_typecache isinstance_COROUTINE_TYPESlenadd)objs rrr sE Cy**#'( % & , " & &tCy 1rct|sJd}d}d}t|dr|jr |j}n$t|dr|jr |j}||}|s||r|dS|Sd}t|dr|jr |j}n$t|dr|j r |j }|j xsd}d }||j}|d |d |}|S|j}|d |d |}|S) Nct|dr|jr |j}n>t|dr|jr |j}ndt|jd}|dS)N __qualname____name__z())hasattrr#r$r)coro coro_names rget_namez#_format_coroutine..get_name3sc 4 (T->->))I T: &4== IDJ//00BCIBrct |jS#t$r  |jcYS#t$rYYywxYwwxYw)NF) cr_runningAttributeError gi_running)r's r is_runningz%_format_coroutine..is_runningAsA ?? "  &!   s  7 &7 3737cr_codegi_codez runninggi_framecr_framezrz running at :z done, defined at ) rr&r/r0r1r2 co_filenamef_linenoco_firstlineno) r'r)r. coro_coder( coro_framefilenamelineno coro_reprs r_format_coroutiner<0s" t    ItYDLLLL y !dllLL I  d [) ) JtZ T]]]] z "t}}]] $$=(=H F$$ khZqA )) k!3H:QvhG r)__all__collections.abc collectionsrr rtypesrobjectrr CoroutineTypeabc Coroutinersetrrr<rrrrFs] . N C'')B)BC  =r__pycache__/tasks.cpython-312.pyc000064400000116570152343231170012617 0ustar00 ֦idZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlm Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZej&dj(Zd/d Zd/d ZdZGddej2ZeZ ddlZej4xZZddddZej"j@Z ej"jBZ!ej"jDZ"de"ddZ#dZ$dZ%dZ&dZ'dddZ(ejRdZ*d/dZ+dddZ,Gdd ejZZ.d!d"d#Z/d$Z0d%Z1d&Z2e2eZ3e jhZ5e6Z7iZ8d'Z9d(Z:d)Z;d*Zd-Z?eZ@e9ZAe:ZBe>ZCe?ZDe;ZEeZ>m?Z?m;Z;mZKe?ZLe;ZMeD!  #t+AFFH D >>   FADy   >sB0B"BBc| |j}||yy#t$rtjdtdYywxYw)Nz~Task.set_name() was added in Python 3.8, the method support will be mandatory for third-party task implementations since 3.13.) stacklevel)set_nameAttributeErrorwarningswarnDeprecationWarning)tasknamer8s r&_set_task_namer?FsM  }}H TN 8 MM9)Q 8 8s %AAceZdZdZdZdddddfd ZfdZeeZ dZ d Z d Z d Z d Zd ZdZdddZddddZddZdZdZdZddZfdZdZxZS)rz A coroutine wrapped in a Future.TNFr%r>context eager_startcFt|||jr |jd=tj|sd|_t d||dt|_nt||_d|_ d|_ d|_ ||_ |tj|_n||_|r+|j"j%r|j'y|j"j)|j*|j t-|y)Nr$Fza coroutine was expected, got zTask-rrB)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr_num_cancels_requested _must_cancel _fut_waiter_coro contextvars copy_context_context_loop is_running_Task__eager_start call_soon _Task__stepr)selfcoror%r>rBrC __class__s r&rHz Task.__init__os d#  ! !&&r*%%d+).D %>r'cd|_|jry|xjdz c_|j|jj |ryd|_||_y)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. FrmsgT)_log_tracebackr0rPrRcancelrQ_cancel_message)r\rs r&rz Task.cancelsf,$ 99; ##q(#    '&&3&/ "r'c|jS)zReturn the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). rPris r& cancellingzTask.cancellings ***r'cb|jdkDr|xjdzc_|jS)zDecrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. rrrris r&uncancelz Task.uncancels/  & & *  ' '1 , '***r'ct|j|} t| |jj |j dt | t|j|}||usJ |jr d|_d}yt|y#t |wxYw#|jr d|_d}wt|wxYw# t|j|}||usJ |jr d|_d}wt|w#|jr d|_d}wt|wxYwxYwrg) _swap_current_taskrW_register_eager_taskrVrun!_Task__step_run_and_handle_result_unregister_eager_taskr0rSr)r\ prev_taskcurtasks r& __eager_startzTask.__eager_starts&tzz48  )  & - !!$"C"CTJ&t, ),TZZC$&99;!%DJD"4('t, 99;!%DJD"4( ),TZZC$&99;!%DJD"4( 99;!%DJD"4(sF C&B CB* B''C*'CED3&E'EEc|jrtjd|d||jr1t |tj s|j }d|_d|_t|j| |j|t|j|d}y#t|j|d}wxYw)Nz_step(): already done: z, F) r0rInvalidStateErrorrQ isinstanceCancelledError_make_cancelled_errorrRrrWrr)r\excs r&__stepz Task.__step#s 99;..)$C7;= =   c:#<#<=002 %D DJJ%   - -c 2  D )D  D )Ds B11C c|j} ||jd}n|j|}t|dd}|lt j ||j urGtd|d|d}|j j|j||jd}y|r||urCtd|}|j j|j||jd}yd|_ |j|j|j||_|jrN|jj!|j"r'd|_ d}ytd |d |}|j j|j||j d}y|4|j j|j|jd}yt%j&|rFtd |d |}|j j|j||jd}ytd |}|j j|j||j d}yd}y#t($rS}|jr"d|_t*|A|j"nt*|Y|j.Yd}~d}yd}~wt0j2$r!}||_t*|AYd}~d}yd}~wt6t8f$r}t*|u|d}~wt<$r}t*|u|Yd}~d}yd}~wwxYw#d}wxYw) N_asyncio_future_blockingzTask z got Future z attached to a different looprFzTask cannot await on itself: Frz-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )rSsendthrowgetattrrr/rWr,rZr[rVradd_done_callback _Task__wakeuprRrQrrinspect isgenerator StopIterationrGrwrsrr_cancelled_excKeyboardInterrupt SystemExitrz BaseException)r\rr]rvblockingnew_excr^s r&__step_run_and_handle_resultz!Task.__step_run_and_handle_result4sezzG {4C$v'A4HH#$$V,DJJ>*x|!*$ACDGJJ(( Wdmm)EPDM~".;D8D#F ,, KK$---IDD?;@700 MM4==1B+1(,,#//66(,(<(< 7 >49 10D-+##'(& <=GJJ(( Wdmm)E&D! $$T[[$--$HD$$V,&))-vjBC $$KK$--%AD ')=fZ'HI $$KK$--%AD4DA .  $)!4#7#78"399-tDs(( "%D  GN  lDk":.  G !# &  ' G !# & &bDe 'dDs%JA5M,AM5A0M)AM03M&AMAM MAKMM5L MM#L33 M?MMMMM!c |j|jd}y#t$r}|j|Yd}~d}yd}~wwxYwrg)rvr[r)r\futurers r&__wakeupz Task.__wakeupsH  MMO KKM  KK   s% A AA rg)__name__ __module__ __qualname____doc__rKrHre classmethodr__class_getitem__rjrlrorqr8rwrzr~rrrrrYr[rr __classcell__r^s@r&rrSs+. %)d"!> $L1+ IL"&7.$(d ?(T+ +)&"IVr'rr>rBctj}||j|}n|j||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. rF)rr!rr?)r]r>rBr%r=s r&rrsK  " " $D%g64 Kr')timeout return_whencKtj|stj|r!t dt |j |s td|tttfvrtd|t|}td|Dr t dtj}t||||d{S7w)a}Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not zSet of Tasks/Futures is empty.zInvalid return_when value: c3FK|]}tj|ywrg)rrJ).0fs r& zwait..s 1b: ! !! $bs!z6Passing coroutines is forbidden, use tasks explicitly.N)risfuturerrJrLtyper ValueErrorrrrsetanyrr!_wait)fsrrr%s r&rrs z55b98b9J9J8KLMM 9::?O]KK6{mDEE RB 1b 11PQQ  " " $Dr7K6 66 6sCC C CcH|js|jdyyrg)r0rw)waiterargss r&_release_waiterrs ;;=$ r'cK|T|dkrOt|}|jr|jSt|d{ |jStj|4d{|d{cdddd{S7N#tj $r }t |d}~wwxYw7C7;7-#1d{7swYyxYww)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. Nr) r r0rv_cancel_and_waitrr TimeoutErrorrr)futrrs r&rrsFw!|C  88:::< s### (::< ((y)(( $(( (C ' ())(((sACBC BC2B63C6B<<B8=B< C B: CB3'B..B33C8B<:C<CC C CcB K|sJd|j d ||j|t  t| fd}|D]}|j | d{  j |D]}|j | tt}}|D]5}|jr|j|%|j|7||fS7#  j |D]}|j |wxYww)zVInternal helper for wait(). The fs argument must be a collection of Futures. zSet of Futures is empty.Ncdzdks2tk(s)tk(rW|jsF|j5j j sj dyyyyy)Nrr)rr cancelledryrr0rw)rcounterrtimeout_handlers r&_on_completionz_wait.._on_completionst1  qL ? * ? *AKKM01 0I)%%';;=!!$'!1J5B *r') create_future call_laterrlenrrremove_done_callbackrr0add) rrrr%rrr0pendingrrrs ` @@@r&rr s )))2    !FN/6J"gG ( N+3  %  ! ! #A " "> 2E35'D  668 HHQK KKN  =   %  ! ! #A " "> 2s1A D'C0,C.-C01A=D.C00,DDc2Ktj}|j}tjt |}|j | |j|d{|j|y7#|j|wxYww)z._on_timeoutds2A " "> 2 OOD ! r'c|syj|j|sjyyyrg)removerr)rr0rrs r&rz$as_completed.._on_completionjs;  A 2  ! ! #3tr'cKjd{}|tj|jS7&wrg)r#rrrv)rr0s r& _wait_for_onez#as_completed.._wait_for_oners7((*  9)) )xxz sA>'A)rrrrJrLrrqueuesrrget_event_looprr rrranger) rrrr%rrr_rr0rrs @@@@r&r r Hs$z55b9=d2h>O>O=PQRR 7D  "D14R 9AM!$ ' 9DN $ N+ #+> 3t9 o9 :sA:DC=A.Dc#Kdyw)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nrr'r&__sleep0rs  sc0K|dkrtd{|Stj}|j}|j |t j ||} |d{|jS7g7#|jwxYww)z9Coroutine that completes after a given time (in seconds).rN)rrr!rrr_set_result_unless_cancelledr)delayrvr%rhs r&r r s zj  " " $D    !F << (A|     s:BA=A B#B(A?)B,B?BBBr$ctj|r&|"|tj|ur td|Sd}t j |s.t j|rd}||}d}n td|tj} |j|S#t$r|r|jwxYw)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. zRThe future belongs to a different loop than the one specified as the loop argumentTc"K|d{S7wrgr) awaitables r&_wrap_awaitablez&ensure_future.._wrap_awaitables&&s  Fz:An asyncio.Future, a coroutine or an awaitable is required)rrr/rrrJr isawaitablerLrrrr,close)coro_or_futurer% should_closers r&r r s '  G,=,=n,M MEF FL  ! !. 1   ~ . '-^._done_callbacks,Q =EJJL==?   }}//1##C(mmo?'',  G==?%33!119++-C--/C{!jjls# "&&//1##C(  ); r'rNr$Fr) rrrrwr rr/rKr0r rr) r coros_or_futuresr%r arg_to_fut done_futsargrrrrrs ` @@@@r&r r s < $$&""$  5*5*nJH EII D E j $/C|((-#~ ,1( QJE!JsOxxz  %%%n5S/C/ 2 XD 1E s Lr'ct|jrStj}|j fdfd}j j |S)aWait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. c0jr!|js|jy|jrjy|j}|j|yj |j yrg)rryrrzrwrv)innerrrs r&_inner_done_callbackz$shield.._inner_done_callbacksj ?? ??$!  ??  LLN//#C##C(  0r'cJjsjyyrg)r0r)rrrs r&_outer_done_callbackz$shield.._outer_done_callbacks zz|  & &'; <r')r r0rr/rr)rr%rrrrs @@@r&r r askB # E zz|   U #D    E1"= 01 01 Lr'ctjs tdtjj fd}j |S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc tjty#ttf$rt $r'}j rj|d}~wwxYw)Nr$)r _chain_futurer rrrset_running_or_notify_cancelrz)rr]rr%s r&callbackz*run_coroutine_threadsafe..callbacks]   ! !-4"@& I-.   224$$S)  s!%A$"AA$)rrJrL concurrentrFuturecall_soon_threadsafe)r]r%r"rs`` @r&rrsM  ! !$ '899    & & (F h' Mr'cdddfd }|S)a=Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. Nrc||||dS)NTrAr)r%r]r>rBcustom_task_constructors r&factoryz*create_eager_task_factory..factorys& t$TK Kr'r)r(r)s` r&rrs&%)$K Nr'c.tj|y)z;Register an asyncio Task scheduled to run on an event loop.N)r+rr=s r&rrsr'c.tj|y)z6Register an asyncio Task about to be eagerly executed.N)r*rr+s r&rrsTr'chtj|}|td|d|d|t|<y)NzCannot enter into task z while another task z is being executed.r"r#r,r%r=rs r&rrsL!%%d+L4TH=##/"22EGH HN4r'chtj|}||urtd|d|dt|=y)Nz Leaving task z! does not match the current task .r.r/s r&rrsJ!%%d+L4]4(3//;.>aAB Btr'cXtj|}| t|=|S|t|<|Srg)r"r#)r%r=rs r&rrs9""4(I | 4   $t r'c.tj|y)z'Unregister a completed, scheduled Task.N)r+discardr+s r&rrsT"r'c.tj|y)z6Unregister a task which finished its first eager step.N)r*r4r+s r&rr sr') rrrrrrrr+r*r"rrg)Pr__all__concurrent.futuresr#rTrrr-typesr:weakrefrr rrrrrrcount__next__rMrrr? _PyFuturer_PyTask_asyncio_CTask ImportErrorrrrrrrrrrr coroutinerr r r$rr r rrrWeakSetr+rr*r"rrrrrrr_py_current_task_py_register_task_py_register_eager_task_py_unregister_task_py_unregister_eager_task_py_enter_task_py_leave_task_py_swap_current_task_c_current_task_c_register_task_c_register_eager_task_c_unregister_task_c_unregister_eager_task _c_enter_task _c_leave_task_c_swap_current_taskrr'r&rSsM6   %Y__Q'00$>6 z7  zz " MM!D6#D $$$44$$44""00 # 7@ 0d)X%$!%6r  "+/@w~~:16CL?D.4/t4 #7??$u    #   ".&2*.((((#O%1)5MM-i  T  s$F5 G5F>=F>G G __pycache__/constants.cpython-312.opt-1.pyc000064400000001675152343231170014444 0ustar00 ֦iZddlZdZdZdZdZdZdZdZd Zd Z Gd d ejZ y) N gN@g>@iii,creZdZejZejZejZy) _SendfileModeN)__name__ __module__ __qualname__enumauto UNSUPPORTED TRY_NATIVEFALLBACK*/usr/lib64/python3.12/asyncio/constants.pyrr&s)$))+KJtyy{Hrr) r !LOG_THRESHOLD_FOR_CONNLOST_WRITESACCEPT_RETRY_DELAYDEBUG_STACK_DEPTHSSL_HANDSHAKE_TIMEOUTSSL_SHUTDOWN_TIMEOUT!SENDFILE_FALLBACK_READBUFFER_SIZE FLOW_CONTROL_HIGH_WATER_SSL_READ!FLOW_CONTROL_HIGH_WATER_SSL_WRITETHREAD_JOIN_TIMEOUTEnumrrrrrs^  %&! %/!#& $'!DIIr__pycache__/base_tasks.cpython-312.opt-2.pyc000064400000007760152343231170014551 0ustar00 ֦ip tddlZddlZddlZddlmZddlmZdZejdZdZ dZ y) N) base_futures) coroutinesctj|}|jr|jsd|d<|j dd|j z|j |j dd|j |jr5tj|j}|j dd|d|S) N cancellingrrzname=%rz wait_for=zcoro=<>) r_future_repr_infordoneinsertget_name _fut_waiter_coror_format_coroutine)taskinfocoros +/usr/lib64/python3.12/asyncio/base_tasks.py_task_repr_infor s  ) )$ /D QKK9t}}./ # A4#3#3"678 zz++DJJ7 AvQ'( Kcpdjt|}d|jjd|dS)N >zz 7 " KK !   *  61;;?xt<=) //C  dX&T2  th&?@tL 4(";<4H d3 33CMM3GD $Tr *Hr) r:reprlibr?r1rrrrecursive_reprrr.rJrrrNsC&11 F+r__pycache__/unix_events.cpython-312.pyc000064400000204222152343231170014031 0ustar00 ֦idZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe j6dk(reddZdZGddej>Z GddejBZ"GddejFejHZ%GddejLZ'GddZ(Gdde(Z)Gd d!e(Z*Gd"d#e*Z+Gd$d%e*Z,Gd&d'e(Z-Gd(d)e(Z.d*Z/Gd+d,ej`Z1e Z2e1Z3y)-z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherPidfdChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicywin32z+Signals are not really supported on Windowscy)zDummy signal handler.N)signumframes ,/usr/lib64/python3.12/asyncio/unix_events.py_sighandler_noopr*scP tj|S#t$r|cYSwxYwN)oswaitstatus_to_exitcode ValueError)statuss rr"r"/s.((00  s  %%ceZdZdZdfd ZfdZdZdZdZdZ d Z dd Z dd Z dd Z d Z ddddddddZ dddddddddZdZdZdZdZxZS)_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Nc2t||i|_yr )super__init___signal_handlers)selfselector __class__s rr)z_UnixSelectorEventLoop.__init__?s " "rc0t|tjs,t |j D]}|j |y|j r;tjd|dt||j jyy)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) r(closesys is_finalizinglistr*remove_signal_handlerwarningswarnResourceWarningclear)r+sigr-s rr1z_UnixSelectorEventLoop.closeCs    "D112**3/3$$ 1$:HI.%) + %%++- %rc:|D]}|s|j|yr )_handle_signal)r+datars r_process_self_dataz)_UnixSelectorEventLoop._process_self_dataQs F    ' rcRtj|stj|r td|j ||j  t j|jjtj|||d}||j |< t j |t"t j$|dy#ttf$r}tt|d}~wwxYw#t$r}|j |=|j sI t jdn2#ttf$r }t'j(d|Yd}~nd}~wwxYw|j*t*j,k(rtd|dd}~wwxYw)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)r iscoroutineiscoroutinefunction TypeError _check_signal _check_closedsignal set_wakeup_fd_csockfilenor#OSError RuntimeErrorstrrHandler*r siginterruptrinfoerrnoEINVAL)r+r:callbackargsexchandlenexcs radd_signal_handlerz)_UnixSelectorEventLoop.add_signal_handlerXsq  " "8 ,..x889 9 3  )  !3!3!5 6xtT:%+c"  MM#/ 0   U +G$ )s3x( ( ) %%c*((F((,"G,FKK >EEFyyELL("T#.?#@AA sZ-C-0D D-DD F&F!,EF!E1E,'F!,E110F!!F&c|jj|}|y|jr|j|y|j |y)z2Internal helper that is the actual signal handler.N)r*get _cancelledr5_add_callback_signalsafe)r+r:rXs rr<z%_UnixSelectorEventLoop._handle_signalsE&&**3/ >      & &s +  ) )& 1rc|j| |j|=|tjk(rtj }ntj } tj|||js tjdyy#t$rYywxYw#t$r2}|jtjk(rtd|dd}~wwxYw#ttf$r }tjd|Yd}~yd}~wwxYw)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. FrBrCNr@rAT)rGr*KeyErrorrISIGINTdefault_int_handlerSIG_DFLrMrSrTrNrJr#rrR)r+r:handlerrWs rr5z,_UnixSelectorEventLoop.remove_signal_handlers 3 %%c* &-- 00GnnG  MM#w '$$ A$$R(-   yyELL("T#.?#@AA  ( A :C@@ AsA BB8C BB C'-CCD +DD ct|tstd||tjvrt d|y)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintrFrI valid_signalsr#)r+r:s rrGz$_UnixSelectorEventLoop._check_signalsJ #s#6sg>? ? f**, ,5cU;< < -rc t|||||Sr )_UnixReadPipeTransportr+pipeprotocolwaiterextras r_make_read_pipe_transportz0_UnixSelectorEventLoop._make_read_pipe_transports%dD(FEJJrc t|||||Sr )_UnixWritePipeTransportrks r_make_write_pipe_transportz1_UnixSelectorEventLoop._make_write_pipe_transports&tT8VUKKrc lKtj5tjdtt j } ddd 5| j s td|j} t||||||||f| |d| } | j| j|j|  | d{ ddd| S#1swYxYw7#ttf$rt$r+| j!| j#d{7wxYw#1swY SxYww)NignorezRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rnro)r6catch_warnings simplefilterDeprecationWarningrget_child_watcher is_activerN create_future_UnixSubprocessTransportadd_child_handlerget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr1_wait) r+rmrVshellstdinstdoutstderrbufsizerokwargswatcherrntransps r_make_subprocess_transportz1_UnixSelectorEventLoop._make_subprocess_transports/ $ $ &  ! !(,> ?..0G'$$& #$GHH'')F-dHdE,16676396/56F  % %fnn&6$($@$@& J  !0 9' &( 12    lln$$ '0 seD4/C D4A-D'>C!CC! D4CD4C!!;D$DD$$D''D1,D4c<|j|j|yr )call_soon_threadsafe_process_exited)r+pid returncoders rrz._UnixSelectorEventLoop._child_watcher_callbacks !!&"8"8*Er)sslsockserver_hostnamessl_handshake_timeoutssl_shutdown_timeoutcK|t|tsJ|r |2td| td| td| td|| tdtj|}t j t j t jd} |jd|j||d{nf| td|jt j k7s|jt jk7rtd ||jd|j|||||| d{\}} || fS7#|jxYw7#w) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl0ssl_shutdown_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rr)rfrOr#r!fspathsocketAF_UNIX SOCK_STREAM setblocking sock_connectr1familytype_create_connection_transport) r+protocol_factorypathrrrrr transportrms rcreate_unix_connectionz-_UnixSelectorEventLoop.create_unix_connections &*_c*JJJ & EGG* !NOO$0 GII#/ FHH   IKK99T?D==1C1CQGD   '''d333 | !BCC v~~-II!3!33 DTHMOO   U #$($E$E "C"7!5%F%77 8(""%4  7s=B"E7%&E E EBE7E5 E7EE22E7dT)rbacklogrrr start_servingc Kt|tr td| |s td| |s td|| tdt j |}t j t jt j}|ddvrH tjt j|jrt j| |j#|nU| td |j*t jk7s|j,t jk7rtd ||j/d t1j2||g|||||} |r-| j5t7j8dd{| S#t$rYt$r!} tj d|| Yd} ~ d} ~ wwxYw#t$rT} |j%| j&t&j(k(r!d|d } tt&j(| dd} ~ w|j%xYw7w) Nz*ssl argument must be an SSLContext or Nonerrrr)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrF)rfboolrFr#r!rrrrstatS_ISSOCKst_moderemoveFileNotFoundErrorrMrerrorbindr1rS EADDRINUSErrrrServer_start_servingr sleep) r+rrrrrrrrerrrWmsgservers rcreate_unix_serverz)_UnixSelectorEventLoop.create_unix_servers7 c4 HI I ,SCE E +CBD D   IKK99T?D==1C1CDDAwk)6}}RWWT]%:%:; $  $| CEE v~~-II!3!33 DTHMOO ##D4&2B$'2G$8:   ! ! #++a.  S)6LL"*+/666  99 0 00%TH,>?C!%"2"2C8dB  & !siBIAF'"G3B-I I!I' G0I2G:GIGI I 'AH66I  Ic K tj |j } tj|j}|r|n|}|sy|j} |j| d|||||d| d{S#t$rtjdwxYw#tt jf$r}tjdd}~wwxYw#t$rtjdwxYw7~w)Nzos.sendfile() is not availableznot a regular filer) r!sendfileAttributeErrorr SendfileNotAvailableErrorrLioUnsupportedOperationfstatst_sizerMr{_sock_sendfile_native_impl) r+rfileoffsetcountrLrfsize blocksizefuts r_sock_sendfile_nativez,_UnixSelectorEventLoop._sock_sendfile_nativebs 2 KK M[[]F MHHV$,,E#E   " ''T4(.y! Ey% 26602 2 2  7 78 M667KL L M M667KL L MsVC<BB"C6C<;C:<C<BC<"C;CCC<C77C<c |j} ||j||jr|j|||y|r/||z }|dkr%|j||||j |y t j | |||} | dk(r%|j||||j |y|| z }|| z }||j|||j| |j|| |||||| y#ttf$r;||j|||j| |j|| |||||| Yyt$r} |Q| jtjk(r4t| t ur#t!dtj} | | _| } |dk(r:t%j&d} |j||||j)| n)|j||||j)| Yd} ~ yYd} ~ yd} ~ wt*t,f$rt.$r.} |j||||j)| Yd} ~ yd} ~ wwxYw)Nrzsocket is not connectedzos.sendfile call failed)rL remove_writer cancelled_sock_sendfile_update_filepos set_resultr!r_sock_add_cancellation_callback add_writerrBlockingIOErrorInterruptedErrorrMrSENOTCONNrConnectionError __cause__r r set_exceptionrrr)r+r registered_fdrrLrrr total_sentfdsentrWnew_excrs rrz1_UnixSelectorEventLoop._sock_sendfile_native_implysT [[]  $   } - ==?  . .vvz J   *IA~2266:Nz*1 F;;r669=DJqy2266:Nz*$d"  (88dCD$C$CS "D& &y*F[ !12 B$44S$? OOB ? ?f"E9j B ')II/I_4 *-u~~?$'!Q !::-/2266:N!!#&2266:N!!#&&'-.   #  . .vvz J   c " " #s,:C??AIIB6HI+$IIcZ|dkDr&tj||tjyyNr)r!lseekSEEK_SET)r+rLrrs rrz4_UnixSelectorEventLoop._sock_sendfile_update_fileposs" > HHVVR[[ 1 rc6fd}|j|y)Ncv|jr(j}|dk7rj|yyy)Nr@)rrLr)rrr+rs rcbzB_UnixSelectorEventLoop._sock_add_cancellation_callback..cbs6}}[[]8&&r*r)add_done_callback)r+rrrs` ` rrz6_UnixSelectorEventLoop._sock_add_cancellation_callbacks + b!rr NN)__name__ __module__ __qualname____doc__r)r1r>rZr<r5rGrprsrrrrrrrr __classcell__r-s@rr&r&9s # .(+Z2@ =@D(,KAE)-L 04BF*.0#4 "&!% 0#f*.Gs"&!% GR.DFL2"rr&ceZdZdZdfd ZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZddZdZdZxZS)rjic4t||||jd<||_||_|j |_||_d|_d|_ tj|j j}tj|sJtj|s5tj |s d|_d|_d|_t#dtj$|j d|jj'|jj(||jj'|j*|j |j,|,|jj't.j0|dyy)NrlFz)Pipe transport is for pipes/sockets only.)r(r)_extra_loop_piperL_fileno _protocol_closing_pausedr!rrrS_ISFIFOrS_ISCHRr# set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)r+looprlrmrnromoder-s rr)z_UnixReadPipeTransport.__init__s. " F  {{} !  xx %-- d# d# T"DJDL!DNHI I  e, T^^;;TB T--!\\4+;+; =   JJ !E!E!' / rc^|jsy|jj||yr ) is_readingrr)r+rrUs rrz"_UnixReadPipeTransport._add_readers#  r8,rc:|j xr |j Sr )rrr+s rrz!_UnixReadPipeTransport.is_readings<<5 $55rct|jjg}|j|jdn|jr|jd|jd|j t |jdd}|jW|Utj||j tj}|r|jdnA|jdn/|j|jdn|jddjd j|S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r-rrappendrrgetattrrr _test_selector_event selectors EVENT_READformatjoin)r+rRr,r s r__repr__z_UnixReadPipeTransport.__repr__s''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (<(<>G I& F# ZZ # KK  KK !}}SXXd^,,rch tj|j|j}|r|jj |y|j jrtjd|d|_ |j j|j|j j|jj|j j|jdy#tt f$rYyt"$r}|j%|dYd}~yd}~wwxYw)N%r was closed by peerTz"Fatal read error on pipe transport)r!readrmax_sizer data_receivedr get_debugrrRr_remove_readerr eof_received_call_connection_lostrrrM _fatal_error)r+r=rWs rrz"_UnixReadPipeTransport._read_ready s G774<<7D ,,T2::'')KK 7> $  ))$,,7 $$T^^%@%@A $$T%?%?F !12   I   c#G H H Is*C<<D1 D1D,,D1c|jsyd|_|jj|j|jj rt jd|yy)NTz%r pauses reading)rrrrrrrdebugrs r pause_readingz$_UnixReadPipeTransport.pause_readingsP   !!$,,/ ::   ! LL,d 3 "rc|js |jsyd|_|jj|j|j |jj rtjd|yy)NFz%r resumes reading) rrrrrrrrr#rs rresume_readingz%_UnixReadPipeTransport.resume_reading%s[ ==   t||T-=-=> ::   ! LL-t 4 "rc||_yr rr+rms r set_protocolz#_UnixReadPipeTransport.set_protocol- !rc|jSr r(rs r get_protocolz#_UnixReadPipeTransport.get_protocol0 ~~rc|jSr rrs r is_closingz!_UnixReadPipeTransport.is_closing3 }}rc@|js|jdyyr )r_closers rr1z_UnixReadPipeTransport.close6s}} KK rcv|j-|d|t||jjyyNzunclosed transport r/rr8r1r+_warns r__del__z_UnixReadPipeTransport.__del__:5 :: ! 'x0/$ O JJ    "rc<t|trQ|jtjk(r4|jj rDt jd||dn*|jj||||jd|j|yNz%r: %sTexc_info)message exceptionrrm) rfrMrSEIOrrrr#call_exception_handlerrr4r+rWr@s rr!z#_UnixReadPipeTransport._fatal_error?sr sG $eii)?zz##% XtWtD JJ - -" ! NN /  Crcd|_|jj|j|jj |j |yNT)rrrrrr r+rWs rr4z_UnixReadPipeTransport._closeMs9  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwr rconnection_lostrr1rrGs rr z,_UnixReadPipeTransport._call_connection_lostRg  NN * *3 / JJ   DJ!DNDJ JJ   DJ!DNDJ A 1A>rzFatal error on pipe transport)rrrrr)rrrrr$r&r*r-r1r1r6r7r:r!r4r rrs@rrjrjs]H/<- 6-*G$45"%MM > rrjceZdZdfd ZdZdZdZdZdZdZ dZ d Z d Z d Z d Zej fd ZdZddZddZdZxZS)rrct |||||jd<||_|j |_||_t|_d|_ d|_ tj|j j}tj|}tj |}tj"|} |s$|s"| s d|_d|_d|_t%dtj&|j d|j(j+|j j,|| s!|rdt.j0j3dsE|j(j+|j(j4|j |j6|,|j(j+t8j:|dyy)NrlrFz?Pipe transport is only for pipes, sockets and character devicesaix)r(r)rrrLrr bytearray_buffer _conn_lostrr!rrrrrrr#rrrrr2platform startswithrrr r) r+rrlrmrnroris_charis_fifo is_socketr-s rr)z _UnixWritePipeTransport.__init___si %" F {{} ! {  xx %--,,t$--%MM$' 7iDJDL!DNDE E  e, T^^;;TB )@)@)G JJ !7!7!%t/?/? A   JJ !E!E!' / rc|jjg}|j|jdn|jr|jd|jd|j t |jdd}|j{|ytj||j tj}|r|jdn|jd|j}|jd|n/|j|jdn|jdd jd j|S) Nrrr r r r zbufsize=r rr)r-rrrrrrrr rr EVENT_WRITEget_write_buffer_sizerr)r+rRr,r rs rrz _UnixWritePipeTransport.__repr__s ''( ::  KK ! ]] KK " c$,,()4::{D9 :: !h&:%::$,, (=(=?G I& F#002G KK(7), - ZZ # KK  KK !}}SXXd^,,rc,t|jSr )lenrRrs rr[z-_UnixWritePipeTransport.get_write_buffer_sizes4<<  rc|jjrtjd||jr|j t y|j y)Nr)rrrrRrRr4BrokenPipeErrorrs rrz#_UnixWritePipeTransport._read_readys@ ::   ! KK/ 6 << KK) * KKMrcZt|tttfsJt |t|tr t|}|sy|j s |j rH|j tjk\rtjd|xj dz c_y|jss tj|j|}|t+|k(ry|dkDrt||d}|j,j/|j|j0|xj|z c_ |j3y#tt f$rd}Yt"t$f$rt&$r1}|xj dz c_|j)|dYd}~yd}~wwxYw)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr#Fatal write error on pipe transport)rfbytesrQ memoryviewreprrSrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrRr!writerrrrrrr!r]r _add_writer _write_ready_maybe_pause_protocol)r+r=nrWs rrgz_UnixWritePipeTransport.writesW$ : >?KdK? dI &d#D  ??dmm)"M"MM HI OOq O || HHT\\40CI~Q!$'+ JJ " "4<<1B1B C   ""$$%56  12   1$!!#'LM s7 EF*"F*9'F%%F*c4|jsJd tj|j|j}|t |jk(r|jj |j j|j|j|jr6|j j|j|jdy|dkDr|jd|=yy#ttf$rYyttf$rt $rp}|jj |xj"dz c_|j j|j|j%|dYd}~yd}~wwxYw)NzData should not be emptyrrra)rRr!rgrr]r9r_remove_writer_maybe_resume_protocolrrr rrrrrrSr!)r+rkrWs rriz$_UnixWritePipeTransport._write_readys@||777| %t||4AC %% ""$ ))$,,7++-==JJ--dll;..t4QLL!$) !12  -.   J LL   OOq O JJ % %dll 3   c#H I I  Js*C??FF'A&FFcyrFrrs r can_write_eofz%_UnixWritePipeTransport.can_write_eofrc|jry|jsJd|_|jsL|jj |j |jj |jdyyrF)rrrRrrrrr rs r write_eofz!_UnixWritePipeTransport.write_eofs[ == zzz || JJ % %dll 3 JJ !;!;T Brc||_yr r(r)s rr*z$_UnixWritePipeTransport.set_protocolr+rc|jSr r(rs rr-z$_UnixWritePipeTransport.get_protocolr.rc|jSr r0rs rr1z"_UnixWritePipeTransport.is_closingr2rcX|j|js|jyyyr )rrrsrs rr1z_UnixWritePipeTransport.closes$ :: !$-- NN +8 !rcv|j-|d|t||jjyyr6r7r8s rr:z_UnixWritePipeTransport.__del__r;rc&|jdyr )r4rs rabortz_UnixWritePipeTransport.aborts Drct|tr4|jjrDt j d||dn*|jj ||||jd|j|yr=) rfrMrrrr#rCrr4rDs rr!z$_UnixWritePipeTransport._fatal_error sc c7 #zz##% XtWtD JJ - -" ! NN /  Crc>d|_|jr%|jj|j|jj |jj |j|jj|j|yrF) rrRrrmrr9rrr rGs rr4z_UnixWritePipeTransport._closesf << JJ % %dll 3  !!$,,/ T77=rc |jj||jjd|_d|_d|_y#|jjd|_d|_d|_wxYwr rIrGs rr z-_UnixWritePipeTransport._call_connection_lostrKrLrrMr )rrrr)rr[rrgrirprsr*r-r1r1r6r7r:rzr!r4r rrs@rrrrr\sd#/J-0!!%F%8C" %MM  >rrrceZdZdZy)r|c d}|tjk(r6tjj drt j \}} tj|f||||d|d||_|=|jt|jd||j_ d}|!|j|jyy#|!|j|jwwxYw)NrPF)rrrruniversal_newlinesrwb) buffering) subprocessPIPEr2rTrUr socketpairPopen_procr1r detachr) r+rVrrrrrrstdin_ws r_startz_UnixSubprocessTransport._start+s JOO # (?(?(F $..0NE7 #))E!vf#('E=CEDJ" #'(8$'#R  "  #w"  #s A!C%C7N)rrrrrrrr|r|)s rr|cBeZdZdZd dZdZdZdZdZdZ d Z d Z y) raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. Nc\|jtk7rtjdddyy)NrP{name!r} is deprecated as of Python 3.12 and will be removed in Python {remove}.r)rrr6 _deprecated)clss r__init_subclass__z&AbstractChildWatcher.__init_subclass__Xs, >>X %  !7;%, . &rct)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. NotImplementedErrorr+rrUrVs rr}z&AbstractChildWatcher.add_child_handler_s "##rct)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.rr+rs rremove_child_handlerz)AbstractChildWatcher.remove_child_handlerjs "##rct)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. rr+rs r attach_loopz AbstractChildWatcher.attach_looprs "##rct)zlClose the watcher. This must be called to make sure that any underlying resource is freed. rrs rr1zAbstractChildWatcher.close|s "##rct)zReturn ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. rrs rrzzAbstractChildWatcher.is_actives "##rct)zdEnter the watcher's context and allow starting new processes This function must return selfrrs r __enter__zAbstractChildWatcher.__enter__s "##rct)zExit the watcher's contextrr+abcs r__exit__zAbstractChildWatcher.__exit__s !##r)returnN) rrrrrr}rrr1rzrrrrrrrAs/,. $$$$$$ $rrc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) ra6Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. c|Sr rrs rrzPidfdChildWatcher.__enter__ rcyr r)r+exc_type exc_value exc_tracebacks rrzPidfdChildWatcher.__exit__ rcyrFrrs rrzzPidfdChildWatcher.is_activerqrcyr rrs rr1zPidfdChildWatcher.closerrcyr rrs rrzPidfdChildWatcher.attach_looprrctj}tj|}|j ||j ||||yr )rget_running_loopr! pidfd_openr_do_wait)r+rrUrVrpidfds rr}z#PidfdChildWatcher.add_child_handlers:&&( c"  sE8TJrc$tj}|j| tj|d\}}t |}tj||||g|y#t $rd}tjd|YCwxYw)NrzJchild process pid %d exit status already read: will report returncode 255) rrrr!waitpidr"ChildProcessErrorrrfr1) r+rrrUrVr_r$rs rrzPidfdChildWatcher._do_waits&&( E" 8 3*IAv07J j(4(! J NN.   sA++!BBcyrFrrs rrz&PidfdChildWatcher.remove_child_handlerrN) rrrrrrrzr1rr}rrrrrrrs0    K )&rrc6eZdZdZdZdZdZdZdZdZ y) BaseChildWatcherc d|_i|_yr )r _callbacksrs rr)zBaseChildWatcher.__init__s rc&|jdyr )rrs rr1zBaseChildWatcher.closes rcV|jduxr|jjSr )r is_runningrs rrzzBaseChildWatcher.is_actives#zz%A$***?*?*AArctr r)r+ expected_pids r _do_waitpidzBaseChildWatcher._do_waitpid !##rctr rrs r_do_waitpid_allz BaseChildWatcher._do_waitpid_allrrc|t|tjsJ|j(|&|jrt j dt|j)|jjtj||_|;|jtj|j|jyy)NzCA loop is being detached from a child watcher with pending handlers)rfrAbstractEventLooprrr6r7RuntimeWarningr5rISIGCHLDrZ _sig_chldrrs rrzBaseChildWatcher.attach_loops|z$0H0HIII :: !dlt MM= :: ! JJ , ,V^^ <    # #FNNDNN C  " rc |jy#ttf$rt$r(}|jj d|dYd}~yd}~wwxYw)N$Unknown exception in SIGCHLD handler)r@rA)rrrrrrCrGs rrzBaseChildWatcher._sig_chldsX   "-.    JJ - -A /    sAAAN) rrrr)r1rzrrrrrrrrrs&B$$#( rrcPeZdZdZfdZfdZdZdZdZdZ dZ d Z xZ S) rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cRt|tjdddy)Nrrrr)r(r)r6rr+r-s rr)zSafeChildWatcher.__init__s' /;%, .rcV|jjt| yr )rr9r(r1rs rr1zSafeChildWatcher.closes   rc|Sr rrs rrzSafeChildWatcher.__enter__rrcyr rrs rrzSafeChildWatcher.__exit__rrcH||f|j|<|j|yr )rrrs rr}z"SafeChildWatcher.add_child_handler"s% ($/ rc> |j|=y#t$rYywxYwNTFrr`rs rrz%SafeChildWatcher.remove_child_handler(( $    cZt|jD]}|j|yr r4rrrs rrz SafeChildWatcher._do_waitpid_all/s#(C   S !)rc|dkDsJ tj|tj\}}|dk(ryt|}|jj rt jd|| |jj|\}}|||g|y#t$r|}d}t jd|YOwxYw#t$r7|jj rt jd|dYyYywxYw)Nr$process %s exited with returncode %sr8Unknown child process pid %d, will report returncode 255'Child watcher got an unexpected pid: %rTr>) r!rWNOHANGr"rrrr#rrfrpopr`)r+rrr$rrUrVs rrzSafeChildWatcher._do_waitpid4sa 7**\2::>KCax/7Jzz##% C):7 -!__005NHd S* ,t ,7! CJ NNJ   ( 3zz##%H"T3& 3s#'B4C#CC;DD) rrrrr)r1rrr}rrrrrs@rrrs0.  " -rrcJeZdZdZfdZfdZdZdZdZdZ dZ xZ S) raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). ct|tj|_i|_d|_tjdddy)Nrrrrr) r(r) threadingLock_lock_zombies_forksr6rrs rr)zFastChildWatcher.__init__asC ^^%   /;%, .rc|jj|jjt|yr )rr9rr(r1rs rr1zFastChildWatcher.closeks,    rct|j5|xjdz c_|cdddS#1swYyxYw)Nr)rrrs rrzFastChildWatcher.__enter__ps$ ZZ KK1 KZZs.7c>|j5|xjdzc_|js |js dddyt|j}|jj dddt j dy#1swY xYw)Nrz5Caught subprocesses termination from unknown pids: %s)rrrrOr9rrf)r+rrrcollateral_victimss rrzFastChildWatcher.__exit__vsp ZZ KK1 K{{$-- Z "%T]]!3  MM   !  C  Zs/B/BBc |jsJd|j5 |jj|} ddd||g|y#t$r||f|j |<YdddywxYw#1swY |j|=y#t$rYywxYwrrrs rrz%FastChildWatcher.remove_child_handlerrrc tjdtj\}}|dk(ryt|}|j 5 |j j|\}}|jjrtjd|| dddtjd||n |||g#t$rYywxYw#t$r\|jrK||j|<|jjrtjd||Yddd4d}YwxYw#1swYxYw)Nr@rrz,unknown process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %d)r!rrr"rrrrrrrr#r`rrrf)r+rr$rrUrVs rrz FastChildWatcher._do_waitpid_alls8 < jjRZZ8 V !83F; 6%)__%8%8%=NHdzz++- %K%(*6!& #Z1j040K%   ${{-7 c*:://1"LL*>),j:! $H $sN'CD= C'2D= CCAD:*D=5D:7D=9D::D==E) rrrrr)r1rrr}rrrrs@rrrWs+.    )(1rrcReZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zy )ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cPi|_d|_tjdddy)Nrrrr)r_saved_sighandlerr6rrs rr)zMultiLoopChildWatcher.__init__s*!%4;%, .rc|jduSr )rrs rrzzMultiLoopChildWatcher.is_actives%%T11rcZ|jj|jytjtj }||j k7rtjdd|_ytjtj |jd|_y)Nz+SIGCHLD handler was changed by outside code) rr9rrI getsignalrrrrf)r+rds rr1zMultiLoopChildWatcher.closesz   ! ! ) ""6>>2 dnn $ NNH I"& MM&..$*@*@ A!%rc|Sr rrs rrzMultiLoopChildWatcher.__enter__rrcyr rr+rexc_valexc_tbs rrzMultiLoopChildWatcher.__exit__rrcrtj}|||f|j|<|j|yr )rrrr)r+rrUrVrs rr}z'MultiLoopChildWatcher.add_child_handlers5&&( $h5 rc> |j|=y#t$rYywxYwrrrs rrz*MultiLoopChildWatcher.remove_child_handlerrrc8|jytjtj|j|_|j*t j dtj |_tjtjdy)NzaPrevious SIGCHLD handler was set by non-Python code, restore to default handler on watcher close.F)rrIrrrrfrcrQrs rrz!MultiLoopChildWatcher.attach_loopso  ! ! - !'v~~t~~!N  ! ! ) NNJ K%+^^D " FNNE2rcZt|jD]}|j|yr rrs rrz%MultiLoopChildWatcher._do_waitpid_alls#(C   S !)rc8|dkDsJ tj|tj\}}|dk(ryt|}d} |jj|\}}}|jrt j d||y|r'|jrt jd|||j|||g|y#t$r|}d}t j d|d}YwxYw#t$rt j d|d YywxYw) NrTrrF%Loop %r that handles pid %r is closedrrr>)r!rrr"rrrfrr is_closedrr#rr`) r+rrr$r debug_logrrUrVs rrz!MultiLoopChildWatcher._do_waitpidsa **\2::>KCax/7JI L#'??#6#6s#; D(D~~FcR!1LL!G!-z;)))(CKdK=! CJ NNJ I $ / NND / /s#'C C5 %C21C25!DDc |jy#ttf$rt$rt j ddYywxYw)NrTr>)rrrrrrf)r+rrs rrzMultiLoopChildWatcher._sig_chld<sE R  "-.   R NNAD Q Rs/AAN)rrrrr)rzr1rrr}rrrrrrrrrrsA $.2 & 3""#LJRrrcdeZdZdZdZdZdZdZdZe jfdZ dZ d Z d Zd Zy ) raAThreaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. cFtjd|_i|_yr) itertoolsr _pid_counter_threadsrs rr)zThreadedChildWatcher.__init__Rs%OOA. rcyrFrrs rrzzThreadedChildWatcher.is_activeVrqrcyr rrs rr1zThreadedChildWatcher.closeYrrc|Sr rrs rrzThreadedChildWatcher.__enter__\rrcyr rrs rrzThreadedChildWatcher.__exit___rrct|jjDcgc]}|jr|}}|r||jdt |yycc}w)Nz0 has registered but not finished child processesr/)r4rvaluesis_aliver-r8)r+r9threadthreadss rr:zThreadedChildWatcher.__del__bse(,T]]-A-A-C(D)(Dfoo'(D)  T^^$$TU!  )sA!ctj}tj|jdt |j ||||fd}||j|<|jy)Nzasyncio-waitpid-T)targetnamerVdaemon) rrrThreadrnextrrstart)r+rrUrVrrs rr}z&ThreadedChildWatcher.add_child_handlerjsf&&(!!)9)9)9$t?P?P:Q9R'S(,c8T'B)-/$ c rcyrFrrs rrz)ThreadedChildWatcher.remove_child_handlersrrcyr rrs rrz ThreadedChildWatcher.attach_loopyrrc|dkDsJ tj|d\}}t|}|jrt j d|| |jrt jd||n|j|||g||jj|y#t $r|}d}t jd|Y~wxYw)Nrrrrr) r!rr"rrr#rrfrrrr)r+rrrUrVrr$rs rrz ThreadedChildWatcher._do_waitpid|sa 7**\15KC07J~~ C):7 >>  NNBD# N %D % %hZ G$ G ,''! CJ NNJ   sB..#CCN)rrrrr)rzr1rrr6r7r:r}rrrrrrrrEsB   %MM  (rrcttdsy tj}tjtj|dy#t $rYywxYw)NrFrT)hasattrr!getpidr1rrM)rs r can_use_pidfdr&sO 2| $iik sA&'  s=A AAcBeZdZdZeZfdZdZfdZdZ dZ xZ S)_UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.c0t|d|_yr )r(r)_watcherrs rr)z$_UnixDefaultEventLoopPolicy.__init__s  rctj5|j)trt |_nt |_dddy#1swYyxYwr )rrr*r&rrrs r _init_watcherz)_UnixDefaultEventLoopPolicy._init_watchers6 \\}}$ ?$5$7DM$8$:DM \\s 6AAct|||jEtjtj ur|jj |yyy)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)r(set_event_loopr*rcurrent_thread main_threadr)r+rr-s rr.z*_UnixDefaultEventLoopPolicy.set_event_loopsS t$ MM %((*i.C.C.EE MM % %d +F &rc|j|jtjddd|jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. ryrrr)r*r,r6rrs rryz-_UnixDefaultEventLoopPolicy.get_child_watchers@ ==    0:BI K}}rc|t|tsJ|j|jj||_t j dddy)z$Set the watcher for child processes.Nset_child_watcherrrr)rfrr*r1r6r)r+rs rr3z-_UnixDefaultEventLoopPolicy.set_child_watchersT*W6J"KKK == $ MM   ! 0:BI Kr) rrrrr& _loop_factoryr)r,r.ryr3rrs@rr(r(s%D*M; ,  Krr()4rrSrr r!rrIrrrr2rr6rrrrrr r r r r logr__all__rT ImportErrorrr"BaseSelectorEventLoopr& ReadTransportrj_FlowControlMixinWriteTransportrrBaseSubprocessTransportr|rrrrrrrr&BaseDefaultEventLoopPolicyr(rrrrrr?se8     <<7 C DD P"_BBP"f MZ55M`Jj::(77JZ FF 0S$S$l7,7t2+2jN-'N-bj1'j1Z~R0~RBO(/O(b 6K&"C"C6Kr+4r__pycache__/exceptions.cpython-312.opt-2.pyc000064400000004623152343231170014606 0ustar00 ֦i dZGddeZeZGddeZGddeZGddeZ Gd d eZ Gd d eZ y ))BrokenBarrierErrorCancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc eZdZy)rN__name__ __module__ __qualname__+/usr/lib64/python3.12/asyncio/exceptions.pyrr s+rrc eZdZy)rNr rrrrrs5rrc eZdZy)rNr rrrrrsrrc&eZdZ fdZdZxZS)rc||dn t|}t| t|d|d||_||_y)N undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrr r_expected __class__s rrzIncompleteReadError.__init__$sE$,$4[$x.  CL>)C&<8 9   rcHt||j|jffSN)typerrrs r __reduce__zIncompleteReadError.__reduce__+sDzDLL$--888rr r r rr# __classcell__rs@rrrs !9rrc&eZdZ fdZdZxZS)rc2t||||_yr )rrconsumed)rmessager)rs rrzLimitOverrunError.__init__5s !  rcNt||jd|jffS)N)r!argsr)r"s rr#zLimitOverrunError.__reduce__9s"DzDIIaL$--888rr$r&s@rrr/s !9rrc eZdZy)rNr rrrrr=s4rrN) __all__ BaseExceptionrr Exceptionr RuntimeErrorrEOFErrorrrrrrrr4s^ ( ,], 6 6 9(9$ 9 955r__pycache__/format_helpers.cpython-312.pyc000064400000007435152343231170014503 0ustar00 ֦id ZddlZddlZddlZddlZddlZddlmZdZdZdZ d dZ d dZ y) N) constantsc\tj|}tj|r$|j}|j|j fSt |tjrt|jSt |tjrt|jSyN) inspectunwrap isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcodes //usr/lib64/python3.12/asyncio/format_helpers.pyrr s >>$ D$}}  $"5"566$ ))*#DII..$ //0#DII.. c\t||d}t|}|r|d|dd|dz }|S)Nz at r:r)_format_callbackr)rargs func_reprsources r_format_callback_sourcersB tT2I !$ 'F tF1I;aq {33 rcg}|r|jd|D|r&|jd|jDdjdj|S)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). c3FK|]}tj|ywrreprlibrepr).0args r z*_format_args_and_kwargs..&s7$3W\\#&$s!c3VK|]!\}}|dtj|#yw)=Nr)r"kvs rr$z*_format_args_and_kwargs..(s)I.$!Qs!GLLO,-.s')z({})z, )extenditemsformatjoin)rkwargsr*s r_format_args_and_kwargsr.sQ E  7$77  I&,,.II ==5) **rct|tjr;t|||z}t |j |j |j|St|dr|jr |j}n0t|dr|jr |j}n t|}|t||z }|r||z }|S)N __qualname____name__) r rrr.rrrkeywordshasattrr0r1r!)rrr-suffixrs rrr,s$ ))*(v6? 499dmmVLLt^$):):%% z "t}}MM J  (v66I V rc|tjj}|tj}t j jt j||d}|j|S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. F)limit lookup_lines) sys _getframef_backrDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr6stacks r extract_stackrC>sj y MMO " " }++  " " * *9+?+?+B168= + ?E MMO Lr))NN) rrr r8r<rDrrrr.rrCrrrFs0   +$r__pycache__/base_events.cpython-312.pyc000064400000251334152343231170013766 0ustar00 ֦i26dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlm Z ddl!m"Z"dZ#dZ$dZ%e&e dZ'dZ(dZ)dZ*dZ+d&dZ,d'dZ-dZ.e&e drdZ/ndZ/dZ0Gd d!ejbZ2Gd"d#ejfZ4Gd$d%ejjZ6y#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/lib64/python3.12/asyncio/base_events.py_format_handler Gs=   B'"j$/<BKK  6{ch|tjk(ry|tjk(ryt|S)Nzz) subprocessPIPESTDOUTr)fds r _format_piper'Ps+ 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_reuseportr2Ys` 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! a ]  s) collections OrderedDictrBlistvaluesextend itertoolschain from_iterable zip_longest) addrinfosfirst_address_family_countaddrinfos_by_familyaddrrFaddrinfos_lists reordereds r_interleave_addrinfosrds&113a , ,*,  'F#**40  .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._wakeup0s3-- F;;=!!$'r!c *|jryd|_|jD]p}|j|j|jj |j ||j||j|j|jry)NT) rrlistenrr_start_servingrrrr)rr1s rrzServer._start_serving7sp ==  MMD KK & JJ % %&&d.?.?dmmT%@%@** ,"r!c|jSrP)rrs rget_loopzServer.get_loopBs zzr!c|jSrP)rrs r is_servingzServer.is_servingEs }}r!cT|jytd|jDS)NrQc3FK|]}tj|ywrP)rTransportSocket)rRss rrTz!Server.sockets..LsF 1V++A. s!)rtuplers rrzServer.socketsHs$ == F FFFr!cP|j}|yd|_|D]}|jj|d|_|j;|jj s!|jj d|_|jdk(r|jyy)NFr) rr _stop_servingrrrrrr)rrr1s rclosez Server.closeNs-- ?  D JJ $ $T *  % % 1--224  % % , , .(,D %    " LLN #r!cjK|jtjdd{y7w)Nr)rr sleeprs r start_servingzServer.start_servingas% 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_forevergs  $ $ 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)namecontextc2|j|j3tj||||}|jrM|jd=n?||j||}n|j|||}tj || |~S#~wxYw)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 , s BBcB|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_shutdownfs 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_foreverws   ++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_soon2sDxtW=  # #((, 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_thread9sB ?? " '')  ''( ( (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_threadsafeJs`  ;;  +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_executorUs  ;;  '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_executores,(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_debugjsq!"  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.getaddrinfosU ;;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$rP} d| dt | j }t | j|} |j| Yd} ~ d} ~ wwxYw7f#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/rlowererrnopop sock_connectr)rr addr_infolocal_addr_infos my_exceptionsrFtype_rH_r)r1lfamilyladdrrmrs r _connect_sockzBaseEventLoop._connect_socks  -(+4(ua# .==U%HD   U #+/?+GQ1e&(  2 %( 0@%+//11%(OyPV&WXX##D'2 2 2*. -J1#2'',ir#c(..2B1CE&cii5%,,S11 2 3    %   )- -JskE#z;BaseEventLoop.create_connection...]s$2D2D&+3r!NrQ)rRrrr rs rrTz2BaseEventLoop.create_connection..Zs' ).H)1).srrzcreate_connection failedc3:K|]}t|k(ywrPr)rRrmmodels rrTz2BaseEventLoop.create_connection..psGJSs3x50JszMultiple exceptions: {}rc32K|]}t|ywrPr)rRrms rrTz2BaseEventLoop.create_connection..us%E*3c#h*sz5host 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"rrrrrinfosrsubrmrrrr rs` @@@rcreate_connectionzBaseEventLoop.create_connectionsq(  &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&+&? ? !&(66 ). )   |-7GZc3Cc3cZG &!,-GTT:!+(m+!$JqM 2GJGG",Q-/&&?&F&F II%E*%EE'GHH | KMMyyF...!8ACC%)$E$E "C"7!5%F%77 8 ;;++H5D LL:tT9h @(""mN," ?#! ! H "&J 7sBJI4;JI7*J>I=I:I=*JJ JJ"J'A8JAJ1J2AJ7J:I== J J J  JJJJc .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_addrrFrHrr3r4rc36K|]\}}|s |d|yw)=NrQ)rRkvs rrTz9BaseEventLoop.create_datagram_endpoint..=s!$NLDAqAs!A3ZLs  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 expectedrrzcan 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) rrrr6rFrHrr3r4r1optsproblemsr_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'5D' 40E'(<==6*Q-{"B 6==)<)D)DEIIj1&,UO%/$=$?#B #$j/A{3C!DIC' *4 7CIN"+,A"BB&*&;&; f6G6G"'u4'<'A!A %")*M"NN7<3CCG#&*C"*437, 33:JsOC0 8="E&r,rwrCrr}platformrrUabcIterablerYr rWsetrZr[r\r+rGr|rwarningrBr-r. SO_REUSEADDRr@rr2rAr*r` IPV6_V6ONLYrr/rr EADDRNOTAVAILrrrGr:rrrrr)rrrDrErFrr1rrurZr3rrrrhostsfsr completedresrLsocktyperH canonnamesarMrrrs r create_serverzBaseEventLoop.create_servers8 c4 HI I ,CE E + BD D   d #  t/ NPP$ "7 2 Os||x7O GrzT3' {'?'?@$%#d11$V8=2?# % ,,++E 55e<=EI4 % C9<6B%B!%}}R5ANN4($"--v/B/BDJ"bV^^V__,M&M&t,"&//1#FN;(;(;(.(:(:(,. @ " ;!V!:?%@%$d1g%%@#CDD!  ' !(| !LMMyyF... #EdX!NOOfGD   U #g'7W&;,.   ! ! #++a. ;; KK 0 c%,"<<!;;"NN,G+-xO! !4# @#%c#hnn&6 899(;(;;#KKM JJL#{{ &s 3$%cii54? @&A! ' !(!( !sC QL'*QL,.Q1 P?L/C P M/1P? P PB(Q>P>?.Q/9M,(P+M,,P/ P8A=P5P;PPPP;;Q)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_socketRs 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_pipeps#%##%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|rrrurvs rconnect_write_pipez BaseEventLoop.connect_write_pipes#%##%33D(FK  LL ;; LL< 8 =(""   OO  rxcr|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)rrcmdr4r5r6r~r3r7rrrr8r 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)rrprogramr4r5r6r~r3r7rrrr2r8 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_listrstriprrBrrG) rr rSrgr_ log_linesrRvaluetbs rdefault_exception_handlerz'BaseEventLoop.default_exception_handlers[++i(9GKK ,  YI4K4KLHH g -$$0$$66$$66 & 'I '?C..CLE((WWY2259:F$**WWY2259:F$U    uBug. /#  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-rrGrr*rr)rr ctxthingrms rrZz$BaseEventLoop.call_exception_handler+sq,  " " * ,..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_callbackss"  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_signalsafexs 6" r!cH|jr|xjdz c_yy)z3Notification that a TimerHandle has been cancelled.rN)rrrs r_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s!     ' '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_runrrrfr ) r sched_count new_scheduledrrjrr=end_timentodoirrs rrzBaseEventLoop._run_onces$//* 6 6  ' '+ 55 6M//$$(-F%!((0 * 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 uA[[((*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$r2rVr+r:rrYr? AI_PASSIVErqrsrwrzr}r#r$rrrrrrZrrrrr{rrrQr!rrrs/< ))-d4 %""%)$" 9=" $t"&!%!% "CG" @D(," AE)-"04" ""7DG "20DK40$L*.%MM - :>06:$26&%("=A 5 * 2"#!1H7 A(, A./4*).X59Q#14T"&!%!%$Q#j*/"&!% #8-<#'-<^1"4%*(,.2-1 .+bEID#./q267;$ D#N'(f.@.@%&a D59K####"&!%K^"&!% #<# # %&0__&0oo&0oo27%)1(,T "#J%/OOJOO%/__$)1'+Dt #D' *"0>dF0P'  - N` :Tr!r)rr)r)7__doc__rUcollections.abcconcurrent.futuresrrrrZrCr+rAr#rfrrr}rLrru ImportErrorr5rrrrrr r r r r rrlogr__all__rrr*rArr r'r2rMrdrnrrrwProtocolryAbstractServerrAbstractEventLooprrQr!rrs-      $ #),% FJ ' #J8v," 6=!G  > A) 2 2A)HBV " "BJPTF,,PTk  CsDDD__pycache__/base_events.cpython-312.opt-2.pyc000064400000226663152343231170014735 0ustar00 ֦i24 ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZ ddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%edZ&dZ'dZ(dZ)dZ*d%dZ+d&dZ,dZ-e%edrdZ.ndZ.dZ/Gdd ej`Z1Gd!d"ejdZ3Gd#d$ejhZ5y#e$rdZYwxYw)'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/lib64/python3.12/asyncio/base_events.py_format_handler Gs=   B'"j$/<BKK  6{ch|tjk(ry|tjk(ryt|S)Nzz) subprocessPIPESTDOUTr)fds r _format_piper'Ps+ 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_reuseportr2Ys` 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%c tj}|D]$}|d}||vrg||<||j|&t|j }g}|dkDr%|j |dd|dz |dd|dz =|j dt jjt j|D|S)Nrrc3$K|]}|| ywN).0as r z(_interleave_addrinfos..s! a ]  s) collections OrderedDictrBlistvaluesextend itertoolschain from_iterable zip_longest) addrinfosfirst_address_family_countaddrinfos_by_familyaddrrFaddrinfos_lists reordereds r_interleave_addrinfosrds7%113a , ,*,  'F#**40  .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!c.|xjdz c_yrq)rrs r_attachzServer._attach&s ar!c|xjdzc_|jdk(r|j|jyyy)Nrr)rr_wakeuprs r_detachzServer._detach*s; a    "t}}'< LLN(= "r!c||j}d|_|D]$}|jr|jd&yrP)rdoner)rwaiterswaiters rrzServer._wakeup0s3-- F;;=!!$'r!c *|jryd|_|jD]p}|j|j|jj |j ||j||j|j|jryNT) rrlistenrr_start_servingrrrr)rr1s rrzServer._start_serving7sp ==  MMD KK & JJ % %&&d.?.?dmmT%@%@** ,"r!c|jSrP)rrs rget_loopzServer.get_loopBs zzr!c|jSrP)rrs r is_servingzServer.is_servingEs }}r!cT|jytd|jDS)NrQc3FK|]}tj|ywrP)rTransportSocket)rRss rrTz!Server.sockets..LsF 1V++A. s!)rtuplers rrzServer.socketsHs$ == F FFFr!cP|j}|yd|_|D]}|jj|d|_|j;|jj s!|jj d|_|jdk(r|jyy)NFr) rr _stop_servingrrrrrr)rrr1s rclosez Server.closeNs-- ?  D JJ $ $T *  % % 1--224  % % , , .(,D %    " LLN #r!cjK|jtjdd{y7w)Nr)rr sleeprs r start_servingzServer.start_servingas% 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_forevergs  $ $ 0$!MNP P ==  ;< < $(JJ$<$<$>! -++ + +)-D % ,((   &&(((  )-D %s`A&C)B8B9B>CBC #C?CCC CC  C CCcK |jy|jj}|jj||d{y7wrP)rrrrB)rrs rrzServer.wait_closed|sE ( == ))+ V$ sA A 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!c0 tj|S)Nr)rFuturers rrzBaseEventLoop.create_futures:~~4((r!N)namecontextc4 |j|j3tj||||}|jrM|jd=n?||j||}n|j|||}tj || |~S#~wxYw)N)rr r r ) _check_closedrr r_source_traceback_set_task_name)rcoror r tasks r create_taskzBaseEventLoop.create_tasks      %::dD'JD%%**2.))$5))$g)F  t , s BBcD |t|s td||_y)Nz'task factory must be a callable or None)callabler>r)rfactorys rset_task_factoryzBaseEventLoop.set_task_factorys*   x'8EF F$r!c |jSrP)rrs rget_task_factoryzBaseEventLoop.get_task_factorysJ!!!r!)extraserverc trPNotImplementedError)rr1protocolrrrs r_make_socket_transportz$BaseEventLoop._make_socket_transports &!!r!FT) server_sideserver_hostnamerrrrcall_connection_madec trPr) rrawsockr sslcontextrr!r"rrrrr#s r_make_ssl_transportz!BaseEventLoop._make_ssl_transports  $!!r!c trPr)rr1raddressrrs r_make_datagram_transportz&BaseEventLoop._make_datagram_transports (!!r!c trPrrpiperrrs r_make_read_pipe_transportz'BaseEventLoop._make_read_pipe_transports )!!r!c trPrr,s r_make_write_pipe_transportz(BaseEventLoop._make_write_pipe_transports *!!r!c K twrPr) rrargsshellstdinstdoutstderrbufsizerkwargss r_make_subprocess_transportz(BaseEventLoop._make_subprocess_transport s +!!s c trPrrs r_write_to_selfzBaseEventLoop._write_to_selfs "!r!c trPr)r event_lists r_process_eventszBaseEventLoop._process_eventss &!!r!c2|jr tdy)NzEvent loop is closed)rrrs rrzBaseEventLoop._check_closeds <<56 6 r!c2|jr tdy)Nz!Executor shutdown has been called)rrrs r_check_default_executorz%BaseEventLoop._check_default_executor#s  ) )BC C *r!c|jj||js+|j|j|j yyrP)rdiscardrcall_soon_threadsaferacloseragens r_asyncgen_finalizer_hookz&BaseEventLoop._asyncgen_finalizer_hook's? %~~  % %d&6&6 F r!c|jr tjd|dt||jj |y)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() callsource)rwarningswarnResourceWarningraddrFs r_asyncgen_firstiter_hookz&BaseEventLoop._asyncgen_firstiter_hook,sA  * * MM)$212 . D!r!cK d|_t|jsyt|j}|jj t j |Dcgc]}|jc}ddid{}t||D].\}}t|ts|jd|||d0ycc}w7Gw)NTreturn_exceptionsz;an error occurred during closing of asynchronous generator )messagergasyncgen) rlenrrWclearr gatherrEzipr Exceptioncall_exception_handler)r closing_agensagresultsresultrGs rshutdown_asyncgensz BaseEventLoop.shutdown_asyncgens5s:*.'4??# T__-   $1 2MbbiikM 2$"$$ 7LFD&),++"99= B!' $ -83$s$A!C#C: CC &C,!CcK d|_|jy|j}tj|j |f}|j  tj|4d{|d{dddd{|jy7/7'7#1d{7swY)xYw#t$r?tjd|dtd|jjdYywxYww) NT)targetr2z:The executor did not finishing joining its threads within z seconds.) stacklevelFwait)rrr threadingThread _do_shutdownstartr timeoutjoin TimeoutErrorrLrMRuntimeWarningshutdown)rrjfuturethreads rshutdown_default_executorz'BaseEventLoop.shutdown_default_executorNs *.&  ! ! ) ##%!!):):&K  ''00 10 KKM11000 8 MM007y C(Q 8  " " + + + 7  8sAD B?4B$5B?8B*>B&?B* B?B(B?D $B?&B*(B?*B<0B3 1B<8B??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_shutdownfs 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)N) firstiter finalizerF)rrw_set_coroutine_origin_tracking_debugsysget_asyncgen_hooksrf get_identrset_asyncgen_hooksrPrHr_set_running_loop _run_oncer)rold_agen_hookss r run_foreverzBaseEventLoop.run_foreverws)   ++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)NrFz+Event loop stopped before Future completed.)rrwrisfuturer 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??5C44C77Dc d|_yr)rrs rrkzBaseEventLoop.stops r!cn |jr td|jry|jrt j d|d|_|j j|jjd|_ |j}|d|_ |jdyy)Nz!Cannot close a running event loopzClose %rTFrd) rrrr|rdebugrrVrrrrnrexecutors rrzBaseEventLoop.closes  ?? BC C <<  ;; LLT *   )-&))  %)D "   5  ) r!c |jSrP)rrs rrzBaseEventLoop.is_closeds8||r!c|js4|d|t||js|jyyy)Nzunclosed event loop rJ)rrNrr)r_warns r__del__zBaseEventLoop.__del__s=~~ (1?4 P??$ % r!c |jduSrP)rrs rrzBaseEventLoop.is_runnings8t+,r!c, tjSrP)rrrs rrzBaseEventLoop.times ~~r!r c | td|j|j|z|g|d|i}|jr |jd=|S)Nzdelay must not be Noner r )r>call_atrr)rdelaycallbackr r2timers r call_laterzBaseEventLoop.call_latersd  =45 5 TYY[50(.T.%,.  " "''+ r!cP | td|j|jr"|j|j |dt j |||||}|jr |jd=tj|j|d|_ |S)Nzwhen cannot be Nonerr T) r>rr| _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)N call_soonr )rr|rr _call_soonrrrr r2rs rrzBaseEventLoop.call_soonsf   ;;     ; 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_soon2sDxtW=  # #((, 6" r!c| |jytj}||jk7r tdy)NzMNon-thread-safe operation invoked on an event loop other than the current one)rrfrr)r thread_ids rrzBaseEventLoop._check_thread9sG  ?? " '')  ''( ( (r!c |j|jr|j|d|j|||}|jr |jd=|j |S)NrDr )rr|rrrr;rs rrDz"BaseEventLoop.call_soon_threadsafeJsc0  ;;  +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) rr|rrrA concurrentrThreadPoolExecutor wrap_futuresubmit)rrfuncr2s rrzBaseEventLoop.run_in_executorUs  ;;  '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_executores,(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_debugjsq!"  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.getaddrinfosU ;;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!cK g}|j||\}}}}} d} tj|||} | jd|G|D]!\} }}}} | |k7r | j| n"|r|jt d|d|j| | d{| dx}}S#t$rP} d| dt | j }t | j|} |j| Yd} ~ d} ~ wwxYw7f#t$r)} |j| | | jd} ~ w| | jxYw#dx}}wxYww)NrFrGrHF*error while attempting to bind on address : z&no matching local address with family=z found) rBr+ setblockingbindr/rlowererrnopop sock_connectr)rr addr_infolocal_addr_infos my_exceptionsrFtype_rH_r)r1lfamilyladdrrmrs r _connect_sockzBaseEventLoop._connect_socks2  -(+4(ua# .==U%HD   U #+/?+GQ1e&(  2 %( 0@%+//11%(OyPV&WXX##D'2 2 2*. -J1#2'',ir#c(..2B1CE&cii5%,,S11 2 3    %   )- -Jsk E$AD D DD E$EEEE!!E$) rurFrHrr1 local_addrr"rrhappy_eyeballs_delay interleave all_errorsc DK | |s td| |r|s td|} | |s td| |s td| t|| |d}||| tdj||f|tj||d{}|s t d| :j| |tj||d{s t dd|r t ||}g| %|D]} j|d{}n0n.tjfd |D| d{d }|ʉDcgc] }|D]}| c}} |r td tdk(rd td tfd Drd t djdjdD| td|j tjk7rtd|j#|||| | | d{\}}j$r+|j'd}t)j*d|||||||fS777f#t $rYwxYw7Jcc}}w#dwxYw7kw)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with ssl0ssl_shutdown_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timerFrGrHrr!getaddrinfo() returned empty listc30K|] }|ffd yw)c*j|SrP)r)rr laddr_infosrs rz;BaseEventLoop.create_connection...]s$2D2D&+3r!NrQ)rRrrr rs rrTz2BaseEventLoop.create_connection..Zs' ).H)1).srrzcreate_connection failedc3:K|]}t|k(ywrPr)rRrmmodels rrTz2BaseEventLoop.create_connection..psGJSs3x50JszMultiple exceptions: {}rc32K|]}t|ywrPr)rRrms rrTz2BaseEventLoop.create_connection..us%E*3c#h*sz5host 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"rrrrrinfosrsubrmrrrr rs` @@@rcreate_connectionzBaseEventLoop.create_connectionsv   &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&+&? ? !&(66 ). )   |-7GZc3Cc3cZG &!,-GTT:!+(m+!$JqM 2GJGG",Q-/&&?&F&F II%E*%EE'GHH | KMMyyF...!8ACC%)$E$E "C"7!5%F%77 8 ;;++H5D LL:tT9h @(""mN," ?#! ! H "&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'r r) 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)NzTransport is closing_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport ) rrrr _SendfileMode UNSUPPORTED TRY_NATIVE_sendfile_nativerr_sendfile_fallback)rrrrrrrrms rsendfilezBaseEventLoop.sendfiles ,    !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_tlssB  ;CD D*cnn5!n&' 'y"95AYM)IJL L##%++ (J "7!5!& (  !|,^^L$@$@)L NN9#;#;<  LL***   OO            s0CD6 C8%C6&C8* D66C88;D33D6)rFrHr reuse_portallow_broadcastr1c FK | | jtjk(rtd| |s |s |s|s|s|s|rGt |||||||} dj d| j D} td| d| jdd} nb|s|s|dk(r td ||fd ff} nttd r|tjk(r||fD] }|t|trtd |rO|dd vrH 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)Nz$A datagram socket was expected, got )r remote_addrrFrHrr3r4rc36K|]\}}|s |d|yw)=NrQ)rRkvs rrTz9BaseEventLoop.create_datagram_endpoint..=s!$NLDAqAs!A3ZLs  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 expectedrrzcan 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) rrrr6rFrHrr3r4r1optsproblemsr_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'5D' 40E'(<==6*Q-{"B 6==)<)D)DEIIj1&,UO%/$=$?#B #$j/A{3C!DIC' *4 7CIN"+,A"BB&*&;&; f6G6G"'u4'<'A!A %")*M"NN7<3CCG#&*C"*437, 33:JsOC0 8="E&r,rwrCr r}platformrrUabcIterablerYr rWsetrZr[r\r+rGr|rwarningrBr-r. SO_REUSEADDRr@rr2rAr*r` IPV6_V6ONLYrr/rr EADDRNOTAVAILrrrGr:rrrrr)rrrDrErFrr1rrurZr3rrrrhostsfsr completedresrLsocktyperH canonnamesarMrrrs r create_serverzBaseEventLoop.create_servers  c4 HI I ,CE E + BD D   d #  t/ NPP$ "7 2 Os||x7O GrzT3' {'?'?@$%#d11$V8=2?# % ,,++E 55e<=EI4 % C9<6B%B!%}}R5ANN4($"--v/B/BDJ"bV^^V__,M&M&t,"&//1#FN;(;(;(.(:(:(,. @ " ;!V!:?%@%$d1g%%@#CDD!  ' !(| !LMMyyF... #EdX!NOOfGD   U #g'7W&;,.   ! ! #++a. ;; KK 0 c%,"<<!;;"NN,G+-xO! !4# @#%c#hnn&6 899(;(;;#KKM JJL#{{ &s 3$%cii54? @&A! ' !(!( !sC QL(+QL-.Q2 P L0C P !M02P P P B(Q?P?.Q09M-)P ,M--P 0 P9A=P6P <PPP P<<Q)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_socketRs 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_pipeps#%##%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|rrrurvs rconnect_write_pipez BaseEventLoop.connect_write_pipes#%##%33D(FK  LL ;; LL< 8 =(""   OO  rxcr|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)rrcmdr4r5r6r~r3r7rrrr8r 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)rrprogramr4r5r6r~r3r7rrrr2r8 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 |jSrP)rrs rget_exception_handlerz#BaseEventLoop.get_exception_handlers &&&r!cJ |t|std|||_y)Nz+A callable object or None is expected, got )rr>r)rhandlers rset_exception_handlerz#BaseEventLoop.set_exception_handlers:   x'8##*+/0 0")r!c |jd}|sd}|jd}|t|||jf}nd}d|vr;|j/|jjr|jj|d<|g}t |D]}|dvr||}|dk(r:dj tj|}d }||jz }nJ|dk(r:dj tj|}d }||jz }n t|}|j|d |tjd j || y)NrSz!Unhandled exception in event looprgFsource_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_listrstriprrBrrG) rr rSrgr_ log_linesrRvaluetbs rdefault_exception_handlerz'BaseEventLoop.default_exception_handlers` ++i(9GKK ,  YI4K4KLHH g -$$0$$66$$66 & 'I '?C..CLE((WWY2259:F$**WWY2259:F$U    uBug. /#  TYYy)H=r!c |j |j|y d}|jd}||jd}||jd}|t|dr|j}|*t|dr|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) 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-rrGrr*rr)rr ctxthingrms rrZz$BaseEventLoop.call_exception_handler+sv *  " " * ,..w7$ 0 F+=$KK1E=#KK1E$ )F++-C?wsE':GGD33T7C++D':3 12   , E&*,  ,0 12   0022#I%(#*4 #$56$0LL"?+/000  0sMB8BC-%C-8/C*)C*-E DE/E E EEE cV |js|jj|yyrP) _cancelledrrBrrs r _add_callbackzBaseEventLoop._add_callbackss%%  KK  v &!r!cH |j||jyrP)rr;rs r_add_callback_signalsafez&BaseEventLoop._add_callback_signalsafexsD 6" r!cJ |jr|xjdz c_yyrq)rrrs r_timer_handle_cancelledz%BaseEventLoop._timer_handle_cancelled}s$A     ' '1 , ' r!cd t|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)NFrrzExecuting %s took %.3f seconds)rUr_MIN_SCHEDULED_TIMER_HANDLESr%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONrrBrheapifyheappoprr_whenrmaxrMAXIMUM_SELECT_TIMEOUT _selectorselectr>rrangepopleftr|r_runrrrfr ) r sched_count new_scheduledrrjrr=end_timentodoirrs rrzBaseEventLoop._run_onces $//* 6 6  ' '+ 55 6M//$$(-F%!((0 * 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 uA[[((*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)Urrrrrrrrrr r'r*r.r0r9r;r>rrArHrPr_rqrhrwrrrkrrrLrMrrrrrrrrrrDrrrrrrrrrrrrr%r#r$r2rVr+r:rrYr? AI_PASSIVErqrsrwrzr}r#r$rrrrrrZrrrrr{rrrQr!rrrs/< ))-d4 %""%)$" 9=" $t"&!%!% "CG" @D(," AE)-"04" ""7DG "20DK40$L*.%MM - :>06:$26&%("=A 5 * 2"#!1H7 A(, A./4*).X59Q#14T"&!%!%$Q#j*/"&!% #8-<#'-<^1"4%*(,.2-1 .+bEID#./q267;$ D#N'(f.@.@%&a D59K####"&!%K^"&!% #<# # %&0__&0oo&0oo27%)1(,T "#J%/OOJOO%/__$)1'+Dt #D' *"0>dF0P'  - N` :Tr!r)rr)r)6rUcollections.abcconcurrent.futuresrrrrZrCr+rAr#rfrrr}rLrru ImportErrorr5rrrrrr r r r r rrlogr__all__rrr*rArr r'r2rMrdrnrrrwProtocolryAbstractServerrAbstractEventLooprrQr!rrs-      $ #),% FJ ' #J8v," 6=!G  > A) 2 2A)HBV " "BJPTF,,PTk  CsD DD__pycache__/__init__.cpython-312.pyc000064400000002663152343231170013226 0ustar00 ֦idZddlZddlddlddlddlddlddlddlddl ddl ddl ddl ddl ddlddlddlddlej$ej$zej$zej$zej$zej$zej$ze j$ze j$ze j$ze j$ze j$zej$zej$zej$zej$zZej&dk(rddleej$z Zyddleej$z Zy)z'The asyncio package, tracking PEP 3156.N)*win32)__doc__sys base_events coroutinesevents exceptionsfutureslocks protocolsrunnersqueuesstreams subprocesstasks taskgroupstimeoutsthreads transports__all__platformwindows_events unix_events)/usr/lib64/python3.12/asyncio/__init__.pyrsZ-         >>      ??   ==        ??  >>  ??      ==      ??         "<<7! ~%%%G {"""Gr__pycache__/base_subprocess.cpython-312.opt-2.pyc000064400000036646152343231170015621 0ustar00 ֦i"ddlZddlZddlZddlmZddlmZddlmZGddejZ Gdd ejZ Gd d e ejZ y) N) protocols) transports)loggerceZdZ dfd ZdZdZdZdZdZdZ e jfdZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZxZS)BaseSubprocessTransportc nt || d|_||_||_d|_d|_d|_g|_tj|_ i|_ d|_ |tjk(rd|jd<|tjk(rd|jd<|tjk(rd|jd< |j d||||||d| |j j$|_|j |j&d<|jj)r?t+|t,t.fr|} n|d} t1j2d| |j |jj5|j7| y#|j#xYw) NFrr)argsshellstdinstdoutstderrbufsize subprocesszprocess %r created: pid %s)super__init___closed _protocol_loop_proc_pid _returncode _exit_waiters collectionsdeque_pending_calls_pipes _finishedrPIPE_startclosepid_extra get_debug isinstancebytesstrrdebug create_task_connect_pipes)selfloopprotocolr r r rrrwaiterextrakwargsprogram __class__s 0/usr/lib64/python3.12/asyncio/base_subprocess.pyrz BaseSubprocessTransport.__init__ sx  !   )//1  JOO #!DKKN Z__ $!DKKN Z__ $!DKKN  DKK BTeF%w B:@ B JJNN $(JJ L! ::   !$ -q' LL5 $)) - t226:;  JJL s F!!F4c^|jjg}|jr|jd|j|jd|j|j |jd|j n/|j|jdn|jd|j jd}||jd|j|j jd}|j jd }|#||ur|jd |jn@||jd |j||jd |jd jdj|S)Nclosedzpid=z returncode=runningz not startedrzstdin=rr zstdout=stderr=zstdout=zstderr=z<{}> ) r4__name__rappendrrrgetpipeformatjoin)r-infor rrs r5__repr__z BaseSubprocessTransport.__repr__7sX''( << KK ! 99 KK$tyyk* +    ' KK+d&6&6%78 9 YY " KK " KK & "   KK& - .##  &F"2 KK. 6 7! gfkk]34! gfkk]34}}SXXd^,,c tN)NotImplementedError)r-r r r rrrr2s r5r"zBaseSubprocessTransport._startTs!!rBc||_yrDr)r-r/s r5 set_protocolz$BaseSubprocessTransport.set_protocolWs !rBc|jSrDrGr-s r5 get_protocolz$BaseSubprocessTransport.get_protocolZs ~~rBc|jSrD)rrJs r5 is_closingz"BaseSubprocessTransport.is_closing]s ||rBc|jryd|_|jjD]}||jj !|j t|j g|j jL|jjrtjd| |j jyyyy#t$rYywxYw)NTz$Close running child process: kill %r)rrvaluesr=r#rrpollrr&rwarningkillProcessLookupError)r-protos r5r#zBaseSubprocessTransport.close`s <<  [['')E} JJ   * JJ "  ( !)zz##%EtL  ! *) #&  s4C CCcb|js#|d|t||jyy)Nzunclosed transport )source)rResourceWarningr#)r-_warns r5__del__zBaseSubprocessTransport.__del__{s+|| 'x0/$ O JJLrBc|jSrD)rrJs r5get_pidzBaseSubprocessTransport.get_pids yyrBc|jSrD)rrJs r5get_returncodez&BaseSubprocessTransport.get_returncodesrBcR||jvr|j|jSyrD)rr=)r-fds r5get_pipe_transportz*BaseSubprocessTransport.get_pipe_transports%  ;;r?'' 'rBc0|j tyrD)rrSrJs r5 _check_procz#BaseSubprocessTransport._check_procs :: $& & rBcZ|j|jj|yrD)rbr send_signal)r-signals r5rdz#BaseSubprocessTransport.send_signals   v&rBcX|j|jjyrD)rbr terminaterJs r5rgz!BaseSubprocessTransport.terminates  rBcX|j|jjyrD)rbrrRrJs r5rRzBaseSubprocessTransport.kills  rBcK j}j}|j9|jfd|jd{\}}|jd<|j 9|j fd|j d{\}}|jd<|j9|j fd|jd{\}}|jd<|jjjjD]\}}|j|g|d_ |#|js|jdyyy777#ttf$rt $r7}|+|js|j#|Yd}~yYd}~yYd}~yd}~wwxYww)NctdS)Nr)WriteSubprocessPipeProtorJsr5z8BaseSubprocessTransport._connect_pipes..s 4T1=rBrctdS)NrReadSubprocessPipeProtorJsr5rlz8BaseSubprocessTransport._connect_pipes.. 3D!.rprBr )rrr connect_write_piperrconnect_read_piper call_soonrconnection_mader cancelled set_result SystemExitKeyboardInterrupt BaseException set_exception) r-r0procr._r=callbackdataexcs ` r5r,z&BaseSubprocessTransport._connect_pipess# (::D::Dzz% $ 7 7=JJ!  4"& A{{& $ 6 6<KK!!!4"& A{{& $ 6 6<KK!!!4"& A NN4>>994 @"&"5"5$x/$/#6"&D !&*:*:*<!!$'+=!; ! !-.   *!&*:*:*<$$S))+=! *shF?AE- E& AE-E)AE-E+A*E-&F?&E-)E-+E--F<#F7(F?7F<<F?c|j|jj||fy|jj|g|yrD)rr;rrt)r-cbrs r5_callzBaseSubprocessTransport._calls?    *    & &Dz 2 DJJ  +d +rBcr|j|jj|||jyrD)rrpipe_connection_lost _try_finish)r-r_rs r5_pipe_connection_lostz-BaseSubprocessTransport._pipe_connection_losts( 4>>66C@ rBcR|j|jj||yrD)rrpipe_data_received)r-r_rs r5_pipe_data_receivedz+BaseSubprocessTransport._pipe_data_receiveds 4>>44b$?rBc,|jjrtjd||||_|j j ||j _|j|jj|jy)Nz%r exited with return code %r) rr&rr@rr returncoderrprocess_exitedr)r-rs r5_process_exitedz'BaseSubprocessTransport._process_exitedsm ::   ! KK7z J% :: (%/DJJ ! 4>>001 rBcK |j |jS|jj}|jj ||d{S7wrD)rr create_futurerr;)r-r0s r5_waitzBaseSubprocessTransport._waitsU '    '## #))+ !!&)||sAAAAc|jytd|jjDr$d|_|j |j dyy)Nc3@K|]}|duxr |jywrD) disconnected).0ps r5 z6BaseSubprocessTransport._try_finish..s(.,1}//,sT)rallrrOr r_call_connection_lostrJs r5rz#BaseSubprocessTransport._try_finishsS    #  . **,. .!DN JJt114 8 .rBc |jj||jD].}|jr|j |j 0d|_d|_d|_d|_y#|jD].}|jr|j |j 0d|_d|_d|_d|_wxYwrD)rconnection_lostrrvrwrrr)r-rr0s r5rz-BaseSubprocessTransport._call_connection_losts " NN * *3 /,,'')%%d&6&67-"&D DJDJ!DN ,,'')%%d&6&67-"&D DJDJ!DNsA77 C:C)NN)r: __module__ __qualname__rrAr"rHrKrMr#warningswarnrYr[r]r`rbrdrgrRr,rrrrrrr __classcell__)r4s@r5rr s%)))r4r:r_r=rJs r5rAz!WriteSubprocessPipeProto.__repr__ s04>>**+4ytyym1MMrBcld|_|jj|j|d|_y)NT)rr|rr_)r-rs r5rz(WriteSubprocessPipeProto.connection_lost s)  ''5 rBcL|jjjyrD)r|r pause_writingrJs r5rz&WriteSubprocessPipeProto.pause_writings ))+rBcL|jjjyrD)r|rresume_writingrJs r5rz'WriteSubprocessPipeProto.resume_writings **,rBN) r:rrrrurArrrrrBr5rkrks!" N ,-rBrkceZdZdZy)rocP|jj|j|yrD)r|rr_)r-rs r5 data_receivedz%ReadSubprocessPipeProto.data_receiveds %%dggt4rBN)r:rrrrrBr5roros5rBro)rrrrrlogrSubprocessTransportr BaseProtocolrkProtocolrorrBr5rsTr"j<<r"j-y55-456'005rB__pycache__/locks.cpython-312.opt-1.pyc000064400000065435152343231170013547 0ustar00 ֦i3J`dZdZddlZddlZddlmZddlmZGddZGd d eejZ Gd d ejZ Gd deejZ GddeejZ Gdde Z GddejZGddejZy)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreBarrierN) exceptions)mixinsceZdZdZdZy)_ContextManagerMixinc@K|jd{y7wN)acquireselfs &/usr/lib64/python3.12/asyncio/locks.py __aenter__z_ContextManagerMixin.__aenter__ slln s c,K|jywr)release)rexc_typeexctbs r __aexit__z_ContextManagerMixin.__aexit__s sN)__name__ __module__ __qualname__rrrr r s  rr c@eZdZdZdZfdZdZdZdZdZ xZ S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... c d|_d|_yNF)_waiters_lockedrs r__init__z Lock.__init__Ms  rct|}|jrdnd}|jr|dt |j}d|ddd|dS Nlockedunlocked , waiters:)super__repr__r$r#lenrresextra __class__s rr0z Lock.__repr__QsYg  LLj ==gZDMM(:';zLock.acquire..cs9=aAKKM=sT) r$r#all collectionsdeque _get_loop create_futureappendremover CancelledError_wake_up_firstrfuts rrz Lock.acquire\s  $--"794==99DL == '--/DMnn,,. S!   *  $$S)   $$S)(( <<##%  sBBD#C$C %C)C/D# CC,,C//1D  D#c`|jrd|_|jytd)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r$rG RuntimeErrorrs rrz Lock.release|s* << DL    !67 7rc|jsy tt|j}|j s|j dyy#t$rYywxYw)z*Wake up the first waiter if it isn't done.NT)r#nextiter StopIterationdone set_resultrHs rrGzLock._wake_up_firstsT}}  tDMM*+Cxxz NN4     sA AA) rrr__doc__r%r0r(rrrG __classcell__r5s@rrrs(3j*@8" !rrc@eZdZdZdZfdZdZdZdZdZ xZ S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. cDtj|_d|_yr")r@rAr#_valuers rr%zEvent.__init__s#))+  rct|}|jrdnd}|jr|dt |j}d|ddd|dS) Nsetunsetr*r+r r,r-r.)r/r0rWr#r1r2s rr0zEvent.__repr__sYg ' ==gZDMM(:';= 0) ValueErrorr#rW)rvalues rr%zSemaphore.__init__Ys# 19CD D  rct|}|jrdnd|j}|jr|dt |j}d|ddd|dS) Nr(zunlocked, value:r*r+r r,r-r.)r/r0r(rWr#r1r2s rr0zSemaphore.__repr___sgg  KKM1A$++/O ==gZDMM(:';K|]}|j ywrr9r;s rr>z#Semaphore.locked..isA,?aAKKM!,?sr)rWanyr#rs rr(zSemaphore.lockedfs4{{aC ADMM,?R,?A A CrcK|js|xjdzc_y|jtj|_|j j }|jj| |d{|jj| |jdkDr|jy7@#|jj|wxYw#tj$r7|js%|xjdz c_|jwxYww)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. r TNr) r(rWr#r@rArBrCrDrEr rFr: _wake_up_nextrHs rrzSemaphore.acquireks{{} KK1 K == '--/DMnn,,. S!  *  $$S) ;;?     $$S)(( ==? q ""$   sCBD> CCCC1.!D>CC..C11A D;;D>cN|xjdz c_|jy)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. r N)rWr~rs rrzSemaphore.releases q  rc|jsy|jD]:}|jr|xjdzc_|jdyy)z)Wake up the first waiter that isn't done.Nr T)r#rPrWrQrHs rr~zSemaphore._wake_up_nexts@}} ==C88: q t$ !rrt) rrrrRr%r0r(rrr~rSrTs@rrrJs(  *C "H rrc.eZdZdZdfd ZfdZxZS)rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. c2||_t| |yr) _bound_valuer/r%)rrxr5s rr%zBoundedSemaphore.__init__s! rcj|j|jk\r tdt|y)Nz(BoundedSemaphore released too many times)rWrrwr/r)rr5s rrzBoundedSemaphore.releases+ ;;$++ +GH H rrt)rrrrRr%rrSrTs@rrrs  rrceZdZdZdZdZdZy) _BarrierStatefillingdraining resettingbrokenN)rrrFILLINGDRAINING RESETTINGBROKENrrrrrsGHI FrrceZdZdZdZfdZdZdZdZdZ dZ d Z d Z d Z d Zed ZedZedZxZS)ra Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. c|dkr tdt|_||_tj |_d|_y)z1Create a barrier, initialised to 'parties' tasks.r zparties must be >= 1rN)rwr_cond_partiesrr_state_count)rpartiess rr%zBarrier.__init__s9 Q;34 4[  #++  rct|}|jj}|js|d|j d|j z }d|ddd|dS)Nr*/r+r r,r-r.)r/r0rrxr n_waitingrr2s rr0zBarrier.__repr__sdg ;;$$%{{ z$..!14<<.A AE3q9+Rwb))rc>K|jd{S7wrrjrs rrzBarrier.__aenter__sYY[   s c Kywrr)rargss rrzBarrier.__aexit__s  sc0K|j4d{|jd{ |j}|xjdz c_|dz|jk(r|j d{n|j d{||xjdzc_|j cdddd{S777Y7B7 #|xjdzc_|j wxYw#1d{7swYyxYww)zWait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. Nr )r_blockrr_release_wait_exit)rindexs rrbz Barrier.waits:::++-     q 19 ---/))**,&& q  ::  *& q  ::sDC DDCDAC7C8CCC%D; DCDDCCD'C>>DDD DDcKjjfdd{jtjurt j dy76w)Nc\jtjtjfvSr)rrrrrsrz Barrier._block..s$DKK&& (?(?(rzBarrier aborted)rrmrrrr BrokenBarrierErrorrs`rrzBarrier._blocksZ jj!!     ;;-.. .//0AB B / s"AA7AcjKtj|_|jj ywr)rrrrrsrs rrzBarrier._releases% $,,  s13cKjjfdd{jtjtj fvrt jdy7Fw)Nc<jtjuSr)rrrrsrrzBarrier._wait..s$++]=R=R*RrzAbort or reset of barrier)rrmrrrrr rrs`rrz Barrier._waits] jj!!"RSSS ;;=//1H1HI I//0KL L J Ts"A.A,AA.c|jdk(r\|jtjtjfvrtj |_|j jyy)Nr)rrrrrrrrsrs rrz Barrier._exitsO ;;! {{}66 8N8NOO+33 JJ ! ! # rchK|j4d{|jdkDr2|jtjur+tj|_ntj |_|jj dddd{y77#1d{7swYyxYww)zReset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. Nr)rrrrrrrsrs rresetz Barrier.reset"sk :::{{Q;;m&=&=="/"9"9DK+33 JJ ! ! #::::::sEB2BB2A1B B2BB2B2B/#B& $B/+B2cK|j4d{tj|_|jj dddd{y7D7#1d{7swYyxYww)zPlace the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. N)rrrrrsrs rabortz Barrier.abort1sA :::'..DK JJ ! ! #::::::sDA1AA10A A1AA1A1A."A% #A.*A1c|jS)z8Return the number of tasks required to trip the barrier.)rrs rrzBarrier.parties;s}}rcT|jtjur |jSy)zrs! * C! !7!7C!L:&F " ":&zm($f&<&<m(`W$f&<&<Wty$DIIM3f$$M3r__pycache__/transports.cpython-312.opt-2.pyc000064400000020722152343231170014642 0ustar00 ֦i) dZGddZGddeZGddeZGddeeZGd d eZGd d eZGd deZy)) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc:eZdZ dZd dZd dZdZdZdZdZ y) r_extraNc|i}||_yNr )selfextras +/usr/lib64/python3.12/asyncio/transports.py__init__zBaseTransport.__init__s =E c< |jj||Sr )r get)r namedefaults rget_extra_infozBaseTransport.get_extra_infos1{{tW--rc tr NotImplementedErrorr s r is_closingzBaseTransport.is_closings @!!rc tr rrs rclosezBaseTransport.close "!rc tr r)r protocols r set_protocolzBaseTransport.set_protocol%s !!!rc tr rrs r get_protocolzBaseTransport.get_protocol)s *!!rr ) __name__ __module__ __qualname__ __slots__rrrrr!r#rrrr s($I .""""rrc$eZdZ dZdZdZdZy)rr(c tr rrs r is_readingzReadTransport.is_reading3s 8!!rc tr rrs r pause_readingzReadTransport.pause_reading7 "!rc tr rrs rresume_readingzReadTransport.resume_reading?r.rN)r$r%r&r'r+r-r0r(rrrr.s-I"""rrcDeZdZ dZd dZdZdZdZdZdZ d Z d Z y) rr(Nc tr rr highlows rset_write_buffer_limitsz&WriteTransport.set_write_buffer_limitsMs $"!rc tr rrs rget_write_buffer_sizez$WriteTransport.get_write_buffer_sizebs :!!rc tr rrs rget_write_buffer_limitsz&WriteTransport.get_write_buffer_limitsfs %"!rc tr r)r datas rwritezWriteTransport.writelr.rcJ dj|}|j|y)Nr)joinr=)r list_of_datar<s r writelineszWriteTransport.writelinests# xx % 4rc tr rrs r write_eofzWriteTransport.write_eof} "!rc tr rrs r can_write_eofzWriteTransport.can_write_eofs O!!rc tr rrs rabortzWriteTransport.abortrDrNN) r$r%r&r'r6r8r:r=rArCrFrHr(rrrrHs2.I"*"" """"rrceZdZ dZy)rr(N)r$r%r&r'r(rrrrs(Irrc eZdZ dZddZdZy)rr(Nc tr r)r r<addrs rsendtozDatagramTransport.sendtorrc tr rrs rrHzDatagramTransport.abortrDrr )r$r%r&r'rNrHr(rrrrs2I""rrc4eZdZdZdZdZdZdZdZdZ y) rr(c tr rrs rget_pidzSubprocessTransport.get_pids  !!rc tr rrs rget_returncodez"SubprocessTransport.get_returncoder.rc tr r)r fds rget_pipe_transportz&SubprocessTransport.get_pipe_transports 4!!rc tr r)r signals r send_signalzSubprocessTransport.send_signalr.rc tr rrs r terminatezSubprocessTransport.terminates "!rc tr rrs rkillzSubprocessTransport.kills "!rN) r$r%r&r'rRrTrWrZr\r^r(rrrrs%I"""" " "rrcNeZdZ dZd fd ZdZdZdZd dZd dZ dZ xZ S) _FlowControlMixin)_loop_protocol_paused _high_water _low_waterc`t||||_d|_|j y)NF)superrrarb_set_write_buffer_limits)r rloop __class__s rrz_FlowControlMixin.__init__s+  % %%'rc@|j}||jkry|js#d|_ |jj yy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NTzprotocol.pause_writing() failedmessage exception transportr ) r8rcrb _protocol pause_writing SystemExitKeyboardInterrupt BaseExceptionracall_exception_handler)r sizeexcs r_maybe_pause_protocolz'_FlowControlMixin._maybe_pause_protocols))+ 4## # $$$(D ! ,,.% 12    11@!$!% $ 3 sAB)*BBc<|jrA|j|jkr#d|_ |jj yyy#t t f$rt$r4}|jjd|||jdYd}~yd}~wwxYw)NFz protocol.resume_writing() failedrk) rbr8rdroresume_writingrqrrrsrart)r rvs r_maybe_resume_protocolz(_FlowControlMixin._maybe_resume_protocol's  ! !**,?$)D ! --/@ "  12    11A!$!% $ 3 sAB'*BBc2|j|jfSr )rdrcrs rr:z)_FlowControlMixin.get_write_buffer_limits7s!1!122rc| |d}nd|z}||dz}||cxk\rdk\sntd|d|d||_||_y)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorrcrdr3s rrgz*_FlowControlMixin._set_write_buffer_limits:sh <{ 3w ;!)Csa 23'HJ J rcJ|j|||jy)N)r4r5)rgrwr3s rr6z)_FlowControlMixin.set_write_buffer_limitsJs! %%4S%9 ""$rctr rrs rr8z'_FlowControlMixin.get_write_buffer_sizeNs!!rrI) r$r%r&r'rrwrzr:rgr6r8 __classcell__)ris@rr`r`s3 KI($ 3 %"rr`N)__all__rrrrrrr`r(rrrsj  """"J"M"4I"]I"X ~0" "23"-3"lT" T"r__pycache__/windows_utils.cpython-312.pyc000064400000016247152343231170014404 0ustar00 ֦idZddlZejdk7redddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ejZ ejZejZdde d d ZGd d ZGd dej&Zy)z)Various Windows specific bits and pieces.Nwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec tjdjtjt t }|r6tj}tjtjz}||}}n$tj}tj}d|}}|tjz}|dr|tjz}|drtj}nd}dx} } tj||tjd||tj tj"} tj$||dtj"tj&|tj"} tj(| d} | j+d| | fS#| tj,| | tj,| xYw)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr )tempfilemktempformatosgetpidnext _mmap_counter_winapiPIPE_ACCESS_DUPLEX GENERIC_READ GENERIC_WRITEPIPE_ACCESS_INBOUNDFILE_FLAG_FIRST_PIPE_INSTANCEFILE_FLAG_OVERLAPPEDCreateNamedPipe PIPE_WAITNMPWAIT_WAIT_FOREVERNULL CreateFile OPEN_EXISTINGConnectNamedPipeGetOverlappedResult CloseHandle) rr r addressopenmodeaccessobsizeibsizeflags_and_attribsh1h2ovs ./usr/lib64/python3.12/asyncio/windows_utils.pyrr soo188 IIKm,./G--%%(=(== '..&&G 555H!}G000!}#88NB  $ $ Xw00 vvw;;W\\K   VQ g.C.C w||- % %bT : t$2v  >    # >    # s *B6F!!1Gc|eZdZdZdZdZedZdZe jddZ e jfdZd Zd Zy ) rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. c||_yN_handleselfhandles r/__init__zPipeHandle.__init__Vs  cx|jd|j}nd}d|jjd|dS)Nzhandle=closed< >)r4 __class____name__r5s r/__repr__zPipeHandle.__repr__YsB << #t||./FF4>>**+1VHA66r9c|jSr2r3r6s r/r7zPipeHandle.handle`s ||r9cH|j td|jS)NzI/O operation on closed pipe)r4 ValueErrorrCs r/filenozPipeHandle.filenods" << ;< <||r9)r%cP|j||jd|_yyr2r3)r6r%s r/closezPipeHandle.closeis$ << #  %DL $r9cb|j#|d|t||jyy)Nz unclosed )source)r4ResourceWarningrH)r6_warns r/__del__zPipeHandle.__del__ns- << # IdX& E JJL $r9c|Sr2rCs r/ __enter__zPipeHandle.__enter__ss r9c$|jyr2)rH)r6tvtbs r/__exit__zPipeHandle.__exit__vs  r9N)r@ __module__ __qualname____doc__r8rApropertyr7rFrr%rHwarningswarnrMrPrUrOr9r/rrQsR7 $+#6#6 %MM r9rc$eZdZdZdfd ZxZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. c ,|jdrJ|jdddk(sJdx}x}}dx} x} } |tk(r5tdd\} } tj| t j }n|}|tk(r&td\} } tj| d}n|}|tk(r&td\} }tj|d}n|tk(r|}n|} t|$|f|||d || t| |_ | t| |_ | t| |_ |tk(rt j ||tk(rt j ||tk(rt j |yy#| | | fD]}|tj|xYw#|tk(rt j ||tk(rt j ||tk(rt j |wwxYw) Nuniversal_newlinesr r)FTT)r r)TFr)stdinstdoutstderr)getrrmsvcrtopen_osfhandlerO_RDONLYSTDOUTsuperr8rr_r`rarr%rH)r6argsr_r`rakwds stdin_rfd stdout_wfd stderr_wfdstdin_wh stdout_rh stderr_rhstdin_rh stdout_wh stderr_whhr?s r/r8zPopen.__init__s880111xx 1%***.22 2J+///9y D=!%t!L Hh--h DII T>#'=#A Iy..y!#'=#A Iy..y!r}s/ <<7 l ##  0     ! \7+b&&X0%J  0%r9constants.py000064400000002605152343231170007136 0ustar00# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io import enum # After the connection is lost, log warnings after this many write()s. LOG_THRESHOLD_FOR_CONNLOST_WRITES = 5 # Seconds to wait before retrying accept(). ACCEPT_RETRY_DELAY = 1 # Number of stack entries to capture in debug mode. # The larger the number, the slower the operation in debug mode # (see extract_stack() in format_helpers.py). DEBUG_STACK_DEPTH = 10 # Number of seconds to wait for SSL handshake to complete # The default timeout matches that of Nginx. SSL_HANDSHAKE_TIMEOUT = 60.0 # Number of seconds to wait for SSL shutdown to complete # The default timeout mimics lingering_time SSL_SHUTDOWN_TIMEOUT = 30.0 # Used in sendfile fallback code. We use fallback for platforms # that don't support sendfile, or for TLS connections. SENDFILE_FALLBACK_READBUFFER_SIZE = 1024 * 256 FLOW_CONTROL_HIGH_WATER_SSL_READ = 256 # KiB FLOW_CONTROL_HIGH_WATER_SSL_WRITE = 512 # KiB # Default timeout for joining the threads in the threadpool THREAD_JOIN_TIMEOUT = 300 # The enum should be here to break circular dependencies between # base_events and sslproto class _SendfileMode(enum.Enum): UNSUPPORTED = enum.auto() TRY_NATIVE = enum.auto() FALLBACK = enum.auto() proactor_events.py000064400000101334152343231170010336 0ustar00"""Event loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. """ __all__ = 'BaseProactorEventLoop', import io import os import socket import warnings import signal import threading import collections from . import base_events from . import constants from . import futures from . import exceptions from . import protocols from . import sslproto from . import transports from . import trsock from .log import logger def _set_socket_extra(transport, sock): transport._extra['socket'] = trsock.TransportSocket(sock) try: transport._extra['sockname'] = sock.getsockname() except socket.error: if transport._loop.get_debug(): logger.warning( "getsockname() failed on %r", sock, exc_info=True) if 'peername' not in transport._extra: try: transport._extra['peername'] = sock.getpeername() except socket.error: # UDP sockets may not have a peer name transport._extra['peername'] = None class _ProactorBasePipeTransport(transports._FlowControlMixin, transports.BaseTransport): """Base class for pipe and socket transports.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(extra, loop) self._set_extra(sock) self._sock = sock self.set_protocol(protocol) self._server = server self._buffer = None # None or bytearray. self._read_fut = None self._write_fut = None self._pending_write = 0 self._conn_lost = 0 self._closing = False # Set when close() called. self._called_connection_lost = False self._eof_written = False if self._server is not None: self._server._attach() self._loop.call_soon(self._protocol.connection_made, self) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') if self._sock is not None: info.append(f'fd={self._sock.fileno()}') if self._read_fut is not None: info.append(f'read={self._read_fut!r}') if self._write_fut is not None: info.append(f'write={self._write_fut!r}') if self._buffer: info.append(f'write_bufsize={len(self._buffer)}') if self._eof_written: info.append('EOF written') return '<{}>'.format(' '.join(info)) def _set_extra(self, sock): self._extra['pipe'] = sock def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._closing: return self._closing = True self._conn_lost += 1 if not self._buffer and self._write_fut is None: self._loop.call_soon(self._call_connection_lost, None) if self._read_fut is not None: self._read_fut.cancel() self._read_fut = None def __del__(self, _warn=warnings.warn): if self._sock is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._sock.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): try: if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) finally: self._force_close(exc) def _force_close(self, exc): if self._empty_waiter is not None and not self._empty_waiter.done(): if exc is None: self._empty_waiter.set_result(None) else: self._empty_waiter.set_exception(exc) if self._closing and self._called_connection_lost: return self._closing = True self._conn_lost += 1 if self._write_fut: self._write_fut.cancel() self._write_fut = None if self._read_fut: self._read_fut.cancel() self._read_fut = None self._pending_write = 0 self._buffer = None self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): if self._called_connection_lost: return try: self._protocol.connection_lost(exc) finally: # XXX If there is a pending overlapped read on the other # end then it may fail with ERROR_NETNAME_DELETED if we # just close our end. First calling shutdown() seems to # cure it, but maybe using DisconnectEx() would be better. if hasattr(self._sock, 'shutdown') and self._sock.fileno() != -1: self._sock.shutdown(socket.SHUT_RDWR) self._sock.close() self._sock = None server = self._server if server is not None: server._detach() self._server = None self._called_connection_lost = True def get_write_buffer_size(self): size = self._pending_write if self._buffer is not None: size += len(self._buffer) return size class _ProactorReadPipeTransport(_ProactorBasePipeTransport, transports.ReadTransport): """Transport for read pipes.""" def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None, buffer_size=65536): self._pending_data_length = -1 self._paused = True super().__init__(loop, sock, protocol, waiter, extra, server) self._data = bytearray(buffer_size) self._loop.call_soon(self._loop_reading) self._paused = False def is_reading(self): return not self._paused and not self._closing def pause_reading(self): if self._closing or self._paused: return self._paused = True # bpo-33694: Don't cancel self._read_fut because cancelling an # overlapped WSASend() loss silently data with the current proactor # implementation. # # If CancelIoEx() fails with ERROR_NOT_FOUND, it means that WSASend() # completed (even if HasOverlappedIoCompleted() returns 0), but # Overlapped.cancel() currently silently ignores the ERROR_NOT_FOUND # error. Once the overlapped is ignored, the IOCP loop will ignores the # completion I/O event and so not read the result of the overlapped # WSARecv(). if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False if self._read_fut is None: self._loop.call_soon(self._loop_reading, None) length = self._pending_data_length self._pending_data_length = -1 if length > -1: # Call the protocol method after calling _loop_reading(), # since the protocol can decide to pause reading again. self._loop.call_soon(self._data_received, self._data[:length], length) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def _eof_received(self): if self._loop.get_debug(): logger.debug("%r received EOF", self) try: keep_open = self._protocol.eof_received() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.eof_received() call failed.') return if not keep_open: self.close() def _data_received(self, data, length): if self._paused: # Don't call any protocol method while reading is paused. # The protocol will be called on resume_reading(). assert self._pending_data_length == -1 self._pending_data_length = length return if length == 0: self._eof_received() return if isinstance(self._protocol, protocols.BufferedProtocol): try: protocols._feed_data_to_buffered_proto(self._protocol, data) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal error: protocol.buffer_updated() ' 'call failed.') return else: self._protocol.data_received(data) def _loop_reading(self, fut=None): length = -1 data = None try: if fut is not None: assert self._read_fut is fut or (self._read_fut is None and self._closing) self._read_fut = None if fut.done(): # deliver data later in "finally" clause length = fut.result() if length == 0: # we got end-of-file so no need to reschedule a new read return # It's a new slice so make it immutable so protocols upstream don't have problems data = bytes(memoryview(self._data)[:length]) else: # the future will be replaced by next proactor.recv call fut.cancel() if self._closing: # since close() has been called we ignore any read data return # bpo-33694: buffer_updated() has currently no fast path because of # a data loss issue caused by overlapped WSASend() cancellation. if not self._paused: # reschedule a new read self._read_fut = self._loop._proactor.recv_into(self._sock, self._data) except ConnectionAbortedError as exc: if not self._closing: self._fatal_error(exc, 'Fatal read error on pipe transport') elif self._loop.get_debug(): logger.debug("Read error on pipe transport while closing", exc_info=True) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') except exceptions.CancelledError: if not self._closing: raise else: if not self._paused: self._read_fut.add_done_callback(self._loop_reading) finally: if length > -1: self._data_received(data, length) class _ProactorBaseWritePipeTransport(_ProactorBasePipeTransport, transports.WriteTransport): """Transport for write pipes.""" _start_tls_compatible = True def __init__(self, *args, **kw): super().__init__(*args, **kw) self._empty_waiter = None def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError( f"data argument must be a bytes-like object, " f"not {type(data).__name__}") if self._eof_written: raise RuntimeError('write_eof() already called') if self._empty_waiter is not None: raise RuntimeError('unable to write; sendfile is in progress') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return # Observable states: # 1. IDLE: _write_fut and _buffer both None # 2. WRITING: _write_fut set; _buffer None # 3. BACKED UP: _write_fut set; _buffer a bytearray # We always copy the data, so the caller can't modify it # while we're still waiting for the I/O to happen. if self._write_fut is None: # IDLE -> WRITING assert self._buffer is None # Pass a copy, except if it's already immutable. self._loop_writing(data=bytes(data)) elif not self._buffer: # WRITING -> BACKED UP # Make a mutable copy which we can extend. self._buffer = bytearray(data) self._maybe_pause_protocol() else: # BACKED UP # Append to buffer (also copies). self._buffer.extend(data) self._maybe_pause_protocol() def _loop_writing(self, f=None, data=None): try: if f is not None and self._write_fut is None and self._closing: # XXX most likely self._force_close() has been called, and # it has set self._write_fut to None. return assert f is self._write_fut self._write_fut = None self._pending_write = 0 if f: f.result() if data is None: data = self._buffer self._buffer = None if not data: if self._closing: self._loop.call_soon(self._call_connection_lost, None) if self._eof_written: self._sock.shutdown(socket.SHUT_WR) # Now that we've reduced the buffer size, tell the # protocol to resume writing if it was paused. Note that # we do this last since the callback is called immediately # and it may add more data to the buffer (even causing the # protocol to be paused again). self._maybe_resume_protocol() else: self._write_fut = self._loop._proactor.send(self._sock, data) if not self._write_fut.done(): assert self._pending_write == 0 self._pending_write = len(data) self._write_fut.add_done_callback(self._loop_writing) self._maybe_pause_protocol() else: self._write_fut.add_done_callback(self._loop_writing) if self._empty_waiter is not None and self._write_fut is None: self._empty_waiter.set_result(None) except ConnectionResetError as exc: self._force_close(exc) except OSError as exc: self._fatal_error(exc, 'Fatal write error on pipe transport') def can_write_eof(self): return True def write_eof(self): self.close() def abort(self): self._force_close(None) def _make_empty_waiter(self): if self._empty_waiter is not None: raise RuntimeError("Empty waiter is already set") self._empty_waiter = self._loop.create_future() if self._write_fut is None: self._empty_waiter.set_result(None) return self._empty_waiter def _reset_empty_waiter(self): self._empty_waiter = None class _ProactorWritePipeTransport(_ProactorBaseWritePipeTransport): def __init__(self, *args, **kw): super().__init__(*args, **kw) self._read_fut = self._loop._proactor.recv(self._sock, 16) self._read_fut.add_done_callback(self._pipe_closed) def _pipe_closed(self, fut): if fut.cancelled(): # the transport has been closed return assert fut.result() == b'' if self._closing: assert self._read_fut is None return assert fut is self._read_fut, (fut, self._read_fut) self._read_fut = None if self._write_fut is not None: self._force_close(BrokenPipeError()) else: self.close() class _ProactorDatagramTransport(_ProactorBasePipeTransport, transports.DatagramTransport): max_size = 256 * 1024 def __init__(self, loop, sock, protocol, address=None, waiter=None, extra=None): self._address = address self._empty_waiter = None self._buffer_size = 0 # We don't need to call _protocol.connection_made() since our base # constructor does it for us. super().__init__(loop, sock, protocol, waiter=waiter, extra=extra) # The base constructor sets _buffer = None, so we set it here self._buffer = collections.deque() self._loop.call_soon(self._loop_reading) def _set_extra(self, sock): _set_socket_extra(self, sock) def get_write_buffer_size(self): return self._buffer_size def abort(self): self._force_close(None) def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError('data argument must be bytes-like object (%r)', type(data)) if not data: return if self._address is not None and addr not in (None, self._address): raise ValueError( f'Invalid address: must be None or {self._address}') if self._conn_lost and self._address: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.sendto() raised exception.') self._conn_lost += 1 return # Ensure that what we buffer is immutable. self._buffer.append((bytes(data), addr)) self._buffer_size += len(data) if self._write_fut is None: # No current write operations are active, kick one off self._loop_writing() # else: A write operation is already kicked off self._maybe_pause_protocol() def _loop_writing(self, fut=None): try: if self._conn_lost: return assert fut is self._write_fut self._write_fut = None if fut: # We are in a _loop_writing() done callback, get the result fut.result() if not self._buffer or (self._conn_lost and self._address): # The connection has been closed if self._closing: self._loop.call_soon(self._call_connection_lost, None) return data, addr = self._buffer.popleft() self._buffer_size -= len(data) if self._address is not None: self._write_fut = self._loop._proactor.send(self._sock, data) else: self._write_fut = self._loop._proactor.sendto(self._sock, data, addr=addr) except OSError as exc: self._protocol.error_received(exc) except Exception as exc: self._fatal_error(exc, 'Fatal write error on datagram transport') else: self._write_fut.add_done_callback(self._loop_writing) self._maybe_resume_protocol() def _loop_reading(self, fut=None): data = None try: if self._conn_lost: return assert self._read_fut is fut or (self._read_fut is None and self._closing) self._read_fut = None if fut is not None: res = fut.result() if self._closing: # since close() has been called we ignore any read data data = None return if self._address is not None: data, addr = res, self._address else: data, addr = res if self._conn_lost: return if self._address is not None: self._read_fut = self._loop._proactor.recv(self._sock, self.max_size) else: self._read_fut = self._loop._proactor.recvfrom(self._sock, self.max_size) except OSError as exc: self._protocol.error_received(exc) except exceptions.CancelledError: if not self._closing: raise else: if self._read_fut is not None: self._read_fut.add_done_callback(self._loop_reading) finally: if data: self._protocol.datagram_received(data, addr) class _ProactorDuplexPipeTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for duplex pipes.""" def can_write_eof(self): return False def write_eof(self): raise NotImplementedError class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePipeTransport, transports.Transport): """Transport for connected sockets.""" _sendfile_compatible = constants._SendfileMode.TRY_NATIVE def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): super().__init__(loop, sock, protocol, waiter, extra, server) base_events._set_nodelay(sock) def _set_extra(self, sock): _set_socket_extra(self, sock) def can_write_eof(self): return True def write_eof(self): if self._closing or self._eof_written: return self._eof_written = True if self._write_fut is None: self._sock.shutdown(socket.SHUT_WR) class BaseProactorEventLoop(base_events.BaseEventLoop): def __init__(self, proactor): super().__init__() logger.debug('Using proactor: %s', proactor.__class__.__name__) self._proactor = proactor self._selector = proactor # convenient alias self._self_reading_future = None self._accept_futures = {} # socket file descriptor => Future proactor.set_loop(self) self._make_self_pipe() if threading.current_thread() is threading.main_thread(): # wakeup fd can only be installed to a file descriptor from the main thread signal.set_wakeup_fd(self._csock.fileno()) def _make_socket_transport(self, sock, protocol, waiter=None, extra=None, server=None): return _ProactorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) _ProactorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): return _ProactorDatagramTransport(self, sock, protocol, address, waiter, extra) def _make_duplex_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorDuplexPipeTransport(self, sock, protocol, waiter, extra) def _make_read_pipe_transport(self, sock, protocol, waiter=None, extra=None): return _ProactorReadPipeTransport(self, sock, protocol, waiter, extra) def _make_write_pipe_transport(self, sock, protocol, waiter=None, extra=None): # We want connection_lost() to be called when other end closes return _ProactorWritePipeTransport(self, sock, protocol, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return if threading.current_thread() is threading.main_thread(): signal.set_wakeup_fd(-1) # Call these methods before closing the event loop (before calling # BaseEventLoop.close), because they can schedule callbacks with # call_soon(), which is forbidden when the event loop is closed. self._stop_accept_futures() self._close_self_pipe() self._proactor.close() self._proactor = None self._selector = None # Close the event loop super().close() async def sock_recv(self, sock, n): return await self._proactor.recv(sock, n) async def sock_recv_into(self, sock, buf): return await self._proactor.recv_into(sock, buf) async def sock_recvfrom(self, sock, bufsize): return await self._proactor.recvfrom(sock, bufsize) async def sock_recvfrom_into(self, sock, buf, nbytes=0): if not nbytes: nbytes = len(buf) return await self._proactor.recvfrom_into(sock, buf, nbytes) async def sock_sendall(self, sock, data): return await self._proactor.send(sock, data) async def sock_sendto(self, sock, data, address): return await self._proactor.sendto(sock, data, 0, address) async def sock_connect(self, sock, address): if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") return await self._proactor.connect(sock, address) async def sock_accept(self, sock): return await self._proactor.accept(sock) async def _sock_sendfile_native(self, sock, file, offset, count): try: fileno = file.fileno() except (AttributeError, io.UnsupportedOperation) as err: raise exceptions.SendfileNotAvailableError("not a regular file") try: fsize = os.fstat(fileno).st_size except OSError: raise exceptions.SendfileNotAvailableError("not a regular file") blocksize = count if count else fsize if not blocksize: return 0 # empty file blocksize = min(blocksize, 0xffff_ffff) end_pos = min(offset + count, fsize) if count else fsize offset = min(offset, fsize) total_sent = 0 try: while True: blocksize = min(end_pos - offset, blocksize) if blocksize <= 0: return total_sent await self._proactor.sendfile(sock, file, offset, blocksize) offset += blocksize total_sent += blocksize finally: if total_sent > 0: file.seek(offset) async def _sendfile_native(self, transp, file, offset, count): resume_reading = transp.is_reading() transp.pause_reading() await transp._make_empty_waiter() try: return await self.sock_sendfile(transp._sock, file, offset, count, fallback=False) finally: transp._reset_empty_waiter() if resume_reading: transp.resume_reading() def _close_self_pipe(self): if self._self_reading_future is not None: self._self_reading_future.cancel() self._self_reading_future = None self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = socket.socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 def _loop_self_reading(self, f=None): try: if f is not None: f.result() # may raise if self._self_reading_future is not f: # When we scheduled this Future, we assigned it to # _self_reading_future. If it's not there now, something has # tried to cancel the loop while this callback was still in the # queue (see windows_events.ProactorEventLoop.run_forever). In # that case stop here instead of continuing to schedule a new # iteration. return f = self._proactor.recv(self._ssock, 4096) except exceptions.CancelledError: # _close_self_pipe() has been called, stop waiting for data return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self.call_exception_handler({ 'message': 'Error on reading from the event loop self pipe', 'exception': exc, 'loop': self, }) else: self._self_reading_future = f f.add_done_callback(self._loop_self_reading) def _write_to_self(self): # This may be called from a different thread, possibly after # _close_self_pipe() has been called or even while it is # running. Guard for self._csock being None or closed. When # a socket is closed, send() raises OSError (with errno set to # EBADF, but let's not rely on the exact error code). csock = self._csock if csock is None: return try: csock.send(b'\0') except OSError: if self._debug: logger.debug("Fail to write a null byte into the " "self-pipe socket", exc_info=True) def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): def loop(f=None): try: if f is not None: conn, addr = f.result() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) protocol = protocol_factory() if sslcontext is not None: self._make_ssl_transport( conn, protocol, sslcontext, server_side=True, extra={'peername': addr}, server=server, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: self._make_socket_transport( conn, protocol, extra={'peername': addr}, server=server) if self.is_closed(): return f = self._proactor.accept(sock) except OSError as exc: if sock.fileno() != -1: self.call_exception_handler({ 'message': 'Accept failed on a socket', 'exception': exc, 'socket': trsock.TransportSocket(sock), }) sock.close() elif self._debug: logger.debug("Accept failed on socket %r", sock, exc_info=True) except exceptions.CancelledError: sock.close() else: self._accept_futures[sock.fileno()] = f f.add_done_callback(loop) self.call_soon(loop) def _process_events(self, event_list): # Events are processed in the IocpProactor._poll() method pass def _stop_accept_futures(self): for future in self._accept_futures.values(): future.cancel() self._accept_futures.clear() def _stop_serving(self, sock): future = self._accept_futures.pop(sock.fileno(), None) if future: future.cancel() self._proactor._stop_serving(sock) sock.close() queues.py000064400000017446152343231170006442 0ustar00__all__ = ('Queue', 'PriorityQueue', 'LifoQueue', 'QueueFull', 'QueueEmpty') import collections import heapq from types import GenericAlias from . import locks from . import mixins class QueueEmpty(Exception): """Raised when Queue.get_nowait() is called on an empty Queue.""" pass class QueueFull(Exception): """Raised when the Queue.put_nowait() method is called on a full Queue.""" pass class Queue(mixins._LoopBoundMixin): """A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. """ def __init__(self, maxsize=0): self._maxsize = maxsize # Futures. self._getters = collections.deque() # Futures. self._putters = collections.deque() self._unfinished_tasks = 0 self._finished = locks.Event() self._finished.set() self._init(maxsize) # These three are overridable in subclasses. def _init(self, maxsize): self._queue = collections.deque() def _get(self): return self._queue.popleft() def _put(self, item): self._queue.append(item) # End of the overridable methods. def _wakeup_next(self, waiters): # Wake up the next waiter (if any) that isn't cancelled. while waiters: waiter = waiters.popleft() if not waiter.done(): waiter.set_result(None) break def __repr__(self): return f'<{type(self).__name__} at {id(self):#x} {self._format()}>' def __str__(self): return f'<{type(self).__name__} {self._format()}>' __class_getitem__ = classmethod(GenericAlias) def _format(self): result = f'maxsize={self._maxsize!r}' if getattr(self, '_queue', None): result += f' _queue={list(self._queue)!r}' if self._getters: result += f' _getters[{len(self._getters)}]' if self._putters: result += f' _putters[{len(self._putters)}]' if self._unfinished_tasks: result += f' tasks={self._unfinished_tasks}' return result def qsize(self): """Number of items in the queue.""" return len(self._queue) @property def maxsize(self): """Number of items allowed in the queue.""" return self._maxsize def empty(self): """Return True if the queue is empty, False otherwise.""" return not self._queue def full(self): """Return True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. """ if self._maxsize <= 0: return False else: return self.qsize() >= self._maxsize async def put(self, item): """Put an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. """ while self.full(): putter = self._get_loop().create_future() self._putters.append(putter) try: await putter except: putter.cancel() # Just in case putter is not done yet. try: # Clean self._putters from canceled putters. self._putters.remove(putter) except ValueError: # The putter could be removed from self._putters by a # previous get_nowait call. pass if not self.full() and not putter.cancelled(): # We were woken up by get_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._putters) raise return self.put_nowait(item) def put_nowait(self, item): """Put an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. """ if self.full(): raise QueueFull self._put(item) self._unfinished_tasks += 1 self._finished.clear() self._wakeup_next(self._getters) async def get(self): """Remove and return an item from the queue. If queue is empty, wait until an item is available. """ while self.empty(): getter = self._get_loop().create_future() self._getters.append(getter) try: await getter except: getter.cancel() # Just in case getter is not done yet. try: # Clean self._getters from canceled getters. self._getters.remove(getter) except ValueError: # The getter could be removed from self._getters by a # previous put_nowait call. pass if not self.empty() and not getter.cancelled(): # We were woken up by put_nowait(), but can't take # the call. Wake up the next in line. self._wakeup_next(self._getters) raise return self.get_nowait() def get_nowait(self): """Remove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. """ if self.empty(): raise QueueEmpty item = self._get() self._wakeup_next(self._putters) return item def task_done(self): """Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. """ if self._unfinished_tasks <= 0: raise ValueError('task_done() called too many times') self._unfinished_tasks -= 1 if self._unfinished_tasks == 0: self._finished.set() async def join(self): """Block until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. """ if self._unfinished_tasks > 0: await self._finished.wait() class PriorityQueue(Queue): """A subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). """ def _init(self, maxsize): self._queue = [] def _put(self, item, heappush=heapq.heappush): heappush(self._queue, item) def _get(self, heappop=heapq.heappop): return heappop(self._queue) class LifoQueue(Queue): """A subclass of Queue that retrieves most recently added entries first.""" def _init(self, maxsize): self._queue = [] def _put(self, item): self._queue.append(item) def _get(self): return self._queue.pop() events.py000064400000071233152343231170006431 0ustar00"""Event loop and event loop policy.""" # Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io __all__ = ( 'AbstractEventLoopPolicy', 'AbstractEventLoop', 'AbstractServer', 'Handle', 'TimerHandle', 'get_event_loop_policy', 'set_event_loop_policy', 'get_event_loop', 'set_event_loop', 'new_event_loop', 'get_child_watcher', 'set_child_watcher', '_set_running_loop', 'get_running_loop', '_get_running_loop', ) import contextvars import os import signal import socket import subprocess import sys import threading from . import format_helpers class Handle: """Object returned by callback registration methods.""" __slots__ = ('_callback', '_args', '_cancelled', '_loop', '_source_traceback', '_repr', '__weakref__', '_context') def __init__(self, callback, args, loop, context=None): if context is None: context = contextvars.copy_context() self._context = context self._loop = loop self._callback = callback self._args = args self._cancelled = False self._repr = None if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) else: self._source_traceback = None def _repr_info(self): info = [self.__class__.__name__] if self._cancelled: info.append('cancelled') if self._callback is not None: info.append(format_helpers._format_callback_source( self._callback, self._args)) if self._source_traceback: frame = self._source_traceback[-1] info.append(f'created at {frame[0]}:{frame[1]}') return info def __repr__(self): if self._repr is not None: return self._repr info = self._repr_info() return '<{}>'.format(' '.join(info)) def get_context(self): return self._context def cancel(self): if not self._cancelled: self._cancelled = True if self._loop.get_debug(): # Keep a representation in debug mode to keep callback and # parameters. For example, to log the warning # "Executing took 2.5 second" self._repr = repr(self) self._callback = None self._args = None def cancelled(self): return self._cancelled def _run(self): try: self._context.run(self._callback, *self._args) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: cb = format_helpers._format_callback_source( self._callback, self._args) msg = f'Exception in callback {cb}' context = { 'message': msg, 'exception': exc, 'handle': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self = None # Needed to break cycles when an exception occurs. class TimerHandle(Handle): """Object returned by timed callback registration methods.""" __slots__ = ['_scheduled', '_when'] def __init__(self, when, callback, args, loop, context=None): super().__init__(callback, args, loop, context) if self._source_traceback: del self._source_traceback[-1] self._when = when self._scheduled = False def _repr_info(self): info = super()._repr_info() pos = 2 if self._cancelled else 1 info.insert(pos, f'when={self._when}') return info def __hash__(self): return hash(self._when) def __lt__(self, other): if isinstance(other, TimerHandle): return self._when < other._when return NotImplemented def __le__(self, other): if isinstance(other, TimerHandle): return self._when < other._when or self.__eq__(other) return NotImplemented def __gt__(self, other): if isinstance(other, TimerHandle): return self._when > other._when return NotImplemented def __ge__(self, other): if isinstance(other, TimerHandle): return self._when > other._when or self.__eq__(other) return NotImplemented def __eq__(self, other): if isinstance(other, TimerHandle): return (self._when == other._when and self._callback == other._callback and self._args == other._args and self._cancelled == other._cancelled) return NotImplemented def cancel(self): if not self._cancelled: self._loop._timer_handle_cancelled(self) super().cancel() def when(self): """Return a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). """ return self._when class AbstractServer: """Abstract server returned by create_server().""" def close(self): """Stop serving. This leaves existing connections open.""" raise NotImplementedError def get_loop(self): """Get the event loop the Server object is attached to.""" raise NotImplementedError def is_serving(self): """Return True if the server is accepting connections.""" raise NotImplementedError async def start_serving(self): """Start accepting connections. This method is idempotent, so it can be called when the server is already being serving. """ raise NotImplementedError async def serve_forever(self): """Start accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. """ raise NotImplementedError async def wait_closed(self): """Coroutine to wait until service is closed.""" raise NotImplementedError async def __aenter__(self): return self async def __aexit__(self, *exc): self.close() await self.wait_closed() class AbstractEventLoop: """Abstract event loop.""" # Running and stopping the event loop. def run_forever(self): """Run the event loop until stop() is called.""" raise NotImplementedError def run_until_complete(self, future): """Run the event loop until a Future is done. Return the Future's result, or raise its exception. """ raise NotImplementedError def stop(self): """Stop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. """ raise NotImplementedError def is_running(self): """Return whether the event loop is currently running.""" raise NotImplementedError def is_closed(self): """Returns True if the event loop was closed.""" raise NotImplementedError def close(self): """Close the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. """ raise NotImplementedError async def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" raise NotImplementedError async def shutdown_default_executor(self): """Schedule the shutdown of the default executor.""" raise NotImplementedError # Methods scheduling callbacks. All these return Handles. def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" raise NotImplementedError def call_soon(self, callback, *args, context=None): return self.call_later(0, callback, *args, context=context) def call_later(self, delay, callback, *args, context=None): raise NotImplementedError def call_at(self, when, callback, *args, context=None): raise NotImplementedError def time(self): raise NotImplementedError def create_future(self): raise NotImplementedError # Method scheduling a coroutine object: create a task. def create_task(self, coro, *, name=None, context=None): raise NotImplementedError # Methods for interacting with threads. def call_soon_threadsafe(self, callback, *args, context=None): raise NotImplementedError def run_in_executor(self, executor, func, *args): raise NotImplementedError def set_default_executor(self, executor): raise NotImplementedError # Network I/O methods returning Futures. async def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): raise NotImplementedError async def getnameinfo(self, sockaddr, flags=0): raise NotImplementedError async def create_connection( self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, happy_eyeballs_delay=None, interleave=None): raise NotImplementedError async def create_server( self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """A coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. ssl_shutdown_timeout is the time in seconds that an SSL server will wait for completion of the SSL shutdown procedure before aborting the connection. Default is 30s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. """ raise NotImplementedError async def sendfile(self, transport, file, offset=0, count=None, *, fallback=True): """Send a file through a transport. Return an amount of sent bytes. """ raise NotImplementedError async def start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. """ raise NotImplementedError async def create_unix_connection( self, protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): raise NotImplementedError async def create_unix_server( self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file system path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). ssl_shutdown_timeout is the time in seconds that an SSL server will wait for the SSL shutdown to finish (defaults to 30s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. """ raise NotImplementedError async def connect_accepted_socket( self, protocol_factory, sock, *, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Handle an accepted connection. This is used by servers that accept connections outside of asyncio, but use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. """ raise NotImplementedError async def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_address=None, reuse_port=None, allow_broadcast=None, sock=None): """A coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. """ raise NotImplementedError # Pipes and subprocesses. async def connect_read_pipe(self, protocol_factory, pipe): """Register read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def connect_write_pipe(self, protocol_factory, pipe): """Register write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.""" # The reason to accept file-like object instead of just file descriptor # is: we need to own pipe and close it at transport finishing # Can got complicated errors if pass f.fileno(), # close fd in pipe transport then close f and vice versa. raise NotImplementedError async def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError async def subprocess_exec(self, protocol_factory, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, **kwargs): raise NotImplementedError # Ready-based callback registration methods. # The add_*() methods return None. # The remove_*() methods return True if something was removed, # False if there was nothing to delete. def add_reader(self, fd, callback, *args): raise NotImplementedError def remove_reader(self, fd): raise NotImplementedError def add_writer(self, fd, callback, *args): raise NotImplementedError def remove_writer(self, fd): raise NotImplementedError # Completion based I/O methods returning Futures. async def sock_recv(self, sock, nbytes): raise NotImplementedError async def sock_recv_into(self, sock, buf): raise NotImplementedError async def sock_recvfrom(self, sock, bufsize): raise NotImplementedError async def sock_recvfrom_into(self, sock, buf, nbytes=0): raise NotImplementedError async def sock_sendall(self, sock, data): raise NotImplementedError async def sock_sendto(self, sock, data, address): raise NotImplementedError async def sock_connect(self, sock, address): raise NotImplementedError async def sock_accept(self, sock): raise NotImplementedError async def sock_sendfile(self, sock, file, offset=0, count=None, *, fallback=None): raise NotImplementedError # Signal handling. def add_signal_handler(self, sig, callback, *args): raise NotImplementedError def remove_signal_handler(self, sig): raise NotImplementedError # Task factory. def set_task_factory(self, factory): raise NotImplementedError def get_task_factory(self): raise NotImplementedError # Error handlers. def get_exception_handler(self): raise NotImplementedError def set_exception_handler(self, handler): raise NotImplementedError def default_exception_handler(self, context): raise NotImplementedError def call_exception_handler(self, context): raise NotImplementedError # Debug flag management. def get_debug(self): raise NotImplementedError def set_debug(self, enabled): raise NotImplementedError class AbstractEventLoopPolicy: """Abstract policy for accessing the event loop.""" def get_event_loop(self): """Get the event loop for the current context. Returns an event loop object implementing the AbstractEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.""" raise NotImplementedError def set_event_loop(self, loop): """Set the event loop for the current context to loop.""" raise NotImplementedError def new_event_loop(self): """Create and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.""" raise NotImplementedError # Child processes handling (Unix only). def get_child_watcher(self): "Get the watcher for child processes." raise NotImplementedError def set_child_watcher(self, watcher): """Set the watcher for child processes.""" raise NotImplementedError class BaseDefaultEventLoopPolicy(AbstractEventLoopPolicy): """Default policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). """ _loop_factory = None class _Local(threading.local): _loop = None _set_called = False def __init__(self): self._local = self._Local() def get_event_loop(self): """Get the event loop for the current context. Returns an instance of EventLoop or raises an exception. """ if (self._local._loop is None and not self._local._set_called and threading.current_thread() is threading.main_thread()): stacklevel = 2 try: f = sys._getframe(1) except AttributeError: pass else: # Move up the call stack so that the warning is attached # to the line outside asyncio itself. while f: module = f.f_globals.get('__name__') if not (module == 'asyncio' or module.startswith('asyncio.')): break f = f.f_back stacklevel += 1 import warnings warnings.warn('There is no current event loop', DeprecationWarning, stacklevel=stacklevel) self.set_event_loop(self.new_event_loop()) if self._local._loop is None: raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) return self._local._loop def set_event_loop(self, loop): """Set the event loop.""" self._local._set_called = True if loop is not None and not isinstance(loop, AbstractEventLoop): raise TypeError(f"loop must be an instance of AbstractEventLoop or None, not '{type(loop).__name__}'") self._local._loop = loop def new_event_loop(self): """Create a new event loop. You must call set_event_loop() to make this the current event loop. """ return self._loop_factory() # Event loop policy. The policy itself is always global, even if the # policy's rules say that there is an event loop per thread (or other # notion of context). The default policy is installed by the first # call to get_event_loop_policy(). _event_loop_policy = None # Lock for protecting the on-the-fly creation of the event loop policy. _lock = threading.Lock() # A TLS for the running event loop, used by _get_running_loop. class _RunningLoop(threading.local): loop_pid = (None, None) _running_loop = _RunningLoop() def get_running_loop(): """Return the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) loop = _get_running_loop() if loop is None: raise RuntimeError('no running event loop') return loop def _get_running_loop(): """Return the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) running_loop, pid = _running_loop.loop_pid if running_loop is not None and pid == os.getpid(): return running_loop def _set_running_loop(loop): """Set the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. """ # NOTE: this function is implemented in C (see _asynciomodule.c) _running_loop.loop_pid = (loop, os.getpid()) def _init_event_loop_policy(): global _event_loop_policy with _lock: if _event_loop_policy is None: # pragma: no branch from . import DefaultEventLoopPolicy _event_loop_policy = DefaultEventLoopPolicy() def get_event_loop_policy(): """Get the current event loop policy.""" if _event_loop_policy is None: _init_event_loop_policy() return _event_loop_policy def set_event_loop_policy(policy): """Set the current event loop policy. If policy is None, the default policy is restored.""" global _event_loop_policy if policy is not None and not isinstance(policy, AbstractEventLoopPolicy): raise TypeError(f"policy must be an instance of AbstractEventLoopPolicy or None, not '{type(policy).__name__}'") _event_loop_policy = policy def get_event_loop(): """Return an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. """ # NOTE: this function is implemented in C (see _asynciomodule.c) current_loop = _get_running_loop() if current_loop is not None: return current_loop return get_event_loop_policy().get_event_loop() def set_event_loop(loop): """Equivalent to calling get_event_loop_policy().set_event_loop(loop).""" get_event_loop_policy().set_event_loop(loop) def new_event_loop(): """Equivalent to calling get_event_loop_policy().new_event_loop().""" return get_event_loop_policy().new_event_loop() def get_child_watcher(): """Equivalent to calling get_event_loop_policy().get_child_watcher().""" return get_event_loop_policy().get_child_watcher() def set_child_watcher(watcher): """Equivalent to calling get_event_loop_policy().set_child_watcher(watcher).""" return get_event_loop_policy().set_child_watcher(watcher) # Alias pure-Python implementations for testing purposes. _py__get_running_loop = _get_running_loop _py__set_running_loop = _set_running_loop _py_get_running_loop = get_running_loop _py_get_event_loop = get_event_loop try: # get_event_loop() is one of the most frequently called # functions in asyncio. Pure Python implementation is # about 4 times slower than C-accelerated. from _asyncio import (_get_running_loop, _set_running_loop, get_running_loop, get_event_loop) except ImportError: pass else: # Alias C implementations for testing purposes. _c__get_running_loop = _get_running_loop _c__set_running_loop = _set_running_loop _c_get_running_loop = get_running_loop _c_get_event_loop = get_event_loop if hasattr(os, 'fork'): def on_fork(): # Reset the loop and wakeupfd in the forked child process. if _event_loop_policy is not None: _event_loop_policy._local = BaseDefaultEventLoopPolicy._Local() _set_running_loop(None) signal.set_wakeup_fd(-1) os.register_at_fork(after_in_child=on_fork) staggered.py000064400000015645152343231170007077 0ustar00"""Support for running coroutines in parallel with staggered start times.""" __all__ = 'staggered_race', import contextlib from . import events from . import exceptions as exceptions_mod from . import locks from . import tasks async def staggered_race(coro_fns, delay, *, loop=None): """Run coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. """ # TODO: when we have aiter() and anext(), allow async iterables in coro_fns. loop = loop or events.get_running_loop() enum_coro_fns = enumerate(coro_fns) winner_result = None winner_index = None unhandled_exceptions = [] exceptions = [] running_tasks = set() on_completed_fut = None def task_done(task): running_tasks.discard(task) if ( on_completed_fut is not None and not on_completed_fut.done() and not running_tasks ): on_completed_fut.set_result(None) if task.cancelled(): return exc = task.exception() if exc is None: return unhandled_exceptions.append(exc) async def run_one_coro(ok_to_start, previous_failed) -> None: # in eager tasks this waits for the calling task to append this task # to running_tasks, in regular tasks this wait is a no-op that does # not yield a future. See gh-124309. await ok_to_start.wait() # Wait for the previous task to finish, or for delay seconds if previous_failed is not None: with contextlib.suppress(exceptions_mod.TimeoutError): # Use asyncio.wait_for() instead of asyncio.wait() here, so # that if we get cancelled at this point, Event.wait() is also # cancelled, otherwise there will be a "Task destroyed but it is # pending" later. await tasks.wait_for(previous_failed.wait(), delay) # Get the next coroutine to run try: this_index, coro_fn = next(enum_coro_fns) except StopIteration: return # Start task that will run the next coroutine this_failed = locks.Event() next_ok_to_start = locks.Event() next_task = loop.create_task(run_one_coro(next_ok_to_start, this_failed)) running_tasks.add(next_task) next_task.add_done_callback(task_done) # next_task has been appended to running_tasks so next_task is ok to # start. next_ok_to_start.set() # Prepare place to put this coroutine's exceptions if not won exceptions.append(None) assert len(exceptions) == this_index + 1 try: result = await coro_fn() except (SystemExit, KeyboardInterrupt): raise except BaseException as e: exceptions[this_index] = e this_failed.set() # Kickstart the next coroutine else: # Store winner's results nonlocal winner_index, winner_result assert winner_index is None winner_index = this_index winner_result = result # Cancel all other tasks. We take care to not cancel the current # task as well. If we do so, then since there is no `await` after # here and CancelledError are usually thrown at one, we will # encounter a curious corner case where the current task will end # up as done() == True, cancelled() == False, exception() == # asyncio.CancelledError. This behavior is specified in # https://bugs.python.org/issue30048 current_task = tasks.current_task(loop) for t in running_tasks: if t is not current_task: t.cancel() propagate_cancellation_error = None try: ok_to_start = locks.Event() first_task = loop.create_task(run_one_coro(ok_to_start, None)) running_tasks.add(first_task) first_task.add_done_callback(task_done) # first_task has been appended to running_tasks so first_task is ok to start. ok_to_start.set() propagate_cancellation_error = None # Make sure no tasks are left running if we leave this function while running_tasks: on_completed_fut = loop.create_future() try: await on_completed_fut except exceptions_mod.CancelledError as ex: propagate_cancellation_error = ex for task in running_tasks: task.cancel(*ex.args) on_completed_fut = None if __debug__ and unhandled_exceptions: # If run_one_coro raises an unhandled exception, it's probably a # programming error, and I want to see it. raise ExceptionGroup("staggered race failed", unhandled_exceptions) if propagate_cancellation_error is not None: raise propagate_cancellation_error return winner_result, winner_index, exceptions finally: del exceptions, propagate_cancellation_error, unhandled_exceptions log.py000064400000000174152343231170005702 0ustar00"""Logging configuration.""" import logging # Name the logger after the package. logger = logging.getLogger(__package__) exceptions.py000064400000003330152343231170007277 0ustar00"""asyncio exceptions.""" __all__ = ('BrokenBarrierError', 'CancelledError', 'InvalidStateError', 'TimeoutError', 'IncompleteReadError', 'LimitOverrunError', 'SendfileNotAvailableError') class CancelledError(BaseException): """The Future or Task was cancelled.""" TimeoutError = TimeoutError # make local alias for the standard exception class InvalidStateError(Exception): """The operation is not allowed in this state.""" class SendfileNotAvailableError(RuntimeError): """Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. """ class IncompleteReadError(EOFError): """ Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) """ def __init__(self, partial, expected): r_expected = 'undefined' if expected is None else repr(expected) super().__init__(f'{len(partial)} bytes read on a total of ' f'{r_expected} expected bytes') self.partial = partial self.expected = expected def __reduce__(self): return type(self), (self.partial, self.expected) class LimitOverrunError(Exception): """Reached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. """ def __init__(self, message, consumed): super().__init__(message) self.consumed = consumed def __reduce__(self): return type(self), (self.args[0], self.consumed) class BrokenBarrierError(RuntimeError): """Barrier is broken by barrier.abort() call.""" mixins.py000064400000000741152343231170006430 0ustar00"""Event loop mixins.""" import threading from . import events _global_lock = threading.Lock() class _LoopBoundMixin: _loop = None def _get_loop(self): loop = events._get_running_loop() if self._loop is None: with _global_lock: if self._loop is None: self._loop = loop if loop is not self._loop: raise RuntimeError(f'{self!r} is bound to a different event loop') return loop streams.py000064400000065743152343231170006614 0ustar00__all__ = ( 'StreamReader', 'StreamWriter', 'StreamReaderProtocol', 'open_connection', 'start_server') import collections import socket import sys import warnings import weakref if hasattr(socket, 'AF_UNIX'): __all__ += ('open_unix_connection', 'start_unix_server') from . import coroutines from . import events from . import exceptions from . import format_helpers from . import protocols from .log import logger from .tasks import sleep _DEFAULT_LIMIT = 2 ** 16 # 64 KiB async def open_connection(host=None, port=None, *, limit=_DEFAULT_LIMIT, **kwds): """A wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) """ loop = events.get_running_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = await loop.create_connection( lambda: protocol, host, port, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer async def start_server(client_connected_cb, host=None, port=None, *, limit=_DEFAULT_LIMIT, **kwds): """Start a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword argument is limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. """ loop = events.get_running_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return await loop.create_server(factory, host, port, **kwds) if hasattr(socket, 'AF_UNIX'): # UNIX Domain Sockets are supported on this platform async def open_unix_connection(path=None, *, limit=_DEFAULT_LIMIT, **kwds): """Similar to `open_connection` but works with UNIX Domain Sockets.""" loop = events.get_running_loop() reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, loop=loop) transport, _ = await loop.create_unix_connection( lambda: protocol, path, **kwds) writer = StreamWriter(transport, protocol, reader, loop) return reader, writer async def start_unix_server(client_connected_cb, path=None, *, limit=_DEFAULT_LIMIT, **kwds): """Similar to `start_server` but works with UNIX Domain Sockets.""" loop = events.get_running_loop() def factory(): reader = StreamReader(limit=limit, loop=loop) protocol = StreamReaderProtocol(reader, client_connected_cb, loop=loop) return protocol return await loop.create_unix_server(factory, path, **kwds) class FlowControlMixin(protocols.Protocol): """Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. """ def __init__(self, loop=None): if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._paused = False self._drain_waiters = collections.deque() self._connection_lost = False def pause_writing(self): assert not self._paused self._paused = True if self._loop.get_debug(): logger.debug("%r pauses writing", self) def resume_writing(self): assert self._paused self._paused = False if self._loop.get_debug(): logger.debug("%r resumes writing", self) for waiter in self._drain_waiters: if not waiter.done(): waiter.set_result(None) def connection_lost(self, exc): self._connection_lost = True # Wake up the writer(s) if currently paused. if not self._paused: return for waiter in self._drain_waiters: if not waiter.done(): if exc is None: waiter.set_result(None) else: waiter.set_exception(exc) async def _drain_helper(self): if self._connection_lost: raise ConnectionResetError('Connection lost') if not self._paused: return waiter = self._loop.create_future() self._drain_waiters.append(waiter) try: await waiter finally: self._drain_waiters.remove(waiter) def _get_close_waiter(self, stream): raise NotImplementedError class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): """Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) """ _source_traceback = None def __init__(self, stream_reader, client_connected_cb=None, loop=None): super().__init__(loop=loop) if stream_reader is not None: self._stream_reader_wr = weakref.ref(stream_reader) self._source_traceback = stream_reader._source_traceback else: self._stream_reader_wr = None if client_connected_cb is not None: # This is a stream created by the `create_server()` function. # Keep a strong reference to the reader until a connection # is established. self._strong_reader = stream_reader self._reject_connection = False self._stream_writer = None self._task = None self._transport = None self._client_connected_cb = client_connected_cb self._over_ssl = False self._closed = self._loop.create_future() @property def _stream_reader(self): if self._stream_reader_wr is None: return None return self._stream_reader_wr() def _replace_writer(self, writer): loop = self._loop transport = writer.transport self._stream_writer = writer self._transport = transport self._over_ssl = transport.get_extra_info('sslcontext') is not None def connection_made(self, transport): if self._reject_connection: context = { 'message': ('An open stream was garbage collected prior to ' 'establishing network connection; ' 'call "stream.close()" explicitly.') } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) transport.abort() return self._transport = transport reader = self._stream_reader if reader is not None: reader.set_transport(transport) self._over_ssl = transport.get_extra_info('sslcontext') is not None if self._client_connected_cb is not None: self._stream_writer = StreamWriter(transport, self, reader, self._loop) res = self._client_connected_cb(reader, self._stream_writer) if coroutines.iscoroutine(res): def callback(task): if task.cancelled(): transport.close() return exc = task.exception() if exc is not None: self._loop.call_exception_handler({ 'message': 'Unhandled exception in client_connected_cb', 'exception': exc, 'transport': transport, }) transport.close() self._task = self._loop.create_task(res) self._task.add_done_callback(callback) self._strong_reader = None def connection_lost(self, exc): reader = self._stream_reader if reader is not None: if exc is None: reader.feed_eof() else: reader.set_exception(exc) if not self._closed.done(): if exc is None: self._closed.set_result(None) else: self._closed.set_exception(exc) super().connection_lost(exc) self._stream_reader_wr = None self._stream_writer = None self._task = None self._transport = None def data_received(self, data): reader = self._stream_reader if reader is not None: reader.feed_data(data) def eof_received(self): reader = self._stream_reader if reader is not None: reader.feed_eof() if self._over_ssl: # Prevent a warning in SSLProtocol.eof_received: # "returning true from eof_received() # has no effect when using ssl" return False return True def _get_close_waiter(self, stream): return self._closed def __del__(self): # Prevent reports about unhandled exceptions. # Better than self._closed._log_traceback = False hack try: closed = self._closed except AttributeError: pass # failed constructor else: if closed.done() and not closed.cancelled(): closed.exception() class StreamWriter: """Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. """ def __init__(self, transport, protocol, reader, loop): self._transport = transport self._protocol = protocol # drain() expects that the reader has an exception() method assert reader is None or isinstance(reader, StreamReader) self._reader = reader self._loop = loop self._complete_fut = self._loop.create_future() self._complete_fut.set_result(None) def __repr__(self): info = [self.__class__.__name__, f'transport={self._transport!r}'] if self._reader is not None: info.append(f'reader={self._reader!r}') return '<{}>'.format(' '.join(info)) @property def transport(self): return self._transport def write(self, data): self._transport.write(data) def writelines(self, data): self._transport.writelines(data) def write_eof(self): return self._transport.write_eof() def can_write_eof(self): return self._transport.can_write_eof() def close(self): return self._transport.close() def is_closing(self): return self._transport.is_closing() async def wait_closed(self): await self._protocol._get_close_waiter(self) def get_extra_info(self, name, default=None): return self._transport.get_extra_info(name, default) async def drain(self): """Flush the write buffer. The intended use is to write w.write(data) await w.drain() """ if self._reader is not None: exc = self._reader.exception() if exc is not None: raise exc if self._transport.is_closing(): # Wait for protocol.connection_lost() call # Raise connection closing error if any, # ConnectionResetError otherwise # Yield to the event loop so connection_lost() may be # called. Without this, _drain_helper() would return # immediately, and code that calls # write(...); await drain() # in a loop would never call connection_lost(), so it # would not see an error when the socket is closed. await sleep(0) await self._protocol._drain_helper() async def start_tls(self, sslcontext, *, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade an existing stream-based connection to TLS.""" server_side = self._protocol._client_connected_cb is not None protocol = self._protocol await self.drain() new_transport = await self._loop.start_tls( # type: ignore self._transport, protocol, sslcontext, server_side=server_side, server_hostname=server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) self._transport = new_transport protocol._replace_writer(self) def __del__(self): if not self._transport.is_closing(): if self._loop.is_closed(): warnings.warn("loop is closed", ResourceWarning) else: self.close() warnings.warn(f"unclosed {self!r}", ResourceWarning) class StreamReader: _source_traceback = None def __init__(self, limit=_DEFAULT_LIMIT, loop=None): # The line length limit is a security feature; # it also doubles as half the buffer limit. if limit <= 0: raise ValueError('Limit cannot be <= 0') self._limit = limit if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._buffer = bytearray() self._eof = False # Whether we're done. self._waiter = None # A future used by _wait_for_data() self._exception = None self._transport = None self._paused = False if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) def __repr__(self): info = ['StreamReader'] if self._buffer: info.append(f'{len(self._buffer)} bytes') if self._eof: info.append('eof') if self._limit != _DEFAULT_LIMIT: info.append(f'limit={self._limit}') if self._waiter: info.append(f'waiter={self._waiter!r}') if self._exception: info.append(f'exception={self._exception!r}') if self._transport: info.append(f'transport={self._transport!r}') if self._paused: info.append('paused') return '<{}>'.format(' '.join(info)) def exception(self): return self._exception def set_exception(self, exc): self._exception = exc waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_exception(exc) def _wakeup_waiter(self): """Wakeup read*() functions waiting for data or EOF.""" waiter = self._waiter if waiter is not None: self._waiter = None if not waiter.cancelled(): waiter.set_result(None) def set_transport(self, transport): assert self._transport is None, 'Transport already set' self._transport = transport def _maybe_resume_transport(self): if self._paused and len(self._buffer) <= self._limit: self._paused = False self._transport.resume_reading() def feed_eof(self): self._eof = True self._wakeup_waiter() def at_eof(self): """Return True if the buffer is empty and 'feed_eof' was called.""" return self._eof and not self._buffer def feed_data(self, data): assert not self._eof, 'feed_data after feed_eof' if not data: return self._buffer.extend(data) self._wakeup_waiter() if (self._transport is not None and not self._paused and len(self._buffer) > 2 * self._limit): try: self._transport.pause_reading() except NotImplementedError: # The transport can't be paused. # We'll just have to buffer all data. # Forget the transport so we don't keep trying. self._transport = None else: self._paused = True async def _wait_for_data(self, func_name): """Wait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. """ # StreamReader uses a future to link the protocol feed_data() method # to a read coroutine. Running two read coroutines at the same time # would have an unexpected behaviour. It would not possible to know # which coroutine would get the next data. if self._waiter is not None: raise RuntimeError( f'{func_name}() called while another coroutine is ' f'already waiting for incoming data') assert not self._eof, '_wait_for_data after EOF' # Waiting for data while paused will make deadlock, so prevent it. # This is essential for readexactly(n) for case when n > self._limit. if self._paused: self._paused = False self._transport.resume_reading() self._waiter = self._loop.create_future() try: await self._waiter finally: self._waiter = None async def readline(self): """Read chunk of data from the stream until newline (b'\n') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed. """ sep = b'\n' seplen = len(sep) try: line = await self.readuntil(sep) except exceptions.IncompleteReadError as e: return e.partial except exceptions.LimitOverrunError as e: if self._buffer.startswith(sep, e.consumed): del self._buffer[:e.consumed + seplen] else: self._buffer.clear() self._maybe_resume_transport() raise ValueError(e.args[0]) return line async def readuntil(self, separator=b'\n'): """Read data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. """ seplen = len(separator) if seplen == 0: raise ValueError('Separator should be at least one-byte string') if self._exception is not None: raise self._exception # Consume whole buffer except last bytes, which length is # one less than seplen. Let's check corner cases with # separator='SEPARATOR': # * we have received almost complete separator (without last # byte). i.e buffer='some textSEPARATO'. In this case we # can safely consume len(separator) - 1 bytes. # * last byte of buffer is first byte of separator, i.e. # buffer='abcdefghijklmnopqrS'. We may safely consume # everything except that last byte, but this require to # analyze bytes of buffer that match partial separator. # This is slow and/or require FSM. For this case our # implementation is not optimal, since require rescanning # of data that is known to not belong to separator. In # real world, separator will not be so long to notice # performance problems. Even when reading MIME-encoded # messages :) # `offset` is the number of bytes from the beginning of the buffer # where there is no occurrence of `separator`. offset = 0 # Loop until we find `separator` in the buffer, exceed the buffer size, # or an EOF has happened. while True: buflen = len(self._buffer) # Check if we now have enough data in the buffer for `separator` to # fit. if buflen - offset >= seplen: isep = self._buffer.find(separator, offset) if isep != -1: # `separator` is in the buffer. `isep` will be used later # to retrieve the data. break # see upper comment for explanation. offset = buflen + 1 - seplen if offset > self._limit: raise exceptions.LimitOverrunError( 'Separator is not found, and chunk exceed the limit', offset) # Complete message (with full separator) may be present in buffer # even when EOF flag is set. This may happen when the last chunk # adds data which makes separator be found. That's why we check for # EOF *ater* inspecting the buffer. if self._eof: chunk = bytes(self._buffer) self._buffer.clear() raise exceptions.IncompleteReadError(chunk, None) # _wait_for_data() will resume reading if stream was paused. await self._wait_for_data('readuntil') if isep > self._limit: raise exceptions.LimitOverrunError( 'Separator is found, but chunk is longer than limit', isep) chunk = self._buffer[:isep + seplen] del self._buffer[:isep + seplen] self._maybe_resume_transport() return bytes(chunk) async def read(self, n=-1): """Read up to `n` bytes from the stream. If `n` is not provided or set to -1, read until EOF, then return all read bytes. If EOF was received and the internal buffer is empty, return an empty bytes object. If `n` is 0, return an empty bytes object immediately. If `n` is positive, return at most `n` available bytes as soon as at least 1 byte is available in the internal buffer. If EOF is received before any byte is read, return an empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if self._exception is not None: raise self._exception if n == 0: return b'' if n < 0: # This used to just loop creating a new waiter hoping to # collect everything in self._buffer, but that would # deadlock if the subprocess sends more than self.limit # bytes. So just call self.read(self._limit) until EOF. blocks = [] while True: block = await self.read(self._limit) if not block: break blocks.append(block) return b''.join(blocks) if not self._buffer and not self._eof: await self._wait_for_data('read') # This will work right even if buffer is less than n bytes data = bytes(memoryview(self._buffer)[:n]) del self._buffer[:n] self._maybe_resume_transport() return data async def readexactly(self, n): """Read exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. """ if n < 0: raise ValueError('readexactly size can not be less than zero') if self._exception is not None: raise self._exception if n == 0: return b'' while len(self._buffer) < n: if self._eof: incomplete = bytes(self._buffer) self._buffer.clear() raise exceptions.IncompleteReadError(incomplete, n) await self._wait_for_data('readexactly') if len(self._buffer) == n: data = bytes(self._buffer) self._buffer.clear() else: data = bytes(memoryview(self._buffer)[:n]) del self._buffer[:n] self._maybe_resume_transport() return data def __aiter__(self): return self async def __anext__(self): val = await self.readline() if val == b'': raise StopAsyncIteration return val windows_utils.py000064400000011704152343231170010034 0ustar00"""Various Windows specific bits and pieces.""" import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('win32 only') import _winapi import itertools import msvcrt import os import subprocess import tempfile import warnings __all__ = 'pipe', 'Popen', 'PIPE', 'PipeHandle' # Constants/globals BUFSIZE = 8192 PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT _mmap_counter = itertools.count() # Replacement for os.pipe() using handles instead of fds def pipe(*, duplex=False, overlapped=(True, True), bufsize=BUFSIZE): """Like os.pipe() but with overlapped support and using handles not fds.""" address = tempfile.mktemp( prefix=r'\\.\pipe\python-pipe-{:d}-{:d}-'.format( os.getpid(), next(_mmap_counter))) if duplex: openmode = _winapi.PIPE_ACCESS_DUPLEX access = _winapi.GENERIC_READ | _winapi.GENERIC_WRITE obsize, ibsize = bufsize, bufsize else: openmode = _winapi.PIPE_ACCESS_INBOUND access = _winapi.GENERIC_WRITE obsize, ibsize = 0, bufsize openmode |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE if overlapped[0]: openmode |= _winapi.FILE_FLAG_OVERLAPPED if overlapped[1]: flags_and_attribs = _winapi.FILE_FLAG_OVERLAPPED else: flags_and_attribs = 0 h1 = h2 = None try: h1 = _winapi.CreateNamedPipe( address, openmode, _winapi.PIPE_WAIT, 1, obsize, ibsize, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) h2 = _winapi.CreateFile( address, access, 0, _winapi.NULL, _winapi.OPEN_EXISTING, flags_and_attribs, _winapi.NULL) ov = _winapi.ConnectNamedPipe(h1, overlapped=True) ov.GetOverlappedResult(True) return h1, h2 except: if h1 is not None: _winapi.CloseHandle(h1) if h2 is not None: _winapi.CloseHandle(h2) raise # Wrapper for a pipe handle class PipeHandle: """Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. """ def __init__(self, handle): self._handle = handle def __repr__(self): if self._handle is not None: handle = f'handle={self._handle!r}' else: handle = 'closed' return f'<{self.__class__.__name__} {handle}>' @property def handle(self): return self._handle def fileno(self): if self._handle is None: raise ValueError("I/O operation on closed pipe") return self._handle def close(self, *, CloseHandle=_winapi.CloseHandle): if self._handle is not None: CloseHandle(self._handle) self._handle = None def __del__(self, _warn=warnings.warn): if self._handle is not None: _warn(f"unclosed {self!r}", ResourceWarning, source=self) self.close() def __enter__(self): return self def __exit__(self, t, v, tb): self.close() # Replacement for subprocess.Popen using overlapped pipe handles class Popen(subprocess.Popen): """Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. """ def __init__(self, args, stdin=None, stdout=None, stderr=None, **kwds): assert not kwds.get('universal_newlines') assert kwds.get('bufsize', 0) == 0 stdin_rfd = stdout_wfd = stderr_wfd = None stdin_wh = stdout_rh = stderr_rh = None if stdin == PIPE: stdin_rh, stdin_wh = pipe(overlapped=(False, True), duplex=True) stdin_rfd = msvcrt.open_osfhandle(stdin_rh, os.O_RDONLY) else: stdin_rfd = stdin if stdout == PIPE: stdout_rh, stdout_wh = pipe(overlapped=(True, False)) stdout_wfd = msvcrt.open_osfhandle(stdout_wh, 0) else: stdout_wfd = stdout if stderr == PIPE: stderr_rh, stderr_wh = pipe(overlapped=(True, False)) stderr_wfd = msvcrt.open_osfhandle(stderr_wh, 0) elif stderr == STDOUT: stderr_wfd = stdout_wfd else: stderr_wfd = stderr try: super().__init__(args, stdin=stdin_rfd, stdout=stdout_wfd, stderr=stderr_wfd, **kwds) except: for h in (stdin_wh, stdout_rh, stderr_rh): if h is not None: _winapi.CloseHandle(h) raise else: if stdin_wh is not None: self.stdin = PipeHandle(stdin_wh) if stdout_rh is not None: self.stdout = PipeHandle(stdout_rh) if stderr_rh is not None: self.stderr = PipeHandle(stderr_rh) finally: if stdin == PIPE: os.close(stdin_rfd) if stdout == PIPE: os.close(stdout_wfd) if stderr == PIPE: os.close(stderr_wfd) subprocess.py000064400000017071152343231170007315 0ustar00__all__ = 'create_subprocess_exec', 'create_subprocess_shell' import subprocess from . import events from . import protocols from . import streams from . import tasks from .log import logger PIPE = subprocess.PIPE STDOUT = subprocess.STDOUT DEVNULL = subprocess.DEVNULL class SubprocessStreamProtocol(streams.FlowControlMixin, protocols.SubprocessProtocol): """Like StreamReaderProtocol, but for a subprocess.""" def __init__(self, limit, loop): super().__init__(loop=loop) self._limit = limit self.stdin = self.stdout = self.stderr = None self._transport = None self._process_exited = False self._pipe_fds = [] self._stdin_closed = self._loop.create_future() def __repr__(self): info = [self.__class__.__name__] if self.stdin is not None: info.append(f'stdin={self.stdin!r}') if self.stdout is not None: info.append(f'stdout={self.stdout!r}') if self.stderr is not None: info.append(f'stderr={self.stderr!r}') return '<{}>'.format(' '.join(info)) def connection_made(self, transport): self._transport = transport stdout_transport = transport.get_pipe_transport(1) if stdout_transport is not None: self.stdout = streams.StreamReader(limit=self._limit, loop=self._loop) self.stdout.set_transport(stdout_transport) self._pipe_fds.append(1) stderr_transport = transport.get_pipe_transport(2) if stderr_transport is not None: self.stderr = streams.StreamReader(limit=self._limit, loop=self._loop) self.stderr.set_transport(stderr_transport) self._pipe_fds.append(2) stdin_transport = transport.get_pipe_transport(0) if stdin_transport is not None: self.stdin = streams.StreamWriter(stdin_transport, protocol=self, reader=None, loop=self._loop) def pipe_data_received(self, fd, data): if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader is not None: reader.feed_data(data) def pipe_connection_lost(self, fd, exc): if fd == 0: pipe = self.stdin if pipe is not None: pipe.close() self.connection_lost(exc) if exc is None: self._stdin_closed.set_result(None) else: self._stdin_closed.set_exception(exc) # Since calling `wait_closed()` is not mandatory, # we shouldn't log the traceback if this is not awaited. self._stdin_closed._log_traceback = False return if fd == 1: reader = self.stdout elif fd == 2: reader = self.stderr else: reader = None if reader is not None: if exc is None: reader.feed_eof() else: reader.set_exception(exc) if fd in self._pipe_fds: self._pipe_fds.remove(fd) self._maybe_close_transport() def process_exited(self): self._process_exited = True self._maybe_close_transport() def _maybe_close_transport(self): if len(self._pipe_fds) == 0 and self._process_exited: self._transport.close() self._transport = None def _get_close_waiter(self, stream): if stream is self.stdin: return self._stdin_closed class Process: def __init__(self, transport, protocol, loop): self._transport = transport self._protocol = protocol self._loop = loop self.stdin = protocol.stdin self.stdout = protocol.stdout self.stderr = protocol.stderr self.pid = transport.get_pid() def __repr__(self): return f'<{self.__class__.__name__} {self.pid}>' @property def returncode(self): return self._transport.get_returncode() async def wait(self): """Wait until the process exit and return the process return code.""" return await self._transport._wait() def send_signal(self, signal): self._transport.send_signal(signal) def terminate(self): self._transport.terminate() def kill(self): self._transport.kill() async def _feed_stdin(self, input): debug = self._loop.get_debug() try: if input is not None: self.stdin.write(input) if debug: logger.debug( '%r communicate: feed stdin (%s bytes)', self, len(input)) await self.stdin.drain() except (BrokenPipeError, ConnectionResetError) as exc: # communicate() ignores BrokenPipeError and ConnectionResetError. # write() and drain() can raise these exceptions. if debug: logger.debug('%r communicate: stdin got %r', self, exc) if debug: logger.debug('%r communicate: close stdin', self) self.stdin.close() async def _noop(self): return None async def _read_stream(self, fd): transport = self._transport.get_pipe_transport(fd) if fd == 2: stream = self.stderr else: assert fd == 1 stream = self.stdout if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: read %s', self, name) output = await stream.read() if self._loop.get_debug(): name = 'stdout' if fd == 1 else 'stderr' logger.debug('%r communicate: close %s', self, name) transport.close() return output async def communicate(self, input=None): if self.stdin is not None: stdin = self._feed_stdin(input) else: stdin = self._noop() if self.stdout is not None: stdout = self._read_stream(1) else: stdout = self._noop() if self.stderr is not None: stderr = self._read_stream(2) else: stderr = self._noop() stdin, stdout, stderr = await tasks.gather(stdin, stdout, stderr) await self.wait() return (stdout, stderr) async def create_subprocess_shell(cmd, stdin=None, stdout=None, stderr=None, limit=streams._DEFAULT_LIMIT, **kwds): loop = events.get_running_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = await loop.subprocess_shell( protocol_factory, cmd, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) async def create_subprocess_exec(program, *args, stdin=None, stdout=None, stderr=None, limit=streams._DEFAULT_LIMIT, **kwds): loop = events.get_running_loop() protocol_factory = lambda: SubprocessStreamProtocol(limit=limit, loop=loop) transport, protocol = await loop.subprocess_exec( protocol_factory, program, *args, stdin=stdin, stdout=stdout, stderr=stderr, **kwds) return Process(transport, protocol, loop) transports.py000064400000024742152343231170007347 0ustar00"""Abstract Transport class.""" __all__ = ( 'BaseTransport', 'ReadTransport', 'WriteTransport', 'Transport', 'DatagramTransport', 'SubprocessTransport', ) class BaseTransport: """Base class for transports.""" __slots__ = ('_extra',) def __init__(self, extra=None): if extra is None: extra = {} self._extra = extra def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._extra.get(name, default) def is_closing(self): """Return True if the transport is closing or closed.""" raise NotImplementedError def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError def set_protocol(self, protocol): """Set a new protocol.""" raise NotImplementedError def get_protocol(self): """Return the current protocol.""" raise NotImplementedError class ReadTransport(BaseTransport): """Interface for read-only transports.""" __slots__ = () def is_reading(self): """Return True if the transport is receiving.""" raise NotImplementedError def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ raise NotImplementedError def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ raise NotImplementedError class WriteTransport(BaseTransport): """Interface for write-only transports.""" __slots__ = () def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ raise NotImplementedError def get_write_buffer_size(self): """Return the current size of the write buffer.""" raise NotImplementedError def get_write_buffer_limits(self): """Get the high and low watermarks for write flow control. Return a tuple (low, high) where low and high are positive number of bytes.""" raise NotImplementedError def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ raise NotImplementedError def writelines(self, list_of_data): """Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. """ data = b''.join(list_of_data) self.write(data) def write_eof(self): """Close the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. """ raise NotImplementedError def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class Transport(ReadTransport, WriteTransport): """Interface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. """ __slots__ = () class DatagramTransport(BaseTransport): """Interface for datagram (UDP) transports.""" __slots__ = () def sendto(self, data, addr=None): """Send data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. """ raise NotImplementedError def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ raise NotImplementedError class SubprocessTransport(BaseTransport): __slots__ = () def get_pid(self): """Get subprocess id.""" raise NotImplementedError def get_returncode(self): """Get subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode """ raise NotImplementedError def get_pipe_transport(self, fd): """Get transport for pipe with number fd.""" raise NotImplementedError def send_signal(self, signal): """Send signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal """ raise NotImplementedError def terminate(self): """Stop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate """ raise NotImplementedError def kill(self): """Kill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill """ raise NotImplementedError class _FlowControlMixin(Transport): """All the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. """ __slots__ = ('_loop', '_protocol_paused', '_high_water', '_low_water') def __init__(self, extra=None, loop=None): super().__init__(extra) assert loop is not None self._loop = loop self._protocol_paused = False self._set_write_buffer_limits() def _maybe_pause_protocol(self): size = self.get_write_buffer_size() if size <= self._high_water: return if not self._protocol_paused: self._protocol_paused = True try: self._protocol.pause_writing() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def _maybe_resume_protocol(self): if (self._protocol_paused and self.get_write_buffer_size() <= self._low_water): self._protocol_paused = False try: self._protocol.resume_writing() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, 'transport': self, 'protocol': self._protocol, }) def get_write_buffer_limits(self): return (self._low_water, self._high_water) def _set_write_buffer_limits(self, high=None, low=None): if high is None: if low is None: high = 64 * 1024 else: high = 4 * low if low is None: low = high // 4 if not high >= low >= 0: raise ValueError( f'high ({high!r}) must be >= low ({low!r}) must be >= 0') self._high_water = high self._low_water = low def set_write_buffer_limits(self, high=None, low=None): self._set_write_buffer_limits(high=high, low=low) self._maybe_pause_protocol() def get_write_buffer_size(self): raise NotImplementedError windows_events.py000064400000077513152343231170010212 0ustar00"""Selector and proactor event loops for Windows.""" import sys if sys.platform != 'win32': # pragma: no cover raise ImportError('win32 only') import _overlapped import _winapi import errno from functools import partial import math import msvcrt import socket import struct import time import weakref from . import events from . import base_subprocess from . import futures from . import exceptions from . import proactor_events from . import selector_events from . import tasks from . import windows_utils from .log import logger __all__ = ( 'SelectorEventLoop', 'ProactorEventLoop', 'IocpProactor', 'DefaultEventLoopPolicy', 'WindowsSelectorEventLoopPolicy', 'WindowsProactorEventLoopPolicy', ) NULL = _winapi.NULL INFINITE = _winapi.INFINITE ERROR_CONNECTION_REFUSED = 1225 ERROR_CONNECTION_ABORTED = 1236 # Initial delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_INIT_DELAY = 0.001 # Maximum delay in seconds for connect_pipe() before retrying to connect CONNECT_PIPE_MAX_DELAY = 0.100 class _OverlappedFuture(futures.Future): """Subclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. """ def __init__(self, ov, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] self._ov = ov def _repr_info(self): info = super()._repr_info() if self._ov is not None: state = 'pending' if self._ov.pending else 'completed' info.insert(1, f'overlapped=<{state}, {self._ov.address:#x}>') return info def _cancel_overlapped(self): if self._ov is None: return try: self._ov.cancel() except OSError as exc: context = { 'message': 'Cancelling an overlapped future failed', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) self._ov = None def cancel(self, msg=None): self._cancel_overlapped() return super().cancel(msg=msg) def set_exception(self, exception): super().set_exception(exception) self._cancel_overlapped() def set_result(self, result): super().set_result(result) self._ov = None class _BaseWaitHandleFuture(futures.Future): """Subclass of Future which represents a wait handle.""" def __init__(self, ov, handle, wait_handle, *, loop=None): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] # Keep a reference to the Overlapped object to keep it alive until the # wait is unregistered self._ov = ov self._handle = handle self._wait_handle = wait_handle # Should we call UnregisterWaitEx() if the wait completes # or is cancelled? self._registered = True def _poll(self): # non-blocking wait: use a timeout of 0 millisecond return (_winapi.WaitForSingleObject(self._handle, 0) == _winapi.WAIT_OBJECT_0) def _repr_info(self): info = super()._repr_info() info.append(f'handle={self._handle:#x}') if self._handle is not None: state = 'signaled' if self._poll() else 'waiting' info.append(state) if self._wait_handle is not None: info.append(f'wait_handle={self._wait_handle:#x}') return info def _unregister_wait_cb(self, fut): # The wait was unregistered: it's not safe to destroy the Overlapped # object self._ov = None def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWait(wait_handle) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING means that the unregister is pending self._unregister_wait_cb(None) def cancel(self, msg=None): self._unregister_wait() return super().cancel(msg=msg) def set_exception(self, exception): self._unregister_wait() super().set_exception(exception) def set_result(self, result): self._unregister_wait() super().set_result(result) class _WaitCancelFuture(_BaseWaitHandleFuture): """Subclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. """ def __init__(self, ov, event, wait_handle, *, loop=None): super().__init__(ov, event, wait_handle, loop=loop) self._done_callback = None def cancel(self): raise RuntimeError("_WaitCancelFuture must not be cancelled") def set_result(self, result): super().set_result(result) if self._done_callback is not None: self._done_callback(self) def set_exception(self, exception): super().set_exception(exception) if self._done_callback is not None: self._done_callback(self) class _WaitHandleFuture(_BaseWaitHandleFuture): def __init__(self, ov, handle, wait_handle, proactor, *, loop=None): super().__init__(ov, handle, wait_handle, loop=loop) self._proactor = proactor self._unregister_proactor = True self._event = _overlapped.CreateEvent(None, True, False, None) self._event_fut = None def _unregister_wait_cb(self, fut): if self._event is not None: _winapi.CloseHandle(self._event) self._event = None self._event_fut = None # If the wait was cancelled, the wait may never be signalled, so # it's required to unregister it. Otherwise, IocpProactor.close() will # wait forever for an event which will never come. # # If the IocpProactor already received the event, it's safe to call # _unregister() because we kept a reference to the Overlapped object # which is used as a unique key. self._proactor._unregister(self._ov) self._proactor = None super()._unregister_wait_cb(fut) def _unregister_wait(self): if not self._registered: return self._registered = False wait_handle = self._wait_handle self._wait_handle = None try: _overlapped.UnregisterWaitEx(wait_handle, self._event) except OSError as exc: if exc.winerror != _overlapped.ERROR_IO_PENDING: context = { 'message': 'Failed to unregister the wait handle', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) return # ERROR_IO_PENDING is not an error, the wait was unregistered self._event_fut = self._proactor._wait_cancel(self._event, self._unregister_wait_cb) class PipeServer(object): """Class representing a pipe server. This is much like a bound, listening socket. """ def __init__(self, address): self._address = address self._free_instances = weakref.WeakSet() # initialize the pipe attribute before calling _server_pipe_handle() # because this function can raise an exception and the destructor calls # the close() method self._pipe = None self._accept_pipe_future = None self._pipe = self._server_pipe_handle(True) def _get_unconnected_pipe(self): # Create new instance and return previous one. This ensures # that (until the server is closed) there is always at least # one pipe handle for address. Therefore if a client attempt # to connect it will not fail with FileNotFoundError. tmp, self._pipe = self._pipe, self._server_pipe_handle(False) return tmp def _server_pipe_handle(self, first): # Return a wrapper for a new pipe handle. if self.closed(): return None flags = _winapi.PIPE_ACCESS_DUPLEX | _winapi.FILE_FLAG_OVERLAPPED if first: flags |= _winapi.FILE_FLAG_FIRST_PIPE_INSTANCE h = _winapi.CreateNamedPipe( self._address, flags, _winapi.PIPE_TYPE_MESSAGE | _winapi.PIPE_READMODE_MESSAGE | _winapi.PIPE_WAIT, _winapi.PIPE_UNLIMITED_INSTANCES, windows_utils.BUFSIZE, windows_utils.BUFSIZE, _winapi.NMPWAIT_WAIT_FOREVER, _winapi.NULL) pipe = windows_utils.PipeHandle(h) self._free_instances.add(pipe) return pipe def closed(self): return (self._address is None) def close(self): if self._accept_pipe_future is not None: self._accept_pipe_future.cancel() self._accept_pipe_future = None # Close all instances which have not been connected to by a client. if self._address is not None: for pipe in self._free_instances: pipe.close() self._pipe = None self._address = None self._free_instances.clear() __del__ = close class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Windows version of selector event loop.""" class ProactorEventLoop(proactor_events.BaseProactorEventLoop): """Windows version of proactor event loop using IOCP.""" def __init__(self, proactor=None): if proactor is None: proactor = IocpProactor() super().__init__(proactor) def run_forever(self): try: assert self._self_reading_future is None self.call_soon(self._loop_self_reading) super().run_forever() finally: if self._self_reading_future is not None: ov = self._self_reading_future._ov self._self_reading_future.cancel() # self_reading_future always uses IOCP, so even though it's # been cancelled, we need to make sure that the IOCP message # is received so that the kernel is not holding on to the # memory, possibly causing memory corruption later. Only # unregister it if IO is complete in all respects. Otherwise # we need another _poll() later to complete the IO. if ov is not None and not ov.pending: self._proactor._unregister(ov) self._self_reading_future = None async def create_pipe_connection(self, protocol_factory, address): f = self._proactor.connect_pipe(address) pipe = await f protocol = protocol_factory() trans = self._make_duplex_pipe_transport(pipe, protocol, extra={'addr': address}) return trans, protocol async def start_serving_pipe(self, protocol_factory, address): server = PipeServer(address) def loop_accept_pipe(f=None): pipe = None try: if f: pipe = f.result() server._free_instances.discard(pipe) if server.closed(): # A client connected before the server was closed: # drop the client (close the pipe) and exit pipe.close() return protocol = protocol_factory() self._make_duplex_pipe_transport( pipe, protocol, extra={'addr': address}) pipe = server._get_unconnected_pipe() if pipe is None: return f = self._proactor.accept_pipe(pipe) except BrokenPipeError: if pipe and pipe.fileno() != -1: pipe.close() self.call_soon(loop_accept_pipe) except OSError as exc: if pipe and pipe.fileno() != -1: self.call_exception_handler({ 'message': 'Pipe accept failed', 'exception': exc, 'pipe': pipe, }) pipe.close() elif self._debug: logger.warning("Accept pipe failed on pipe %r", pipe, exc_info=True) self.call_soon(loop_accept_pipe) except exceptions.CancelledError: if pipe: pipe.close() else: server._accept_pipe_future = f f.add_done_callback(loop_accept_pipe) self.call_soon(loop_accept_pipe) return [server] async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): waiter = self.create_future() transp = _WindowsSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) try: await waiter except (SystemExit, KeyboardInterrupt): raise except BaseException: transp.close() await transp._wait() raise return transp class IocpProactor: """Proactor implementation using IOCP.""" def __init__(self, concurrency=INFINITE): self._loop = None self._results = [] self._iocp = _overlapped.CreateIoCompletionPort( _overlapped.INVALID_HANDLE_VALUE, NULL, 0, concurrency) self._cache = {} self._registered = weakref.WeakSet() self._unregistered = [] self._stopped_serving = weakref.WeakSet() def _check_closed(self): if self._iocp is None: raise RuntimeError('IocpProactor is closed') def __repr__(self): info = ['overlapped#=%s' % len(self._cache), 'result#=%s' % len(self._results)] if self._iocp is None: info.append('closed') return '<%s %s>' % (self.__class__.__name__, " ".join(info)) def set_loop(self, loop): self._loop = loop def select(self, timeout=None): if not self._results: self._poll(timeout) tmp = self._results self._results = [] try: return tmp finally: # Needed to break cycles when an exception occurs. tmp = None def _result(self, value): fut = self._loop.create_future() fut.set_result(value) return fut @staticmethod def finish_socket_func(trans, key, ov): try: return ov.getresult() except OSError as exc: if exc.winerror in (_overlapped.ERROR_NETNAME_DELETED, _overlapped.ERROR_OPERATION_ABORTED): raise ConnectionResetError(*exc.args) else: raise @classmethod def _finish_recvfrom(cls, trans, key, ov, *, empty_result): try: return cls.finish_socket_func(trans, key, ov) except OSError as exc: # WSARecvFrom will report ERROR_PORT_UNREACHABLE when the same # socket is used to send to an address that is not listening. if exc.winerror == _overlapped.ERROR_PORT_UNREACHABLE: return empty_result, None else: raise def recv(self, conn, nbytes, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: if isinstance(conn, socket.socket): ov.WSARecv(conn.fileno(), nbytes, flags) else: ov.ReadFile(conn.fileno(), nbytes) except BrokenPipeError: return self._result(b'') return self._register(ov, conn, self.finish_socket_func) def recv_into(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: if isinstance(conn, socket.socket): ov.WSARecvInto(conn.fileno(), buf, flags) else: ov.ReadFileInto(conn.fileno(), buf) except BrokenPipeError: return self._result(0) return self._register(ov, conn, self.finish_socket_func) def recvfrom(self, conn, nbytes, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: ov.WSARecvFrom(conn.fileno(), nbytes, flags) except BrokenPipeError: return self._result((b'', None)) return self._register(ov, conn, partial(self._finish_recvfrom, empty_result=b'')) def recvfrom_into(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) try: ov.WSARecvFromInto(conn.fileno(), buf, flags) except BrokenPipeError: return self._result((0, None)) return self._register(ov, conn, partial(self._finish_recvfrom, empty_result=0)) def sendto(self, conn, buf, flags=0, addr=None): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) ov.WSASendTo(conn.fileno(), buf, flags, addr) return self._register(ov, conn, self.finish_socket_func) def send(self, conn, buf, flags=0): self._register_with_iocp(conn) ov = _overlapped.Overlapped(NULL) if isinstance(conn, socket.socket): ov.WSASend(conn.fileno(), buf, flags) else: ov.WriteFile(conn.fileno(), buf) return self._register(ov, conn, self.finish_socket_func) def accept(self, listener): self._register_with_iocp(listener) conn = self._get_accept_socket(listener.family) ov = _overlapped.Overlapped(NULL) ov.AcceptEx(listener.fileno(), conn.fileno()) def finish_accept(trans, key, ov): ov.getresult() # Use SO_UPDATE_ACCEPT_CONTEXT so getsockname() etc work. buf = struct.pack('@P', listener.fileno()) conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_ACCEPT_CONTEXT, buf) conn.settimeout(listener.gettimeout()) return conn, conn.getpeername() async def accept_coro(future, conn): # Coroutine closing the accept socket if the future is cancelled try: await future except exceptions.CancelledError: conn.close() raise future = self._register(ov, listener, finish_accept) coro = accept_coro(future, conn) tasks.ensure_future(coro, loop=self._loop) return future def connect(self, conn, address): if conn.type == socket.SOCK_DGRAM: # WSAConnect will complete immediately for UDP sockets so we don't # need to register any IOCP operation _overlapped.WSAConnect(conn.fileno(), address) fut = self._loop.create_future() fut.set_result(None) return fut self._register_with_iocp(conn) # The socket needs to be locally bound before we call ConnectEx(). try: _overlapped.BindLocal(conn.fileno(), conn.family) except OSError as e: if e.winerror != errno.WSAEINVAL: raise # Probably already locally bound; check using getsockname(). if conn.getsockname()[1] == 0: raise ov = _overlapped.Overlapped(NULL) ov.ConnectEx(conn.fileno(), address) def finish_connect(trans, key, ov): ov.getresult() # Use SO_UPDATE_CONNECT_CONTEXT so getsockname() etc work. conn.setsockopt(socket.SOL_SOCKET, _overlapped.SO_UPDATE_CONNECT_CONTEXT, 0) return conn return self._register(ov, conn, finish_connect) def sendfile(self, sock, file, offset, count): self._register_with_iocp(sock) ov = _overlapped.Overlapped(NULL) offset_low = offset & 0xffff_ffff offset_high = (offset >> 32) & 0xffff_ffff ov.TransmitFile(sock.fileno(), msvcrt.get_osfhandle(file.fileno()), offset_low, offset_high, count, 0, 0) return self._register(ov, sock, self.finish_socket_func) def accept_pipe(self, pipe): self._register_with_iocp(pipe) ov = _overlapped.Overlapped(NULL) connected = ov.ConnectNamedPipe(pipe.fileno()) if connected: # ConnectNamePipe() failed with ERROR_PIPE_CONNECTED which means # that the pipe is connected. There is no need to wait for the # completion of the connection. return self._result(pipe) def finish_accept_pipe(trans, key, ov): ov.getresult() return pipe return self._register(ov, pipe, finish_accept_pipe) async def connect_pipe(self, address): delay = CONNECT_PIPE_INIT_DELAY while True: # Unfortunately there is no way to do an overlapped connect to # a pipe. Call CreateFile() in a loop until it doesn't fail with # ERROR_PIPE_BUSY. try: handle = _overlapped.ConnectPipe(address) break except OSError as exc: if exc.winerror != _overlapped.ERROR_PIPE_BUSY: raise # ConnectPipe() failed with ERROR_PIPE_BUSY: retry later delay = min(delay * 2, CONNECT_PIPE_MAX_DELAY) await tasks.sleep(delay) return windows_utils.PipeHandle(handle) def wait_for_handle(self, handle, timeout=None): """Wait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). """ return self._wait_for_handle(handle, timeout, False) def _wait_cancel(self, event, done_callback): fut = self._wait_for_handle(event, None, True) # add_done_callback() cannot be used because the wait may only complete # in IocpProactor.close(), while the event loop is not running. fut._done_callback = done_callback return fut def _wait_for_handle(self, handle, timeout, _is_cancel): self._check_closed() if timeout is None: ms = _winapi.INFINITE else: # RegisterWaitForSingleObject() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) # We only create ov so we can use ov.address as a key for the cache. ov = _overlapped.Overlapped(NULL) wait_handle = _overlapped.RegisterWaitWithQueue( handle, self._iocp, ov.address, ms) if _is_cancel: f = _WaitCancelFuture(ov, handle, wait_handle, loop=self._loop) else: f = _WaitHandleFuture(ov, handle, wait_handle, self, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] def finish_wait_for_handle(trans, key, ov): # Note that this second wait means that we should only use # this with handles types where a successful wait has no # effect. So events or processes are all right, but locks # or semaphores are not. Also note if the handle is # signalled and then quickly reset, then we may return # False even though we have not timed out. return f._poll() self._cache[ov.address] = (f, ov, 0, finish_wait_for_handle) return f def _register_with_iocp(self, obj): # To get notifications of finished ops on this objects sent to the # completion port, were must register the handle. if obj not in self._registered: self._registered.add(obj) _overlapped.CreateIoCompletionPort(obj.fileno(), self._iocp, 0, 0) # XXX We could also use SetFileCompletionNotificationModes() # to avoid sending notifications to completion port of ops # that succeed immediately. def _register(self, ov, obj, callback): self._check_closed() # Return a future which will be set with the result of the # operation when it completes. The future's value is actually # the value returned by callback(). f = _OverlappedFuture(ov, loop=self._loop) if f._source_traceback: del f._source_traceback[-1] if not ov.pending: # The operation has completed, so no need to postpone the # work. We cannot take this short cut if we need the # NumberOfBytes, CompletionKey values returned by # PostQueuedCompletionStatus(). try: value = callback(None, None, ov) except OSError as e: f.set_exception(e) else: f.set_result(value) # Even if GetOverlappedResult() was called, we have to wait for the # notification of the completion in GetQueuedCompletionStatus(). # Register the overlapped operation to keep a reference to the # OVERLAPPED object, otherwise the memory is freed and Windows may # read uninitialized memory. # Register the overlapped operation for later. Note that # we only store obj to prevent it from being garbage # collected too early. self._cache[ov.address] = (f, ov, obj, callback) return f def _unregister(self, ov): """Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). """ self._check_closed() self._unregistered.append(ov) def _get_accept_socket(self, family): s = socket.socket(family) s.settimeout(0) return s def _poll(self, timeout=None): if timeout is None: ms = INFINITE elif timeout < 0: raise ValueError("negative timeout") else: # GetQueuedCompletionStatus() has a resolution of 1 millisecond, # round away from zero to wait *at least* timeout seconds. ms = math.ceil(timeout * 1e3) if ms >= INFINITE: raise ValueError("timeout too big") while True: status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms) if status is None: break ms = 0 err, transferred, key, address = status try: f, ov, obj, callback = self._cache.pop(address) except KeyError: if self._loop.get_debug(): self._loop.call_exception_handler({ 'message': ('GetQueuedCompletionStatus() returned an ' 'unexpected event'), 'status': ('err=%s transferred=%s key=%#x address=%#x' % (err, transferred, key, address)), }) # key is either zero, or it is used to return a pipe # handle which should be closed to avoid a leak. if key not in (0, _overlapped.INVALID_HANDLE_VALUE): _winapi.CloseHandle(key) continue if obj in self._stopped_serving: f.cancel() # Don't call the callback if _register() already read the result or # if the overlapped has been cancelled elif not f.done(): try: value = callback(transferred, key, ov) except OSError as e: f.set_exception(e) self._results.append(f) else: f.set_result(value) self._results.append(f) finally: f = None # Remove unregistered futures for ov in self._unregistered: self._cache.pop(ov.address, None) self._unregistered.clear() def _stop_serving(self, obj): # obj is a socket or pipe handle. It will be closed in # BaseProactorEventLoop._stop_serving() which will make any # pending operations fail quickly. self._stopped_serving.add(obj) def close(self): if self._iocp is None: # already closed return # Cancel remaining registered operations. for fut, ov, obj, callback in list(self._cache.values()): if fut.cancelled(): # Nothing to do with cancelled futures pass elif isinstance(fut, _WaitCancelFuture): # _WaitCancelFuture must not be cancelled pass else: try: fut.cancel() except OSError as exc: if self._loop is not None: context = { 'message': 'Cancelling a future failed', 'exception': exc, 'future': fut, } if fut._source_traceback: context['source_traceback'] = fut._source_traceback self._loop.call_exception_handler(context) # Wait until all cancelled overlapped complete: don't exit with running # overlapped to prevent a crash. Display progress every second if the # loop is still running. msg_update = 1.0 start_time = time.monotonic() next_msg = start_time + msg_update while self._cache: if next_msg <= time.monotonic(): logger.debug('%r is running after closing for %.1f seconds', self, time.monotonic() - start_time) next_msg = time.monotonic() + msg_update # handle a few events, or timeout self._poll(msg_update) self._results = [] _winapi.CloseHandle(self._iocp) self._iocp = None def __del__(self): self.close() class _WindowsSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): self._proc = windows_utils.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) def callback(f): returncode = self._proc.poll() self._process_exited(returncode) f = self._loop._proactor.wait_for_handle(int(self._proc._handle)) f.add_done_callback(callback) SelectorEventLoop = _WindowsSelectorEventLoop class WindowsSelectorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): _loop_factory = SelectorEventLoop class WindowsProactorEventLoopPolicy(events.BaseDefaultEventLoopPolicy): _loop_factory = ProactorEventLoop DefaultEventLoopPolicy = WindowsProactorEventLoopPolicy base_futures.py000064400000003666152343231170007621 0ustar00__all__ = () import reprlib from . import format_helpers # States for Future. _PENDING = 'PENDING' _CANCELLED = 'CANCELLED' _FINISHED = 'FINISHED' def isfuture(obj): """Check for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. """ return (hasattr(obj.__class__, '_asyncio_future_blocking') and obj._asyncio_future_blocking is not None) def _format_callbacks(cb): """helper function for Future.__repr__""" size = len(cb) if not size: cb = '' def format_cb(callback): return format_helpers._format_callback_source(callback, ()) if size == 1: cb = format_cb(cb[0][0]) elif size == 2: cb = '{}, {}'.format(format_cb(cb[0][0]), format_cb(cb[1][0])) elif size > 2: cb = '{}, <{} more>, {}'.format(format_cb(cb[0][0]), size - 2, format_cb(cb[-1][0])) return f'cb=[{cb}]' def _future_repr_info(future): # (Future) -> str """helper function for Future.__repr__""" info = [future._state.lower()] if future._state == _FINISHED: if future._exception is not None: info.append(f'exception={future._exception!r}') else: # use reprlib to limit the length of the output, especially # for very long strings result = reprlib.repr(future._result) info.append(f'result={result}') if future._callbacks: info.append(_format_callbacks(future._callbacks)) if future._source_traceback: frame = future._source_traceback[-1] info.append(f'created at {frame[0]}:{frame[1]}') return info @reprlib.recursive_repr() def _future_repr(future): info = ' '.join(_future_repr_info(future)) return f'<{future.__class__.__name__} {info}>' format_helpers.py000064400000004544152343231170010140 0ustar00import functools import inspect import reprlib import sys import traceback from . import constants def _get_function_source(func): func = inspect.unwrap(func) if inspect.isfunction(func): code = func.__code__ return (code.co_filename, code.co_firstlineno) if isinstance(func, functools.partial): return _get_function_source(func.func) if isinstance(func, functools.partialmethod): return _get_function_source(func.func) return None def _format_callback_source(func, args): func_repr = _format_callback(func, args, None) source = _get_function_source(func) if source: func_repr += f' at {source[0]}:{source[1]}' return func_repr def _format_args_and_kwargs(args, kwargs): """Format function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). """ # use reprlib to limit the length of the output items = [] if args: items.extend(reprlib.repr(arg) for arg in args) if kwargs: items.extend(f'{k}={reprlib.repr(v)}' for k, v in kwargs.items()) return '({})'.format(', '.join(items)) def _format_callback(func, args, kwargs, suffix=''): if isinstance(func, functools.partial): suffix = _format_args_and_kwargs(args, kwargs) + suffix return _format_callback(func.func, func.args, func.keywords, suffix) if hasattr(func, '__qualname__') and func.__qualname__: func_repr = func.__qualname__ elif hasattr(func, '__name__') and func.__name__: func_repr = func.__name__ else: func_repr = repr(func) func_repr += _format_args_and_kwargs(args, kwargs) if suffix: func_repr += suffix return func_repr def extract_stack(f=None, limit=None): """Replacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. """ if f is None: f = sys._getframe().f_back if limit is None: # Limit the amount of work to a reasonable amount, as extract_stack() # can be called for each coroutine and future in debug mode. limit = constants.DEBUG_STACK_DEPTH stack = traceback.StackSummary.extract(traceback.walk_stack(f), limit=limit, lookup_lines=False) stack.reverse() return stack sslproto.py000064400000076233152343231170007017 0ustar00# Contains code from https://github.com/MagicStack/uvloop/tree/v0.16.0 # SPDX-License-Identifier: PSF-2.0 AND (MIT OR Apache-2.0) # SPDX-FileCopyrightText: Copyright (c) 2015-2021 MagicStack Inc. http://magic.io import collections import enum import warnings try: import ssl except ImportError: # pragma: no cover ssl = None from . import constants from . import exceptions from . import protocols from . import transports from .log import logger if ssl is not None: SSLAgainErrors = (ssl.SSLWantReadError, ssl.SSLSyscallError) class SSLProtocolState(enum.Enum): UNWRAPPED = "UNWRAPPED" DO_HANDSHAKE = "DO_HANDSHAKE" WRAPPED = "WRAPPED" FLUSHING = "FLUSHING" SHUTDOWN = "SHUTDOWN" class AppProtocolState(enum.Enum): # This tracks the state of app protocol (https://git.io/fj59P): # # INIT -cm-> CON_MADE [-dr*->] [-er-> EOF?] -cl-> CON_LOST # # * cm: connection_made() # * dr: data_received() # * er: eof_received() # * cl: connection_lost() STATE_INIT = "STATE_INIT" STATE_CON_MADE = "STATE_CON_MADE" STATE_EOF = "STATE_EOF" STATE_CON_LOST = "STATE_CON_LOST" def _create_transport_context(server_side, server_hostname): if server_side: raise ValueError('Server side SSL needs a valid SSLContext') # Client side may pass ssl=True to use a default # context; in that case the sslcontext passed is None. # The default is secure for client connections. # Python 3.4+: use up-to-date strong settings. sslcontext = ssl.create_default_context() if not server_hostname: sslcontext.check_hostname = False return sslcontext def add_flowcontrol_defaults(high, low, kb): if high is None: if low is None: hi = kb * 1024 else: lo = low hi = 4 * lo else: hi = high if low is None: lo = hi // 4 else: lo = low if not hi >= lo >= 0: raise ValueError('high (%r) must be >= low (%r) must be >= 0' % (hi, lo)) return hi, lo class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport): _start_tls_compatible = True _sendfile_compatible = constants._SendfileMode.FALLBACK def __init__(self, loop, ssl_protocol): self._loop = loop self._ssl_protocol = ssl_protocol self._closed = False def get_extra_info(self, name, default=None): """Get optional transport information.""" return self._ssl_protocol._get_extra_info(name, default) def set_protocol(self, protocol): self._ssl_protocol._set_app_protocol(protocol) def get_protocol(self): return self._ssl_protocol._app_protocol def is_closing(self): return self._closed or self._ssl_protocol._is_transport_closing() def close(self): """Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. """ if not self._closed: self._closed = True self._ssl_protocol._start_shutdown() else: self._ssl_protocol = None def __del__(self, _warnings=warnings): if not self._closed: self._closed = True _warnings.warn( "unclosed transport ", ResourceWarning) def is_reading(self): return not self._ssl_protocol._app_reading_paused def pause_reading(self): """Pause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. """ self._ssl_protocol._pause_reading() def resume_reading(self): """Resume the receiving end. Data received will once again be passed to the protocol's data_received() method. """ self._ssl_protocol._resume_reading() def set_write_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ self._ssl_protocol._set_write_buffer_limits(high, low) self._ssl_protocol._control_app_writing() def get_write_buffer_limits(self): return (self._ssl_protocol._outgoing_low_water, self._ssl_protocol._outgoing_high_water) def get_write_buffer_size(self): """Return the current size of the write buffers.""" return self._ssl_protocol._get_write_buffer_size() def set_read_buffer_limits(self, high=None, low=None): """Set the high- and low-water limits for read flow control. These two values control when to call the upstream transport's pause_reading() and resume_reading() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_reading() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_reading() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. """ self._ssl_protocol._set_read_buffer_limits(high, low) self._ssl_protocol._control_ssl_reading() def get_read_buffer_limits(self): return (self._ssl_protocol._incoming_low_water, self._ssl_protocol._incoming_high_water) def get_read_buffer_size(self): """Return the current size of the read buffer.""" return self._ssl_protocol._get_read_buffer_size() @property def _protocol_paused(self): # Required for sendfile fallback pause_writing/resume_writing logic return self._ssl_protocol._app_writing_paused def write(self, data): """Write some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. """ if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f"data: expecting a bytes-like instance, " f"got {type(data).__name__}") if not data: return self._ssl_protocol._write_appdata((data,)) def writelines(self, list_of_data): """Write a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. """ self._ssl_protocol._write_appdata(list_of_data) def write_eof(self): """Close the write end after flushing buffered data. This raises :exc:`NotImplementedError` right now. """ raise NotImplementedError def can_write_eof(self): """Return True if this transport supports write_eof(), False if not.""" return False def abort(self): """Close the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. """ self._force_close(None) def _force_close(self, exc): self._closed = True if self._ssl_protocol is not None: self._ssl_protocol._abort(exc) def _test__append_write_backlog(self, data): # for test only self._ssl_protocol._write_backlog.append(data) self._ssl_protocol._write_buffer_size += len(data) class SSLProtocol(protocols.BufferedProtocol): max_size = 256 * 1024 # Buffer size passed to read() _handshake_start_time = None _handshake_timeout_handle = None _shutdown_timeout_handle = None def __init__(self, loop, app_protocol, sslcontext, waiter, server_side=False, server_hostname=None, call_connection_made=True, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): if ssl is None: raise RuntimeError("stdlib ssl module not available") self._ssl_buffer = bytearray(self.max_size) self._ssl_buffer_view = memoryview(self._ssl_buffer) if ssl_handshake_timeout is None: ssl_handshake_timeout = constants.SSL_HANDSHAKE_TIMEOUT elif ssl_handshake_timeout <= 0: raise ValueError( f"ssl_handshake_timeout should be a positive number, " f"got {ssl_handshake_timeout}") if ssl_shutdown_timeout is None: ssl_shutdown_timeout = constants.SSL_SHUTDOWN_TIMEOUT elif ssl_shutdown_timeout <= 0: raise ValueError( f"ssl_shutdown_timeout should be a positive number, " f"got {ssl_shutdown_timeout}") if not sslcontext: sslcontext = _create_transport_context( server_side, server_hostname) self._server_side = server_side if server_hostname and not server_side: self._server_hostname = server_hostname else: self._server_hostname = None self._sslcontext = sslcontext # SSL-specific extra info. More info are set when the handshake # completes. self._extra = dict(sslcontext=sslcontext) # App data write buffering self._write_backlog = collections.deque() self._write_buffer_size = 0 self._waiter = waiter self._loop = loop self._set_app_protocol(app_protocol) self._app_transport = None self._app_transport_created = False # transport, ex: SelectorSocketTransport self._transport = None self._ssl_handshake_timeout = ssl_handshake_timeout self._ssl_shutdown_timeout = ssl_shutdown_timeout # SSL and state machine self._incoming = ssl.MemoryBIO() self._outgoing = ssl.MemoryBIO() self._state = SSLProtocolState.UNWRAPPED self._conn_lost = 0 # Set when connection_lost called if call_connection_made: self._app_state = AppProtocolState.STATE_INIT else: self._app_state = AppProtocolState.STATE_CON_MADE self._sslobj = self._sslcontext.wrap_bio( self._incoming, self._outgoing, server_side=self._server_side, server_hostname=self._server_hostname) # Flow Control self._ssl_writing_paused = False self._app_reading_paused = False self._ssl_reading_paused = False self._incoming_high_water = 0 self._incoming_low_water = 0 self._set_read_buffer_limits() self._eof_received = False self._app_writing_paused = False self._outgoing_high_water = 0 self._outgoing_low_water = 0 self._set_write_buffer_limits() self._get_app_transport() def _set_app_protocol(self, app_protocol): self._app_protocol = app_protocol # Make fast hasattr check first if (hasattr(app_protocol, 'get_buffer') and isinstance(app_protocol, protocols.BufferedProtocol)): self._app_protocol_get_buffer = app_protocol.get_buffer self._app_protocol_buffer_updated = app_protocol.buffer_updated self._app_protocol_is_buffer = True else: self._app_protocol_is_buffer = False def _wakeup_waiter(self, exc=None): if self._waiter is None: return if not self._waiter.cancelled(): if exc is not None: self._waiter.set_exception(exc) else: self._waiter.set_result(None) self._waiter = None def _get_app_transport(self): if self._app_transport is None: if self._app_transport_created: raise RuntimeError('Creating _SSLProtocolTransport twice') self._app_transport = _SSLProtocolTransport(self._loop, self) self._app_transport_created = True return self._app_transport def _is_transport_closing(self): return self._transport is not None and self._transport.is_closing() def connection_made(self, transport): """Called when the low-level connection is made. Start the SSL handshake. """ self._transport = transport self._start_handshake() def connection_lost(self, exc): """Called when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ self._write_backlog.clear() self._outgoing.read() self._conn_lost += 1 # Just mark the app transport as closed so that its __dealloc__ # doesn't complain. if self._app_transport is not None: self._app_transport._closed = True if self._state != SSLProtocolState.DO_HANDSHAKE: if ( self._app_state == AppProtocolState.STATE_CON_MADE or self._app_state == AppProtocolState.STATE_EOF ): self._app_state = AppProtocolState.STATE_CON_LOST self._loop.call_soon(self._app_protocol.connection_lost, exc) self._set_state(SSLProtocolState.UNWRAPPED) self._transport = None self._app_transport = None self._app_protocol = None self._wakeup_waiter(exc) if self._shutdown_timeout_handle: self._shutdown_timeout_handle.cancel() self._shutdown_timeout_handle = None if self._handshake_timeout_handle: self._handshake_timeout_handle.cancel() self._handshake_timeout_handle = None def get_buffer(self, n): want = n if want <= 0 or want > self.max_size: want = self.max_size if len(self._ssl_buffer) < want: self._ssl_buffer = bytearray(want) self._ssl_buffer_view = memoryview(self._ssl_buffer) return self._ssl_buffer_view def buffer_updated(self, nbytes): self._incoming.write(self._ssl_buffer_view[:nbytes]) if self._state == SSLProtocolState.DO_HANDSHAKE: self._do_handshake() elif self._state == SSLProtocolState.WRAPPED: self._do_read() elif self._state == SSLProtocolState.FLUSHING: self._do_flush() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() def eof_received(self): """Called when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ self._eof_received = True try: if self._loop.get_debug(): logger.debug("%r received EOF", self) if self._state == SSLProtocolState.DO_HANDSHAKE: self._on_handshake_complete(ConnectionResetError) elif self._state == SSLProtocolState.WRAPPED: self._set_state(SSLProtocolState.FLUSHING) if self._app_reading_paused: return True else: self._do_flush() elif self._state == SSLProtocolState.FLUSHING: self._do_write() self._set_state(SSLProtocolState.SHUTDOWN) self._do_shutdown() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() except Exception: self._transport.close() raise def _get_extra_info(self, name, default=None): if name in self._extra: return self._extra[name] elif self._transport is not None: return self._transport.get_extra_info(name, default) else: return default def _set_state(self, new_state): allowed = False if new_state == SSLProtocolState.UNWRAPPED: allowed = True elif ( self._state == SSLProtocolState.UNWRAPPED and new_state == SSLProtocolState.DO_HANDSHAKE ): allowed = True elif ( self._state == SSLProtocolState.DO_HANDSHAKE and new_state == SSLProtocolState.WRAPPED ): allowed = True elif ( self._state == SSLProtocolState.WRAPPED and new_state == SSLProtocolState.FLUSHING ): allowed = True elif ( self._state == SSLProtocolState.FLUSHING and new_state == SSLProtocolState.SHUTDOWN ): allowed = True if allowed: self._state = new_state else: raise RuntimeError( 'cannot switch state from {} to {}'.format( self._state, new_state)) # Handshake flow def _start_handshake(self): if self._loop.get_debug(): logger.debug("%r starts SSL handshake", self) self._handshake_start_time = self._loop.time() else: self._handshake_start_time = None self._set_state(SSLProtocolState.DO_HANDSHAKE) # start handshake timeout count down self._handshake_timeout_handle = \ self._loop.call_later(self._ssl_handshake_timeout, lambda: self._check_handshake_timeout()) self._do_handshake() def _check_handshake_timeout(self): if self._state == SSLProtocolState.DO_HANDSHAKE: msg = ( f"SSL handshake is taking longer than " f"{self._ssl_handshake_timeout} seconds: " f"aborting the connection" ) self._fatal_error(ConnectionAbortedError(msg)) def _do_handshake(self): try: self._sslobj.do_handshake() except SSLAgainErrors: self._process_outgoing() except ssl.SSLError as exc: self._on_handshake_complete(exc) else: self._on_handshake_complete(None) def _on_handshake_complete(self, handshake_exc): if self._handshake_timeout_handle is not None: self._handshake_timeout_handle.cancel() self._handshake_timeout_handle = None sslobj = self._sslobj try: if handshake_exc is None: self._set_state(SSLProtocolState.WRAPPED) else: raise handshake_exc peercert = sslobj.getpeercert() except Exception as exc: handshake_exc = None self._set_state(SSLProtocolState.UNWRAPPED) if isinstance(exc, ssl.CertificateError): msg = 'SSL handshake failed on verifying the certificate' else: msg = 'SSL handshake failed' self._fatal_error(exc, msg) self._wakeup_waiter(exc) return if self._loop.get_debug(): dt = self._loop.time() - self._handshake_start_time logger.debug("%r: SSL handshake took %.1f ms", self, dt * 1e3) # Add extra info that becomes available after handshake. self._extra.update(peercert=peercert, cipher=sslobj.cipher(), compression=sslobj.compression(), ssl_object=sslobj) if self._app_state == AppProtocolState.STATE_INIT: self._app_state = AppProtocolState.STATE_CON_MADE self._app_protocol.connection_made(self._get_app_transport()) self._wakeup_waiter() self._do_read() # Shutdown flow def _start_shutdown(self): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN, SSLProtocolState.UNWRAPPED ) ): return if self._app_transport is not None: self._app_transport._closed = True if self._state == SSLProtocolState.DO_HANDSHAKE: self._abort(None) else: self._set_state(SSLProtocolState.FLUSHING) self._shutdown_timeout_handle = self._loop.call_later( self._ssl_shutdown_timeout, lambda: self._check_shutdown_timeout() ) self._do_flush() def _check_shutdown_timeout(self): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN ) ): self._transport._force_close( exceptions.TimeoutError('SSL shutdown timed out')) def _do_flush(self): self._do_read() self._set_state(SSLProtocolState.SHUTDOWN) self._do_shutdown() def _do_shutdown(self): try: if not self._eof_received: self._sslobj.unwrap() except SSLAgainErrors: self._process_outgoing() except ssl.SSLError as exc: self._on_shutdown_complete(exc) else: self._process_outgoing() self._call_eof_received() self._on_shutdown_complete(None) def _on_shutdown_complete(self, shutdown_exc): if self._shutdown_timeout_handle is not None: self._shutdown_timeout_handle.cancel() self._shutdown_timeout_handle = None if shutdown_exc: self._fatal_error(shutdown_exc) else: self._loop.call_soon(self._transport.close) def _abort(self, exc): self._set_state(SSLProtocolState.UNWRAPPED) if self._transport is not None: self._transport._force_close(exc) # Outgoing flow def _write_appdata(self, list_of_data): if ( self._state in ( SSLProtocolState.FLUSHING, SSLProtocolState.SHUTDOWN, SSLProtocolState.UNWRAPPED ) ): if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('SSL connection is closed') self._conn_lost += 1 return for data in list_of_data: self._write_backlog.append(data) self._write_buffer_size += len(data) try: if self._state == SSLProtocolState.WRAPPED: self._do_write() except Exception as ex: self._fatal_error(ex, 'Fatal error on SSL protocol') def _do_write(self): try: while self._write_backlog: data = self._write_backlog[0] count = self._sslobj.write(data) data_len = len(data) if count < data_len: self._write_backlog[0] = data[count:] self._write_buffer_size -= count else: del self._write_backlog[0] self._write_buffer_size -= data_len except SSLAgainErrors: pass self._process_outgoing() def _process_outgoing(self): if not self._ssl_writing_paused: data = self._outgoing.read() if len(data): self._transport.write(data) self._control_app_writing() # Incoming flow def _do_read(self): if ( self._state not in ( SSLProtocolState.WRAPPED, SSLProtocolState.FLUSHING, ) ): return try: if not self._app_reading_paused: if self._app_protocol_is_buffer: self._do_read__buffered() else: self._do_read__copied() if self._write_backlog: self._do_write() else: self._process_outgoing() self._control_ssl_reading() except Exception as ex: self._fatal_error(ex, 'Fatal error on SSL protocol') def _do_read__buffered(self): offset = 0 count = 1 buf = self._app_protocol_get_buffer(self._get_read_buffer_size()) wants = len(buf) try: count = self._sslobj.read(wants, buf) if count > 0: offset = count while offset < wants: count = self._sslobj.read(wants - offset, buf[offset:]) if count > 0: offset += count else: break else: self._loop.call_soon(lambda: self._do_read()) except SSLAgainErrors: pass if offset > 0: self._app_protocol_buffer_updated(offset) if not count: # close_notify self._call_eof_received() self._start_shutdown() def _do_read__copied(self): chunk = b'1' zero = True one = False try: while True: chunk = self._sslobj.read(self.max_size) if not chunk: break if zero: zero = False one = True first = chunk elif one: one = False data = [first, chunk] else: data.append(chunk) except SSLAgainErrors: pass if one: self._app_protocol.data_received(first) elif not zero: self._app_protocol.data_received(b''.join(data)) if not chunk: # close_notify self._call_eof_received() self._start_shutdown() def _call_eof_received(self): try: if self._app_state == AppProtocolState.STATE_CON_MADE: self._app_state = AppProtocolState.STATE_EOF keep_open = self._app_protocol.eof_received() if keep_open: logger.warning('returning true from eof_received() ' 'has no effect when using ssl') except (KeyboardInterrupt, SystemExit): raise except BaseException as ex: self._fatal_error(ex, 'Error calling eof_received()') # Flow control for writes from APP socket def _control_app_writing(self): size = self._get_write_buffer_size() if size >= self._outgoing_high_water and not self._app_writing_paused: self._app_writing_paused = True try: self._app_protocol.pause_writing() except (KeyboardInterrupt, SystemExit): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.pause_writing() failed', 'exception': exc, 'transport': self._app_transport, 'protocol': self, }) elif size <= self._outgoing_low_water and self._app_writing_paused: self._app_writing_paused = False try: self._app_protocol.resume_writing() except (KeyboardInterrupt, SystemExit): raise except BaseException as exc: self._loop.call_exception_handler({ 'message': 'protocol.resume_writing() failed', 'exception': exc, 'transport': self._app_transport, 'protocol': self, }) def _get_write_buffer_size(self): return self._outgoing.pending + self._write_buffer_size def _set_write_buffer_limits(self, high=None, low=None): high, low = add_flowcontrol_defaults( high, low, constants.FLOW_CONTROL_HIGH_WATER_SSL_WRITE) self._outgoing_high_water = high self._outgoing_low_water = low # Flow control for reads to APP socket def _pause_reading(self): self._app_reading_paused = True def _resume_reading(self): if self._app_reading_paused: self._app_reading_paused = False def resume(): if self._state == SSLProtocolState.WRAPPED: self._do_read() elif self._state == SSLProtocolState.FLUSHING: self._do_flush() elif self._state == SSLProtocolState.SHUTDOWN: self._do_shutdown() self._loop.call_soon(resume) # Flow control for reads from SSL socket def _control_ssl_reading(self): size = self._get_read_buffer_size() if size >= self._incoming_high_water and not self._ssl_reading_paused: self._ssl_reading_paused = True self._transport.pause_reading() elif size <= self._incoming_low_water and self._ssl_reading_paused: self._ssl_reading_paused = False self._transport.resume_reading() def _set_read_buffer_limits(self, high=None, low=None): high, low = add_flowcontrol_defaults( high, low, constants.FLOW_CONTROL_HIGH_WATER_SSL_READ) self._incoming_high_water = high self._incoming_low_water = low def _get_read_buffer_size(self): return self._incoming.pending # Flow control for writes to SSL socket def pause_writing(self): """Called when the low-level transport's buffer goes over the high-water mark. """ assert not self._ssl_writing_paused self._ssl_writing_paused = True def resume_writing(self): """Called when the low-level transport's buffer drains below the low-water mark. """ assert self._ssl_writing_paused self._ssl_writing_paused = False self._process_outgoing() def _fatal_error(self, exc, message='Fatal error on transport'): if self._transport: self._transport._force_close(exc) if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) elif not isinstance(exc, exceptions.CancelledError): self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self._transport, 'protocol': self, }) base_subprocess.py000064400000021245152343231170010305 0ustar00import collections import subprocess import warnings from . import protocols from . import transports from .log import logger class BaseSubprocessTransport(transports.SubprocessTransport): def __init__(self, loop, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=None, extra=None, **kwargs): super().__init__(extra) self._closed = False self._protocol = protocol self._loop = loop self._proc = None self._pid = None self._returncode = None self._exit_waiters = [] self._pending_calls = collections.deque() self._pipes = {} self._finished = False if stdin == subprocess.PIPE: self._pipes[0] = None if stdout == subprocess.PIPE: self._pipes[1] = None if stderr == subprocess.PIPE: self._pipes[2] = None # Create the child process: set the _proc attribute try: self._start(args=args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, bufsize=bufsize, **kwargs) except: self.close() raise self._pid = self._proc.pid self._extra['subprocess'] = self._proc if self._loop.get_debug(): if isinstance(args, (bytes, str)): program = args else: program = args[0] logger.debug('process %r created: pid %s', program, self._pid) self._loop.create_task(self._connect_pipes(waiter)) def __repr__(self): info = [self.__class__.__name__] if self._closed: info.append('closed') if self._pid is not None: info.append(f'pid={self._pid}') if self._returncode is not None: info.append(f'returncode={self._returncode}') elif self._pid is not None: info.append('running') else: info.append('not started') stdin = self._pipes.get(0) if stdin is not None: info.append(f'stdin={stdin.pipe}') stdout = self._pipes.get(1) stderr = self._pipes.get(2) if stdout is not None and stderr is stdout: info.append(f'stdout=stderr={stdout.pipe}') else: if stdout is not None: info.append(f'stdout={stdout.pipe}') if stderr is not None: info.append(f'stderr={stderr.pipe}') return '<{}>'.format(' '.join(info)) def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): raise NotImplementedError def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closed def close(self): if self._closed: return self._closed = True for proto in self._pipes.values(): if proto is None: continue proto.pipe.close() if (self._proc is not None and # has the child process finished? self._returncode is None and # the child process has finished, but the # transport hasn't been notified yet? self._proc.poll() is None): if self._loop.get_debug(): logger.warning('Close running child process: kill %r', self) try: self._proc.kill() except ProcessLookupError: pass # Don't clear the _proc reference yet: _post_init() may still run def __del__(self, _warn=warnings.warn): if not self._closed: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self.close() def get_pid(self): return self._pid def get_returncode(self): return self._returncode def get_pipe_transport(self, fd): if fd in self._pipes: return self._pipes[fd].pipe else: return None def _check_proc(self): if self._proc is None: raise ProcessLookupError() def send_signal(self, signal): self._check_proc() self._proc.send_signal(signal) def terminate(self): self._check_proc() self._proc.terminate() def kill(self): self._check_proc() self._proc.kill() async def _connect_pipes(self, waiter): try: proc = self._proc loop = self._loop if proc.stdin is not None: _, pipe = await loop.connect_write_pipe( lambda: WriteSubprocessPipeProto(self, 0), proc.stdin) self._pipes[0] = pipe if proc.stdout is not None: _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 1), proc.stdout) self._pipes[1] = pipe if proc.stderr is not None: _, pipe = await loop.connect_read_pipe( lambda: ReadSubprocessPipeProto(self, 2), proc.stderr) self._pipes[2] = pipe assert self._pending_calls is not None loop.call_soon(self._protocol.connection_made, self) for callback, data in self._pending_calls: loop.call_soon(callback, *data) self._pending_calls = None except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if waiter is not None and not waiter.cancelled(): waiter.set_exception(exc) else: if waiter is not None and not waiter.cancelled(): waiter.set_result(None) def _call(self, cb, *data): if self._pending_calls is not None: self._pending_calls.append((cb, data)) else: self._loop.call_soon(cb, *data) def _pipe_connection_lost(self, fd, exc): self._call(self._protocol.pipe_connection_lost, fd, exc) self._try_finish() def _pipe_data_received(self, fd, data): self._call(self._protocol.pipe_data_received, fd, data) def _process_exited(self, returncode): assert returncode is not None, returncode assert self._returncode is None, self._returncode if self._loop.get_debug(): logger.info('%r exited with return code %r', self, returncode) self._returncode = returncode if self._proc.returncode is None: # asyncio uses a child watcher: copy the status into the Popen # object. On Python 3.6, it is required to avoid a ResourceWarning. self._proc.returncode = returncode self._call(self._protocol.process_exited) self._try_finish() async def _wait(self): """Wait until the process exit and return the process return code. This method is a coroutine.""" if self._returncode is not None: return self._returncode waiter = self._loop.create_future() self._exit_waiters.append(waiter) return await waiter def _try_finish(self): assert not self._finished if self._returncode is None: return if all(p is not None and p.disconnected for p in self._pipes.values()): self._finished = True self._call(self._call_connection_lost, None) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: # wake up futures waiting for wait() for waiter in self._exit_waiters: if not waiter.cancelled(): waiter.set_result(self._returncode) self._exit_waiters = None self._loop = None self._proc = None self._protocol = None class WriteSubprocessPipeProto(protocols.BaseProtocol): def __init__(self, proc, fd): self.proc = proc self.fd = fd self.pipe = None self.disconnected = False def connection_made(self, transport): self.pipe = transport def __repr__(self): return f'<{self.__class__.__name__} fd={self.fd} pipe={self.pipe!r}>' def connection_lost(self, exc): self.disconnected = True self.proc._pipe_connection_lost(self.fd, exc) self.proc = None def pause_writing(self): self.proc._protocol.pause_writing() def resume_writing(self): self.proc._protocol.resume_writing() class ReadSubprocessPipeProto(WriteSubprocessPipeProto, protocols.Protocol): def data_received(self, data): self.proc._pipe_data_received(self.fd, data) selector_events.py000064400000136314152343231170010333 0ustar00"""Event 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. """ __all__ = 'BaseSelectorEventLoop', import collections import errno import functools import itertools import os import selectors import socket import warnings import weakref try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import constants from . import events from . import futures from . import protocols from . import sslproto from . import transports from . import trsock from .log import logger _HAS_SENDMSG = hasattr(socket.socket, 'sendmsg') if _HAS_SENDMSG: try: SC_IOV_MAX = os.sysconf('SC_IOV_MAX') except OSError: # Fallback to send _HAS_SENDMSG = False def _test_selector_event(selector, fd, event): # Test if the selector is monitoring 'event' events # for the file descriptor 'fd'. try: key = selector.get_key(fd) except KeyError: return False else: return bool(key.events & event) class BaseSelectorEventLoop(base_events.BaseEventLoop): """Selector event loop. See events.EventLoop for API specification. """ def __init__(self, selector=None): super().__init__() if selector is None: selector = selectors.DefaultSelector() logger.debug('Using selector: %s', selector.__class__.__name__) self._selector = selector self._make_self_pipe() self._transports = weakref.WeakValueDictionary() def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): self._ensure_fd_no_transport(sock) return _SelectorSocketTransport(self, sock, protocol, waiter, extra, server) def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT, ): self._ensure_fd_no_transport(rawsock) ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout ) _SelectorSocketTransport(self, rawsock, ssl_protocol, extra=extra, server=server) return ssl_protocol._app_transport def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): self._ensure_fd_no_transport(sock) return _SelectorDatagramTransport(self, sock, protocol, address, waiter, extra) def close(self): if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self.is_closed(): return self._close_self_pipe() super().close() if self._selector is not None: self._selector.close() self._selector = None def _close_self_pipe(self): self._remove_reader(self._ssock.fileno()) self._ssock.close() self._ssock = None self._csock.close() self._csock = None self._internal_fds -= 1 def _make_self_pipe(self): # A self-socket, really. :-) self._ssock, self._csock = socket.socketpair() self._ssock.setblocking(False) self._csock.setblocking(False) self._internal_fds += 1 self._add_reader(self._ssock.fileno(), self._read_from_self) def _process_self_data(self, data): pass def _read_from_self(self): while True: try: data = self._ssock.recv(4096) if not data: break self._process_self_data(data) except InterruptedError: continue except BlockingIOError: break def _write_to_self(self): # This may be called from a different thread, possibly after # _close_self_pipe() has been called or even while it is # running. Guard for self._csock being None or closed. When # a socket is closed, send() raises OSError (with errno set to # EBADF, but let's not rely on the exact error code). csock = self._csock if csock is None: return try: csock.send(b'\0') except OSError: if self._debug: logger.debug("Fail to write a null byte into the " "self-pipe socket", exc_info=True) def _start_serving(self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): self._add_reader(sock.fileno(), self._accept_connection, protocol_factory, sock, sslcontext, server, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) def _accept_connection( self, protocol_factory, sock, sslcontext=None, server=None, backlog=100, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): # This method is only called once for each event loop tick where the # listening socket has triggered an EVENT_READ. There may be multiple # connections waiting for an .accept() so it is called in a loop. # See https://bugs.python.org/issue27906 for more details. for _ in range(backlog): try: conn, addr = sock.accept() if self._debug: logger.debug("%r got a new connection from %r: %r", server, addr, conn) conn.setblocking(False) except (BlockingIOError, InterruptedError, ConnectionAbortedError): # Early exit because the socket accept buffer is empty. return None except OSError as exc: # There's nowhere to send the error, so just log it. if exc.errno in (errno.EMFILE, errno.ENFILE, errno.ENOBUFS, errno.ENOMEM): # Some platforms (e.g. Linux keep reporting the FD as # ready, so we remove the read handler temporarily. # We'll try again in a while. self.call_exception_handler({ 'message': 'socket.accept() out of system resource', 'exception': exc, 'socket': trsock.TransportSocket(sock), }) self._remove_reader(sock.fileno()) self.call_later(constants.ACCEPT_RETRY_DELAY, self._start_serving, protocol_factory, sock, sslcontext, server, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) else: raise # The event loop will catch, log and ignore it. else: extra = {'peername': addr} accept = self._accept_connection2( protocol_factory, conn, extra, sslcontext, server, ssl_handshake_timeout, ssl_shutdown_timeout) self.create_task(accept) async def _accept_connection2( self, protocol_factory, conn, extra, sslcontext=None, server=None, ssl_handshake_timeout=constants.SSL_HANDSHAKE_TIMEOUT, ssl_shutdown_timeout=constants.SSL_SHUTDOWN_TIMEOUT): protocol = None transport = None try: protocol = protocol_factory() waiter = self.create_future() if sslcontext: transport = self._make_ssl_transport( conn, protocol, sslcontext, waiter=waiter, server_side=True, extra=extra, server=server, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: transport = self._make_socket_transport( conn, protocol, waiter=waiter, extra=extra, server=server) try: await waiter except BaseException: transport.close() # gh-109534: When an exception is raised by the SSLProtocol object the # exception set in this future can keep the protocol object alive and # cause a reference cycle. waiter = None raise # It's now up to the protocol to handle the connection. except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if self._debug: context = { 'message': 'Error on transport creation for incoming connection', 'exception': exc, } if protocol is not None: context['protocol'] = protocol if transport is not None: context['transport'] = transport self.call_exception_handler(context) def _ensure_fd_no_transport(self, fd): fileno = fd if not isinstance(fileno, int): try: fileno = int(fileno.fileno()) except (AttributeError, TypeError, ValueError): # This code matches selectors._fileobj_to_fd function. raise ValueError(f"Invalid file object: {fd!r}") from None try: transport = self._transports[fileno] except KeyError: pass else: if not transport.is_closing(): raise RuntimeError( f'File descriptor {fd!r} is used by transport ' f'{transport!r}') def _add_reader(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self, None) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_READ, (handle, None)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_READ, (handle, writer)) if reader is not None: reader.cancel() return handle def _remove_reader(self, fd): if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data mask &= ~selectors.EVENT_READ if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (None, writer)) if reader is not None: reader.cancel() return True else: return False def _add_writer(self, fd, callback, *args): self._check_closed() handle = events.Handle(callback, args, self, None) try: key = self._selector.get_key(fd) except KeyError: self._selector.register(fd, selectors.EVENT_WRITE, (None, handle)) else: mask, (reader, writer) = key.events, key.data self._selector.modify(fd, mask | selectors.EVENT_WRITE, (reader, handle)) if writer is not None: writer.cancel() return handle def _remove_writer(self, fd): """Remove a writer callback.""" if self.is_closed(): return False try: key = self._selector.get_key(fd) except KeyError: return False else: mask, (reader, writer) = key.events, key.data # Remove both writer and connector. mask &= ~selectors.EVENT_WRITE if not mask: self._selector.unregister(fd) else: self._selector.modify(fd, mask, (reader, None)) if writer is not None: writer.cancel() return True else: return False def add_reader(self, fd, callback, *args): """Add a reader callback.""" self._ensure_fd_no_transport(fd) self._add_reader(fd, callback, *args) def remove_reader(self, fd): """Remove a reader callback.""" self._ensure_fd_no_transport(fd) return self._remove_reader(fd) def add_writer(self, fd, callback, *args): """Add a writer callback..""" self._ensure_fd_no_transport(fd) self._add_writer(fd, callback, *args) def remove_writer(self, fd): """Remove a writer callback.""" self._ensure_fd_no_transport(fd) return self._remove_writer(fd) async def sock_recv(self, sock, n): """Receive 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. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recv(n) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recv, fut, sock, n) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_read_done(self, fd, fut, handle=None): if handle is None or not handle.cancelled(): self.remove_reader(fd) def _sock_recv(self, fut, sock, n): # _sock_recv() can add itself as an I/O callback if the operation can't # be done immediately. Don't use it directly, call sock_recv(). if fut.done(): return try: data = sock.recv(n) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(data) async def sock_recv_into(self, sock, buf): """Receive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recv_into(buf) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recv_into, fut, sock, buf) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recv_into(self, fut, sock, buf): # _sock_recv_into() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recv_into(). if fut.done(): return try: nbytes = sock.recv_into(buf) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(nbytes) async def sock_recvfrom(self, sock, bufsize): """Receive 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. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.recvfrom(bufsize) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recvfrom, fut, sock, bufsize) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recvfrom(self, fut, sock, bufsize): # _sock_recvfrom() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recvfrom(). if fut.done(): return try: result = sock.recvfrom(bufsize) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(result) async def sock_recvfrom_into(self, sock, buf, nbytes=0): """Receive 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). """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") if not nbytes: nbytes = len(buf) try: return sock.recvfrom_into(buf, nbytes) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_recvfrom_into, fut, sock, buf, nbytes) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) return await fut def _sock_recvfrom_into(self, fut, sock, buf, bufsize): # _sock_recv_into() can add itself as an I/O callback if the operation # can't be done immediately. Don't use it directly, call # sock_recv_into(). if fut.done(): return try: result = sock.recvfrom_into(buf, bufsize) except (BlockingIOError, InterruptedError): return # try again next time except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(result) async def sock_sendall(self, sock, data): """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. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: n = sock.send(data) except (BlockingIOError, InterruptedError): n = 0 if n == len(data): # all data sent return fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) # use a trick with a list in closure to store a mutable state handle = self._add_writer(fd, self._sock_sendall, fut, sock, memoryview(data), [n]) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) return await fut def _sock_sendall(self, fut, sock, view, pos): if fut.done(): # Future cancellation can be scheduled on previous loop iteration return start = pos[0] try: n = sock.send(view[start:]) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) return start += n if start == len(view): fut.set_result(None) else: pos[0] = start async def sock_sendto(self, sock, data, address): """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. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") try: return sock.sendto(data, address) except (BlockingIOError, InterruptedError): pass fut = self.create_future() fd = sock.fileno() self._ensure_fd_no_transport(fd) # use a trick with a list in closure to store a mutable state handle = self._add_writer(fd, self._sock_sendto, fut, sock, data, address) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) return await fut def _sock_sendto(self, fut, sock, data, address): if fut.done(): # Future cancellation can be scheduled on previous loop iteration return try: n = sock.sendto(data, 0, address) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(n) async def sock_connect(self, sock, address): """Connect to a remote socket at address. This method is a coroutine. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") if sock.family == socket.AF_INET or ( base_events._HAS_IPv6 and sock.family == socket.AF_INET6): resolved = await self._ensure_resolved( address, family=sock.family, type=sock.type, proto=sock.proto, loop=self, ) _, _, _, _, address = resolved[0] fut = self.create_future() self._sock_connect(fut, sock, address) try: return await fut finally: # Needed to break cycles when an exception occurs. fut = None def _sock_connect(self, fut, sock, address): fd = sock.fileno() try: sock.connect(address) except (BlockingIOError, InterruptedError): # Issue #23618: When the C function connect() fails with EINTR, the # connection runs in background. We have to wait until the socket # becomes writable to be notified when the connection succeed or # fails. self._ensure_fd_no_transport(fd) handle = self._add_writer( fd, self._sock_connect_cb, fut, sock, address) fut.add_done_callback( functools.partial(self._sock_write_done, fd, handle=handle)) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(None) finally: fut = None def _sock_write_done(self, fd, fut, handle=None): if handle is None or not handle.cancelled(): self.remove_writer(fd) def _sock_connect_cb(self, fut, sock, address): if fut.done(): return try: err = sock.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR) if err != 0: # Jump to any except clause below. raise OSError(err, f'Connect call failed {address}') except (BlockingIOError, InterruptedError): # socket is still registered, the callback will be retried later pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result(None) finally: fut = None async def sock_accept(self, sock): """Accept 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. """ base_events._check_ssl_socket(sock) if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") fut = self.create_future() self._sock_accept(fut, sock) return await fut def _sock_accept(self, fut, sock): fd = sock.fileno() try: conn, address = sock.accept() conn.setblocking(False) except (BlockingIOError, InterruptedError): self._ensure_fd_no_transport(fd) handle = self._add_reader(fd, self._sock_accept, fut, sock) fut.add_done_callback( functools.partial(self._sock_read_done, fd, handle=handle)) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: fut.set_exception(exc) else: fut.set_result((conn, address)) async def _sendfile_native(self, transp, file, offset, count): del self._transports[transp._sock_fd] resume_reading = transp.is_reading() transp.pause_reading() await transp._make_empty_waiter() try: return await self.sock_sendfile(transp._sock, file, offset, count, fallback=False) finally: transp._reset_empty_waiter() if resume_reading: transp.resume_reading() self._transports[transp._sock_fd] = transp def _process_events(self, event_list): for key, mask in event_list: fileobj, (reader, writer) = key.fileobj, key.data if mask & selectors.EVENT_READ and reader is not None: if reader._cancelled: self._remove_reader(fileobj) else: self._add_callback(reader) if mask & selectors.EVENT_WRITE and writer is not None: if writer._cancelled: self._remove_writer(fileobj) else: self._add_callback(writer) def _stop_serving(self, sock): self._remove_reader(sock.fileno()) sock.close() class _SelectorTransport(transports._FlowControlMixin, transports.Transport): max_size = 256 * 1024 # Buffer size passed to recv(). # Attribute used in the destructor: it must be set even if the constructor # is not called (see _SelectorSslTransport which may start by raising an # exception) _sock = None def __init__(self, loop, sock, protocol, extra=None, server=None): super().__init__(extra, loop) self._extra['socket'] = trsock.TransportSocket(sock) try: self._extra['sockname'] = sock.getsockname() except OSError: self._extra['sockname'] = None if 'peername' not in self._extra: try: self._extra['peername'] = sock.getpeername() except socket.error: self._extra['peername'] = None self._sock = sock self._sock_fd = sock.fileno() self._protocol_connected = False self.set_protocol(protocol) self._server = server self._buffer = collections.deque() self._conn_lost = 0 # Set when call to connection_lost scheduled. self._closing = False # Set when close() called. self._paused = False # Set when pause_reading() called if self._server is not None: self._server._attach() loop._transports[self._sock_fd] = self def __repr__(self): info = [self.__class__.__name__] if self._sock is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._sock_fd}') # test if the transport was closed if self._loop is not None and not self._loop.is_closed(): polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_READ) if polling: info.append('read=polling') else: info.append('read=idle') polling = _test_selector_event(self._loop._selector, self._sock_fd, selectors.EVENT_WRITE) if polling: state = 'polling' else: state = 'idle' bufsize = self.get_write_buffer_size() info.append(f'write=<{state}, bufsize={bufsize}>') return '<{}>'.format(' '.join(info)) def abort(self): self._force_close(None) def set_protocol(self, protocol): self._protocol = protocol self._protocol_connected = True def get_protocol(self): return self._protocol def is_closing(self): return self._closing def is_reading(self): return not self.is_closing() and not self._paused def pause_reading(self): if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._sock_fd) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False self._add_reader(self._sock_fd, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def close(self): if self._closing: return self._closing = True self._loop._remove_reader(self._sock_fd) if not self._buffer: self._conn_lost += 1 self._loop._remove_writer(self._sock_fd) self._loop.call_soon(self._call_connection_lost, None) def __del__(self, _warn=warnings.warn): if self._sock is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._sock.close() def _fatal_error(self, exc, message='Fatal error on transport'): # Should be called from exception handler only. if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._force_close(exc) def _force_close(self, exc): if self._conn_lost: return if self._buffer: self._buffer.clear() self._loop._remove_writer(self._sock_fd) if not self._closing: self._closing = True self._loop._remove_reader(self._sock_fd) self._conn_lost += 1 self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: if self._protocol_connected: self._protocol.connection_lost(exc) finally: self._sock.close() self._sock = None self._protocol = None self._loop = None server = self._server if server is not None: server._detach() self._server = None def get_write_buffer_size(self): return sum(map(len, self._buffer)) def _add_reader(self, fd, callback, *args): if not self.is_reading(): return self._loop._add_reader(fd, callback, *args) class _SelectorSocketTransport(_SelectorTransport): _start_tls_compatible = True _sendfile_compatible = constants._SendfileMode.TRY_NATIVE def __init__(self, loop, sock, protocol, waiter=None, extra=None, server=None): self._read_ready_cb = None super().__init__(loop, sock, protocol, extra, server) self._eof = False self._empty_waiter = None if _HAS_SENDMSG: self._write_ready = self._write_sendmsg else: self._write_ready = self._write_send # Disable the Nagle algorithm -- small writes will be # sent without waiting for the TCP ACK. This generally # decreases the latency (in some cases significantly.) base_events._set_nodelay(self._sock) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def set_protocol(self, protocol): if isinstance(protocol, protocols.BufferedProtocol): self._read_ready_cb = self._read_ready__get_buffer else: self._read_ready_cb = self._read_ready__data_received super().set_protocol(protocol) def _read_ready(self): self._read_ready_cb() def _read_ready__get_buffer(self): if self._conn_lost: return try: buf = self._protocol.get_buffer(-1) if not len(buf): raise RuntimeError('get_buffer() returned an empty buffer') except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.get_buffer() call failed.') return try: nbytes = self._sock.recv_into(buf) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on socket transport') return if not nbytes: self._read_ready__on_eof() return try: self._protocol.buffer_updated(nbytes) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.buffer_updated() call failed.') def _read_ready__data_received(self): if self._conn_lost: return try: data = self._sock.recv(self.max_size) except (BlockingIOError, InterruptedError): return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on socket transport') return if not data: self._read_ready__on_eof() return try: self._protocol.data_received(data) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.data_received() call failed.') def _read_ready__on_eof(self): if self._loop.get_debug(): logger.debug("%r received EOF", self) try: keep_open = self._protocol.eof_received() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal error: protocol.eof_received() call failed.') return if keep_open: # We're keeping the connection open so the # protocol can write more, but we still can't # receive more, so remove the reader callback. self._loop._remove_reader(self._sock_fd) else: self.close() def write(self, data): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f'data argument must be a bytes-like object, ' f'not {type(data).__name__!r}') if self._eof: raise RuntimeError('Cannot call write() after write_eof()') if self._empty_waiter is not None: raise RuntimeError('unable to write; sendfile is in progress') if not data: return if self._conn_lost: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Optimization: try to send now. try: n = self._sock.send(data) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal write error on socket transport') return else: data = memoryview(data)[n:] if not data: return # Not all was written; register write handler. self._loop._add_writer(self._sock_fd, self._write_ready) # Add it to the buffer. self._buffer.append(data) self._maybe_pause_protocol() def _get_sendmsg_buffer(self): return itertools.islice(self._buffer, SC_IOV_MAX) def _write_sendmsg(self): assert self._buffer, 'Data should not be empty' if self._conn_lost: return try: nbytes = self._sock.sendmsg(self._get_sendmsg_buffer()) self._adjust_leftover_buffer(nbytes) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on socket transport') if self._empty_waiter is not None: self._empty_waiter.set_exception(exc) else: self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._empty_waiter is not None: self._empty_waiter.set_result(None) if self._closing: self._call_connection_lost(None) elif self._eof: self._sock.shutdown(socket.SHUT_WR) def _adjust_leftover_buffer(self, nbytes: int) -> None: buffer = self._buffer while nbytes: b = buffer.popleft() b_len = len(b) if b_len <= nbytes: nbytes -= b_len else: buffer.appendleft(b[nbytes:]) break def _write_send(self): assert self._buffer, 'Data should not be empty' if self._conn_lost: return try: buffer = self._buffer.popleft() n = self._sock.send(buffer) if n != len(buffer): # Not all data was written self._buffer.appendleft(buffer[n:]) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._loop._remove_writer(self._sock_fd) self._buffer.clear() self._fatal_error(exc, 'Fatal write error on socket transport') if self._empty_waiter is not None: self._empty_waiter.set_exception(exc) else: self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._empty_waiter is not None: self._empty_waiter.set_result(None) if self._closing: self._call_connection_lost(None) elif self._eof: self._sock.shutdown(socket.SHUT_WR) def write_eof(self): if self._closing or self._eof: return self._eof = True if not self._buffer: self._sock.shutdown(socket.SHUT_WR) def writelines(self, list_of_data): if self._eof: raise RuntimeError('Cannot call writelines() after write_eof()') if self._empty_waiter is not None: raise RuntimeError('unable to writelines; sendfile is in progress') if not list_of_data: return self._buffer.extend([memoryview(data) for data in list_of_data]) self._write_ready() # If the entire buffer couldn't be written, register a write handler if self._buffer: self._loop._add_writer(self._sock_fd, self._write_ready) self._maybe_pause_protocol() def can_write_eof(self): return True def _call_connection_lost(self, exc): try: super()._call_connection_lost(exc) finally: self._write_ready = None if self._empty_waiter is not None: self._empty_waiter.set_exception( ConnectionError("Connection is closed by peer")) def _make_empty_waiter(self): if self._empty_waiter is not None: raise RuntimeError("Empty waiter is already set") self._empty_waiter = self._loop.create_future() if not self._buffer: self._empty_waiter.set_result(None) return self._empty_waiter def _reset_empty_waiter(self): self._empty_waiter = None def close(self): self._read_ready_cb = None super().close() class _SelectorDatagramTransport(_SelectorTransport, transports.DatagramTransport): _buffer_factory = collections.deque def __init__(self, loop, sock, protocol, address=None, waiter=None, extra=None): super().__init__(loop, sock, protocol, extra) self._address = address self._buffer_size = 0 self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._sock_fd, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def get_write_buffer_size(self): return self._buffer_size def _read_ready(self): if self._conn_lost: return try: data, addr = self._sock.recvfrom(self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._protocol.error_received(exc) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error(exc, 'Fatal read error on datagram transport') else: self._protocol.datagram_received(data, addr) def sendto(self, data, addr=None): if not isinstance(data, (bytes, bytearray, memoryview)): raise TypeError(f'data argument must be a bytes-like object, ' f'not {type(data).__name__!r}') if not data: return if self._address: if addr not in (None, self._address): raise ValueError( f'Invalid address: must be None or {self._address}') addr = self._address if self._conn_lost and self._address: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('socket.send() raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: if self._extra['peername']: self._sock.send(data) else: self._sock.sendto(data, addr) return except (BlockingIOError, InterruptedError): self._loop._add_writer(self._sock_fd, self._sendto_ready) except OSError as exc: self._protocol.error_received(exc) return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal write error on datagram transport') return # Ensure that what we buffer is immutable. self._buffer.append((bytes(data), addr)) self._buffer_size += len(data) self._maybe_pause_protocol() def _sendto_ready(self): while self._buffer: data, addr = self._buffer.popleft() self._buffer_size -= len(data) try: if self._extra['peername']: self._sock.send(data) else: self._sock.sendto(data, addr) except (BlockingIOError, InterruptedError): self._buffer.appendleft((data, addr)) # Try again later. self._buffer_size += len(data) break except OSError as exc: self._protocol.error_received(exc) return except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._fatal_error( exc, 'Fatal write error on datagram transport') return self._maybe_resume_protocol() # May append to buffer. if not self._buffer: self._loop._remove_writer(self._sock_fd) if self._closing: self._call_connection_lost(None) timeouts.py000064400000012311152343231170006766 0ustar00import enum from types import TracebackType from typing import final, Optional, Type from . import events from . import exceptions from . import tasks __all__ = ( "Timeout", "timeout", "timeout_at", ) class _State(enum.Enum): CREATED = "created" ENTERED = "active" EXPIRING = "expiring" EXPIRED = "expired" EXITED = "finished" @final class Timeout: """Asynchronous context manager for cancelling overdue coroutines. Use `timeout()` or `timeout_at()` rather than instantiating this class directly. """ def __init__(self, when: Optional[float]) -> None: """Schedule a timeout that will trigger at a given loop time. - If `when` is `None`, the timeout will never trigger. - If `when < loop.time()`, the timeout will trigger on the next iteration of the event loop. """ self._state = _State.CREATED self._timeout_handler: Optional[events.TimerHandle] = None self._task: Optional[tasks.Task] = None self._when = when def when(self) -> Optional[float]: """Return the current deadline.""" return self._when def reschedule(self, when: Optional[float]) -> None: """Reschedule the timeout.""" if self._state is not _State.ENTERED: if self._state is _State.CREATED: raise RuntimeError("Timeout has not been entered") raise RuntimeError( f"Cannot change state of {self._state.value} Timeout", ) self._when = when if self._timeout_handler is not None: self._timeout_handler.cancel() if when is None: self._timeout_handler = None else: loop = events.get_running_loop() if when <= loop.time(): self._timeout_handler = loop.call_soon(self._on_timeout) else: self._timeout_handler = loop.call_at(when, self._on_timeout) def expired(self) -> bool: """Is timeout expired during execution?""" return self._state in (_State.EXPIRING, _State.EXPIRED) def __repr__(self) -> str: info = [''] if self._state is _State.ENTERED: when = round(self._when, 3) if self._when is not None else None info.append(f"when={when}") info_str = ' '.join(info) return f"" async def __aenter__(self) -> "Timeout": if self._state is not _State.CREATED: raise RuntimeError("Timeout has already been entered") task = tasks.current_task() if task is None: raise RuntimeError("Timeout should be used inside a task") self._state = _State.ENTERED self._task = task self._cancelling = self._task.cancelling() self.reschedule(self._when) return self async def __aexit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType], ) -> Optional[bool]: assert self._state in (_State.ENTERED, _State.EXPIRING) if self._timeout_handler is not None: self._timeout_handler.cancel() self._timeout_handler = None if self._state is _State.EXPIRING: self._state = _State.EXPIRED if self._task.uncancel() <= self._cancelling and exc_type is exceptions.CancelledError: # Since there are no new cancel requests, we're # handling this. raise TimeoutError from exc_val elif self._state is _State.ENTERED: self._state = _State.EXITED return None def _on_timeout(self) -> None: assert self._state is _State.ENTERED self._task.cancel() self._state = _State.EXPIRING # drop the reference early self._timeout_handler = None def timeout(delay: Optional[float]) -> Timeout: """Timeout async context manager. Useful in cases when you want to apply timeout logic around block of code or in cases when asyncio.wait_for is not suitable. For example: >>> async with asyncio.timeout(10): # 10 seconds timeout ... await long_running_task() delay - value in seconds or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. """ loop = events.get_running_loop() return Timeout(loop.time() + delay if delay is not None else None) def timeout_at(when: Optional[float]) -> Timeout: """Schedule the timeout at absolute time. Like timeout() but argument gives absolute time in the same clock system as loop.time(). Please note: it is not POSIX time but a time with undefined starting base, e.g. the time of the system power on. >>> async with asyncio.timeout_at(loop.time() + 10): ... await long_running_task() when - a deadline when timeout occurs or None to disable timeout logic long_running_task() is interrupted by raising asyncio.CancelledError, the top-most affected timeout() context manager converts CancelledError into TimeoutError. """ return Timeout(when) base_events.py000064400000231347152343231170007427 0ustar00"""Base 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. """ import collections import collections.abc import concurrent.futures import errno import heapq import itertools import os import socket import stat import subprocess import threading import time import traceback import sys import warnings import weakref try: import ssl except ImportError: # pragma: no cover ssl = None from . import constants from . import coroutines from . import events from . import exceptions from . import futures from . import protocols from . import sslproto from . import staggered from . import tasks from . import timeouts from . import transports from . import trsock from .log import logger __all__ = 'BaseEventLoop','Server', # Minimum number of _scheduled timer handles before cleanup of # cancelled handles is performed. _MIN_SCHEDULED_TIMER_HANDLES = 100 # Minimum fraction of _scheduled timer handles that are cancelled # before cleanup of cancelled handles is performed. _MIN_CANCELLED_TIMER_HANDLES_FRACTION = 0.5 _HAS_IPv6 = hasattr(socket, 'AF_INET6') # Maximum timeout passed to select to avoid OS limitations MAXIMUM_SELECT_TIMEOUT = 24 * 3600 def _format_handle(handle): cb = handle._callback if isinstance(getattr(cb, '__self__', None), tasks.Task): # format the task return repr(cb.__self__) else: return str(handle) def _format_pipe(fd): if fd == subprocess.PIPE: return '' elif fd == subprocess.STDOUT: return '' else: return repr(fd) def _set_reuseport(sock): if not hasattr(socket, 'SO_REUSEPORT'): raise ValueError('reuse_port not supported by socket module') else: try: sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1) except OSError: raise ValueError('reuse_port not supported by socket module, ' 'SO_REUSEPORT defined but not implemented.') def _ipaddr_info(host, port, family, type, proto, flowinfo=0, scopeid=0): # Try to skip getaddrinfo if "host" is already an IP. Users might have # handled name resolution in their own code and pass in resolved IPs. if not hasattr(socket, 'inet_pton'): return if proto not in {0, socket.IPPROTO_TCP, socket.IPPROTO_UDP} or \ host is None: return None if type == socket.SOCK_STREAM: proto = socket.IPPROTO_TCP elif type == socket.SOCK_DGRAM: proto = socket.IPPROTO_UDP else: return None if port is None: port = 0 elif isinstance(port, bytes) and port == b'': port = 0 elif isinstance(port, str) and port == '': port = 0 else: # If port's a service name like "http", don't skip getaddrinfo. try: port = int(port) except (TypeError, ValueError): return None if family == socket.AF_UNSPEC: afs = [socket.AF_INET] if _HAS_IPv6: afs.append(socket.AF_INET6) else: afs = [family] if isinstance(host, bytes): host = host.decode('idna') if '%' in host: # Linux's inet_pton doesn't accept an IPv6 zone index after host, # like '::1%lo0'. return None for af in afs: try: socket.inet_pton(af, host) # The host has already been resolved. if _HAS_IPv6 and af == socket.AF_INET6: return af, type, proto, '', (host, port, flowinfo, scopeid) else: return af, type, proto, '', (host, port) except OSError: pass # "host" is not an IP address. return None def _interleave_addrinfos(addrinfos, first_address_family_count=1): """Interleave list of addrinfo tuples by family.""" # Group addresses by family addrinfos_by_family = collections.OrderedDict() for addr in addrinfos: family = addr[0] if family not in addrinfos_by_family: addrinfos_by_family[family] = [] addrinfos_by_family[family].append(addr) addrinfos_lists = list(addrinfos_by_family.values()) reordered = [] if first_address_family_count > 1: reordered.extend(addrinfos_lists[0][:first_address_family_count - 1]) del addrinfos_lists[0][:first_address_family_count - 1] reordered.extend( a for a in itertools.chain.from_iterable( itertools.zip_longest(*addrinfos_lists) ) if a is not None) return reordered def _run_until_complete_cb(fut): if not fut.cancelled(): exc = fut.exception() if isinstance(exc, (SystemExit, KeyboardInterrupt)): # Issue #22429: run_forever() already finished, no need to # stop it. return futures._get_loop(fut).stop() if hasattr(socket, 'TCP_NODELAY'): def _set_nodelay(sock): if (sock.family in {socket.AF_INET, socket.AF_INET6} and sock.type == socket.SOCK_STREAM and sock.proto == socket.IPPROTO_TCP): sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) else: def _set_nodelay(sock): pass def _check_ssl_socket(sock): if ssl is not None and isinstance(sock, ssl.SSLSocket): raise TypeError("Socket cannot be of type SSLSocket") class _SendfileFallbackProtocol(protocols.Protocol): def __init__(self, transp): if not isinstance(transp, transports._FlowControlMixin): raise TypeError("transport should be _FlowControlMixin instance") self._transport = transp self._proto = transp.get_protocol() self._should_resume_reading = transp.is_reading() self._should_resume_writing = transp._protocol_paused transp.pause_reading() transp.set_protocol(self) if self._should_resume_writing: self._write_ready_fut = self._transport._loop.create_future() else: self._write_ready_fut = None async def drain(self): if self._transport.is_closing(): raise ConnectionError("Connection closed by peer") fut = self._write_ready_fut if fut is None: return await fut def connection_made(self, transport): raise RuntimeError("Invalid state: " "connection should have been established already.") def connection_lost(self, exc): if self._write_ready_fut is not None: # Never happens if peer disconnects after sending the whole content # Thus disconnection is always an exception from user perspective if exc is None: self._write_ready_fut.set_exception( ConnectionError("Connection is closed by peer")) else: self._write_ready_fut.set_exception(exc) self._proto.connection_lost(exc) def pause_writing(self): if self._write_ready_fut is not None: return self._write_ready_fut = self._transport._loop.create_future() def resume_writing(self): if self._write_ready_fut is None: return self._write_ready_fut.set_result(False) self._write_ready_fut = None def data_received(self, data): raise RuntimeError("Invalid state: reading should be paused") def eof_received(self): raise RuntimeError("Invalid state: reading should be paused") async def restore(self): self._transport.set_protocol(self._proto) if self._should_resume_reading: self._transport.resume_reading() if self._write_ready_fut is not None: # Cancel the future. # Basically it has no effect because protocol is switched back, # no code should wait for it anymore. self._write_ready_fut.cancel() if self._should_resume_writing: self._proto.resume_writing() class Server(events.AbstractServer): def __init__(self, loop, sockets, protocol_factory, ssl_context, backlog, ssl_handshake_timeout, ssl_shutdown_timeout=None): self._loop = loop self._sockets = sockets self._active_count = 0 self._waiters = [] self._protocol_factory = protocol_factory self._backlog = backlog self._ssl_context = ssl_context self._ssl_handshake_timeout = ssl_handshake_timeout self._ssl_shutdown_timeout = ssl_shutdown_timeout self._serving = False self._serving_forever_fut = None def __repr__(self): return f'<{self.__class__.__name__} sockets={self.sockets!r}>' def _attach(self): assert self._sockets is not None self._active_count += 1 def _detach(self): assert self._active_count > 0 self._active_count -= 1 if self._active_count == 0 and self._sockets is None: self._wakeup() def _wakeup(self): waiters = self._waiters self._waiters = None for waiter in waiters: if not waiter.done(): waiter.set_result(None) def _start_serving(self): if self._serving: return self._serving = True for sock in self._sockets: sock.listen(self._backlog) self._loop._start_serving( self._protocol_factory, sock, self._ssl_context, self, self._backlog, self._ssl_handshake_timeout, self._ssl_shutdown_timeout) def get_loop(self): return self._loop def is_serving(self): return self._serving @property def sockets(self): if self._sockets is None: return () return tuple(trsock.TransportSocket(s) for s in self._sockets) def close(self): sockets = self._sockets if sockets is None: return self._sockets = None for sock in sockets: self._loop._stop_serving(sock) self._serving = False if (self._serving_forever_fut is not None and not self._serving_forever_fut.done()): self._serving_forever_fut.cancel() self._serving_forever_fut = None if self._active_count == 0: self._wakeup() async def start_serving(self): self._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) async def serve_forever(self): if self._serving_forever_fut is not None: raise RuntimeError( f'server {self!r} is already being awaited on serve_forever()') if self._sockets is None: raise RuntimeError(f'server {self!r} is closed') self._start_serving() self._serving_forever_fut = self._loop.create_future() try: await self._serving_forever_fut except exceptions.CancelledError: try: self.close() await self.wait_closed() finally: raise finally: self._serving_forever_fut = None async def wait_closed(self): """Wait 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. """ # Waiters are unblocked by self._wakeup(), which is called # from two places: self.close() and self._detach(), but only # when both conditions have become true. To signal that this # has happened, self._wakeup() sets self._waiters to None. if self._waiters is None: return waiter = self._loop.create_future() self._waiters.append(waiter) await waiter class BaseEventLoop(events.AbstractEventLoop): def __init__(self): self._timer_cancelled_count = 0 self._closed = False self._stopping = False self._ready = collections.deque() self._scheduled = [] self._default_executor = None self._internal_fds = 0 # Identifier of the thread running the event loop, or None if the # event loop is not running self._thread_id = None self._clock_resolution = time.get_clock_info('monotonic').resolution self._exception_handler = None self.set_debug(coroutines._is_debug_mode()) # In debug mode, if the execution of a callback or a step of a task # exceed this duration in seconds, the slow callback/task is logged. self.slow_callback_duration = 0.1 self._current_handle = None self._task_factory = None self._coroutine_origin_tracking_enabled = False self._coroutine_origin_tracking_saved_depth = None # A weak set of all asynchronous generators that are # being iterated by the loop. self._asyncgens = weakref.WeakSet() # Set to True when `loop.shutdown_asyncgens` is called. self._asyncgens_shutdown_called = False # Set to True when `loop.shutdown_default_executor` is called. self._executor_shutdown_called = False def __repr__(self): return ( f'<{self.__class__.__name__} running={self.is_running()} ' f'closed={self.is_closed()} debug={self.get_debug()}>' ) def create_future(self): """Create a Future object attached to the loop.""" return futures.Future(loop=self) def create_task(self, coro, *, name=None, context=None): """Schedule a coroutine object. Return a task object. """ self._check_closed() if self._task_factory is None: task = tasks.Task(coro, loop=self, name=name, context=context) if task._source_traceback: del task._source_traceback[-1] else: if context is None: # Use legacy API if context is not needed task = self._task_factory(self, coro) else: task = self._task_factory(self, coro, context=context) tasks._set_task_name(task, name) try: return task finally: # gh-128552: prevent a refcycle of # task.exception().__traceback__->BaseEventLoop.create_task->task del task def set_task_factory(self, factory): """Set 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. """ if factory is not None and not callable(factory): raise TypeError('task factory must be a callable or None') self._task_factory = factory def get_task_factory(self): """Return a task factory, or None if the default one is in use.""" return self._task_factory def _make_socket_transport(self, sock, protocol, waiter=None, *, extra=None, server=None): """Create socket transport.""" raise NotImplementedError def _make_ssl_transport( self, rawsock, protocol, sslcontext, waiter=None, *, server_side=False, server_hostname=None, extra=None, server=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, call_connection_made=True): """Create SSL transport.""" raise NotImplementedError def _make_datagram_transport(self, sock, protocol, address=None, waiter=None, extra=None): """Create datagram transport.""" raise NotImplementedError def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create read pipe transport.""" raise NotImplementedError def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): """Create write pipe transport.""" raise NotImplementedError async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): """Create subprocess transport.""" raise NotImplementedError def _write_to_self(self): """Write a byte to self-pipe, to wake up the event loop. This may be called from a different thread. The subclass is responsible for implementing the self-pipe. """ raise NotImplementedError def _process_events(self, event_list): """Process selector events.""" raise NotImplementedError def _check_closed(self): if self._closed: raise RuntimeError('Event loop is closed') def _check_default_executor(self): if self._executor_shutdown_called: raise RuntimeError('Executor shutdown has been called') def _asyncgen_finalizer_hook(self, agen): self._asyncgens.discard(agen) if not self.is_closed(): self.call_soon_threadsafe(self.create_task, agen.aclose()) def _asyncgen_firstiter_hook(self, agen): if self._asyncgens_shutdown_called: warnings.warn( f"asynchronous generator {agen!r} was scheduled after " f"loop.shutdown_asyncgens() call", ResourceWarning, source=self) self._asyncgens.add(agen) async def shutdown_asyncgens(self): """Shutdown all active asynchronous generators.""" self._asyncgens_shutdown_called = True if not len(self._asyncgens): # If Python version is <3.6 or we don't have any asynchronous # generators alive. return closing_agens = list(self._asyncgens) self._asyncgens.clear() results = await tasks.gather( *[ag.aclose() for ag in closing_agens], return_exceptions=True) for result, agen in zip(results, closing_agens): if isinstance(result, Exception): self.call_exception_handler({ 'message': f'an error occurred during closing of ' f'asynchronous generator {agen!r}', 'exception': result, 'asyncgen': agen }) async def shutdown_default_executor(self, timeout=None): """Schedule the shutdown of the default executor. The timeout parameter specifies the amount of time the executor will be given to finish joining. The default value is None, which means that the executor will be given an unlimited amount of time. """ self._executor_shutdown_called = True if self._default_executor is None: return future = self.create_future() thread = threading.Thread(target=self._do_shutdown, args=(future,)) thread.start() try: async with timeouts.timeout(timeout): await future except TimeoutError: warnings.warn("The executor did not finishing joining " f"its threads within {timeout} seconds.", RuntimeWarning, stacklevel=2) self._default_executor.shutdown(wait=False) else: thread.join() def _do_shutdown(self, future): try: self._default_executor.shutdown(wait=True) if not self.is_closed(): self.call_soon_threadsafe(futures._set_result_unless_cancelled, future, None) except Exception as ex: if not self.is_closed() and not future.cancelled(): self.call_soon_threadsafe(future.set_exception, ex) def _check_running(self): if self.is_running(): raise RuntimeError('This event loop is already running') if events._get_running_loop() is not None: raise RuntimeError( 'Cannot run the event loop while another loop is running') def run_forever(self): """Run until stop() is called.""" self._check_closed() self._check_running() self._set_coroutine_origin_tracking(self._debug) old_agen_hooks = sys.get_asyncgen_hooks() try: self._thread_id = threading.get_ident() sys.set_asyncgen_hooks(firstiter=self._asyncgen_firstiter_hook, finalizer=self._asyncgen_finalizer_hook) events._set_running_loop(self) while True: self._run_once() if self._stopping: break finally: self._stopping = False self._thread_id = None events._set_running_loop(None) self._set_coroutine_origin_tracking(False) sys.set_asyncgen_hooks(*old_agen_hooks) def run_until_complete(self, future): """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. """ self._check_closed() self._check_running() new_task = not futures.isfuture(future) future = tasks.ensure_future(future, loop=self) if new_task: # An exception is raised if the future didn't complete, so there # is no need to log the "destroy pending task" message future._log_destroy_pending = False future.add_done_callback(_run_until_complete_cb) try: self.run_forever() except: if new_task and future.done() and not future.cancelled(): # The coroutine raised a BaseException. Consume the exception # to not log a warning, the caller doesn't have access to the # local task. future.exception() raise finally: future.remove_done_callback(_run_until_complete_cb) if not future.done(): raise RuntimeError('Event loop stopped before Future completed.') return future.result() def stop(self): """Stop running the event loop. Every callback already scheduled will still run. This simply informs run_forever to stop looping after a complete iteration. """ self._stopping = True def close(self): """Close 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. """ if self.is_running(): raise RuntimeError("Cannot close a running event loop") if self._closed: return if self._debug: logger.debug("Close %r", self) self._closed = True self._ready.clear() self._scheduled.clear() self._executor_shutdown_called = True executor = self._default_executor if executor is not None: self._default_executor = None executor.shutdown(wait=False) def is_closed(self): """Returns True if the event loop was closed.""" return self._closed def __del__(self, _warn=warnings.warn): if not self.is_closed(): _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self) if not self.is_running(): self.close() def is_running(self): """Returns True if the event loop is running.""" return (self._thread_id is not None) def time(self): """Return 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. """ return time.monotonic() def call_later(self, delay, callback, *args, context=None): """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. """ if delay is None: raise TypeError('delay must not be None') timer = self.call_at(self.time() + delay, callback, *args, context=context) if timer._source_traceback: del timer._source_traceback[-1] return timer def call_at(self, when, callback, *args, context=None): """Like call_later(), but uses an absolute time. Absolute time corresponds to the event loop's time() method. """ if when is None: raise TypeError("when cannot be None") self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_at') timer = events.TimerHandle(when, callback, args, self, context) if timer._source_traceback: del timer._source_traceback[-1] heapq.heappush(self._scheduled, timer) timer._scheduled = True return timer def call_soon(self, callback, *args, context=None): """Arrange 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. """ self._check_closed() if self._debug: self._check_thread() self._check_callback(callback, 'call_soon') handle = self._call_soon(callback, args, context) if handle._source_traceback: del handle._source_traceback[-1] return handle def _check_callback(self, callback, method): if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError( f"coroutines cannot be used with {method}()") if not callable(callback): raise TypeError( f'a callable object was expected by {method}(), ' f'got {callback!r}') def _call_soon(self, callback, args, context): handle = events.Handle(callback, args, self, context) if handle._source_traceback: del handle._source_traceback[-1] self._ready.append(handle) return handle def _check_thread(self): """Check 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. """ if self._thread_id is None: return thread_id = threading.get_ident() if thread_id != self._thread_id: raise RuntimeError( "Non-thread-safe operation invoked on an event loop other " "than the current one") def call_soon_threadsafe(self, callback, *args, context=None): """Like call_soon(), but thread-safe.""" self._check_closed() if self._debug: self._check_callback(callback, 'call_soon_threadsafe') handle = self._call_soon(callback, args, context) if handle._source_traceback: del handle._source_traceback[-1] self._write_to_self() return handle def run_in_executor(self, executor, func, *args): self._check_closed() if self._debug: self._check_callback(func, 'run_in_executor') if executor is None: executor = self._default_executor # Only check when the default executor is being used self._check_default_executor() if executor is None: executor = concurrent.futures.ThreadPoolExecutor( thread_name_prefix='asyncio' ) self._default_executor = executor return futures.wrap_future( executor.submit(func, *args), loop=self) def set_default_executor(self, executor): if not isinstance(executor, concurrent.futures.ThreadPoolExecutor): raise TypeError('executor must be ThreadPoolExecutor instance') self._default_executor = executor def _getaddrinfo_debug(self, host, port, family, type, proto, flags): msg = [f"{host}:{port!r}"] if family: msg.append(f'family={family!r}') if type: msg.append(f'type={type!r}') if proto: msg.append(f'proto={proto!r}') if flags: msg.append(f'flags={flags!r}') msg = ', '.join(msg) logger.debug('Get address info %s', msg) t0 = self.time() addrinfo = socket.getaddrinfo(host, port, family, type, proto, flags) dt = self.time() - t0 msg = f'Getting address info {msg} took {dt * 1e3:.3f}ms: {addrinfo!r}' if dt >= self.slow_callback_duration: logger.info(msg) else: logger.debug(msg) return addrinfo async def getaddrinfo(self, host, port, *, family=0, type=0, proto=0, flags=0): if self._debug: getaddr_func = self._getaddrinfo_debug else: getaddr_func = socket.getaddrinfo return await self.run_in_executor( None, getaddr_func, host, port, family, type, proto, flags) async def getnameinfo(self, sockaddr, flags=0): return await self.run_in_executor( None, socket.getnameinfo, sockaddr, flags) async def sock_sendfile(self, sock, file, offset=0, count=None, *, fallback=True): if self._debug and sock.gettimeout() != 0: raise ValueError("the socket must be non-blocking") _check_ssl_socket(sock) self._check_sendfile_params(sock, file, offset, count) try: return await self._sock_sendfile_native(sock, file, offset, count) except exceptions.SendfileNotAvailableError as exc: if not fallback: raise return await self._sock_sendfile_fallback(sock, file, offset, count) async def _sock_sendfile_native(self, sock, file, offset, count): # NB: sendfile syscall is not supported for SSL sockets and # non-mmap files even if sendfile is supported by OS raise exceptions.SendfileNotAvailableError( f"syscall sendfile is not available for socket {sock!r} " f"and file {file!r} combination") async def _sock_sendfile_fallback(self, sock, file, offset, count): if offset: file.seek(offset) blocksize = ( min(count, constants.SENDFILE_FALLBACK_READBUFFER_SIZE) if count else constants.SENDFILE_FALLBACK_READBUFFER_SIZE ) buf = bytearray(blocksize) total_sent = 0 try: while True: if count: blocksize = min(count - total_sent, blocksize) if blocksize <= 0: break view = memoryview(buf)[:blocksize] read = await self.run_in_executor(None, file.readinto, view) if not read: break # EOF await self.sock_sendall(sock, view[:read]) total_sent += read return total_sent finally: if total_sent > 0 and hasattr(file, 'seek'): file.seek(offset + total_sent) def _check_sendfile_params(self, sock, file, offset, count): if 'b' not in getattr(file, 'mode', 'b'): raise ValueError("file should be opened in binary mode") if not sock.type == socket.SOCK_STREAM: raise ValueError("only SOCK_STREAM type sockets are supported") if count is not None: if not isinstance(count, int): raise TypeError( "count must be a positive integer (got {!r})".format(count)) if count <= 0: raise ValueError( "count must be a positive integer (got {!r})".format(count)) if not isinstance(offset, int): raise TypeError( "offset must be a non-negative integer (got {!r})".format( offset)) if offset < 0: raise ValueError( "offset must be a non-negative integer (got {!r})".format( offset)) async def _connect_sock(self, exceptions, addr_info, local_addr_infos=None): """Create, bind and connect one socket.""" my_exceptions = [] exceptions.append(my_exceptions) family, type_, proto, _, address = addr_info sock = None try: sock = socket.socket(family=family, type=type_, proto=proto) sock.setblocking(False) if local_addr_infos is not None: for lfamily, _, _, _, laddr in local_addr_infos: # skip local addresses of different family if lfamily != family: continue try: sock.bind(laddr) break except OSError as exc: msg = ( f'error while attempting to bind on ' f'address {laddr!r}: {str(exc).lower()}' ) exc = OSError(exc.errno, msg) my_exceptions.append(exc) else: # all bind attempts failed if my_exceptions: raise my_exceptions.pop() else: raise OSError(f"no matching local address with {family=} found") await self.sock_connect(sock, address) return sock except OSError as exc: my_exceptions.append(exc) if sock is not None: sock.close() raise except: if sock is not None: sock.close() raise finally: exceptions = my_exceptions = None async def create_connection( self, protocol_factory, host=None, port=None, *, ssl=None, family=0, proto=0, flags=0, sock=None, local_addr=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, happy_eyeballs_delay=None, interleave=None, all_errors=False): """Connect to a TCP server. Create a streaming transport connection to a given internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. """ if server_hostname is not None and not ssl: raise ValueError('server_hostname is only meaningful with ssl') if server_hostname is None and ssl: # Use host as default for server_hostname. It is an error # if host is empty or not set, e.g. when an # already-connected socket was passed or when only a port # is given. To avoid this error, you can pass # server_hostname='' -- this will bypass the hostname # check. (This also means that if host is a numeric # IP/IPv6 address, we will attempt to verify that exact # address; this will probably fail, but it is possible to # create a certificate for a specific IP address, so we # don't judge it here.) if not host: raise ValueError('You must set server_hostname ' 'when using ssl without a host') server_hostname = host if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) if happy_eyeballs_delay is not None and interleave is None: # If using happy eyeballs, default to interleave addresses by family interleave = 1 if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') infos = await self._ensure_resolved( (host, port), family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo() returned empty list') if local_addr is not None: laddr_infos = await self._ensure_resolved( local_addr, family=family, type=socket.SOCK_STREAM, proto=proto, flags=flags, loop=self) if not laddr_infos: raise OSError('getaddrinfo() returned empty list') else: laddr_infos = None if interleave: infos = _interleave_addrinfos(infos, interleave) exceptions = [] if happy_eyeballs_delay is None: # not using happy eyeballs for addrinfo in infos: try: sock = await self._connect_sock( exceptions, addrinfo, laddr_infos) break except OSError: continue else: # using happy eyeballs sock = (await staggered.staggered_race( ( # can't use functools.partial as it keeps a reference # to exceptions lambda addrinfo=addrinfo: self._connect_sock( exceptions, addrinfo, laddr_infos ) for addrinfo in infos ), happy_eyeballs_delay, loop=self, ))[0] # can't use sock, _, _ as it keeks a reference to exceptions if sock is None: exceptions = [exc for sub in exceptions for exc in sub] try: if all_errors: raise ExceptionGroup("create_connection failed", exceptions) if len(exceptions) == 1: raise exceptions[0] else: # If they all have the same str(), raise one. model = str(exceptions[0]) if all(str(exc) == model for exc in exceptions): raise exceptions[0] # Raise a combined exception so the user can see all # the various error messages. raise OSError('Multiple exceptions: {}'.format( ', '.join(str(exc) for exc in exceptions))) finally: exceptions = None else: if sock is None: raise ValueError( 'host and port was not specified and no sock specified') if sock.type != socket.SOCK_STREAM: # We allow AF_INET, AF_INET6, AF_UNIX as long as they # are SOCK_STREAM. # We support passing AF_UNIX sockets even though we have # a dedicated API for that: create_unix_connection. # Disallowing AF_UNIX in this method, breaks backwards # compatibility. raise ValueError( f'A Stream Socket was expected, got {sock!r}') transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r connected to %s:%r: (%r, %r)", sock, host, port, transport, protocol) return transport, protocol async def _create_connection_transport( self, sock, protocol_factory, ssl, server_hostname, server_side=False, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): sock.setblocking(False) protocol = protocol_factory() waiter = self.create_future() if ssl: sslcontext = None if isinstance(ssl, bool) else ssl transport = self._make_ssl_transport( sock, protocol, sslcontext, waiter, server_side=server_side, server_hostname=server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) else: transport = self._make_socket_transport(sock, protocol, waiter) try: await waiter except: transport.close() raise return transport, protocol async def sendfile(self, transport, file, offset=0, count=None, *, fallback=True): """Send 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. """ if transport.is_closing(): raise RuntimeError("Transport is closing") mode = getattr(transport, '_sendfile_compatible', constants._SendfileMode.UNSUPPORTED) if mode is constants._SendfileMode.UNSUPPORTED: raise RuntimeError( f"sendfile is not supported for transport {transport!r}") if mode is constants._SendfileMode.TRY_NATIVE: try: return await self._sendfile_native(transport, file, offset, count) except exceptions.SendfileNotAvailableError as exc: if not fallback: raise if not fallback: raise RuntimeError( f"fallback is disabled and native sendfile is not " f"supported for transport {transport!r}") return await self._sendfile_fallback(transport, file, offset, count) async def _sendfile_native(self, transp, file, offset, count): raise exceptions.SendfileNotAvailableError( "sendfile syscall is not supported") async def _sendfile_fallback(self, transp, file, offset, count): if offset: file.seek(offset) blocksize = min(count, 16384) if count else 16384 buf = bytearray(blocksize) total_sent = 0 proto = _SendfileFallbackProtocol(transp) try: while True: if count: blocksize = min(count - total_sent, blocksize) if blocksize <= 0: return total_sent view = memoryview(buf)[:blocksize] read = await self.run_in_executor(None, file.readinto, view) if not read: return total_sent # EOF transp.write(view[:read]) await proto.drain() total_sent += read finally: if total_sent > 0 and hasattr(file, 'seek'): file.seek(offset + total_sent) await proto.restore() async def start_tls(self, transport, protocol, sslcontext, *, server_side=False, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): """Upgrade transport to TLS. Return a new transport that *protocol* should start using immediately. """ if ssl is None: raise RuntimeError('Python ssl module is not available') if not isinstance(sslcontext, ssl.SSLContext): raise TypeError( f'sslcontext is expected to be an instance of ssl.SSLContext, ' f'got {sslcontext!r}') if not getattr(transport, '_start_tls_compatible', False): raise TypeError( f'transport {transport!r} is not supported by start_tls()') waiter = self.create_future() ssl_protocol = sslproto.SSLProtocol( self, protocol, sslcontext, waiter, server_side, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout, call_connection_made=False) # Pause early so that "ssl_protocol.data_received()" doesn't # have a chance to get called before "ssl_protocol.connection_made()". transport.pause_reading() transport.set_protocol(ssl_protocol) conmade_cb = self.call_soon(ssl_protocol.connection_made, transport) resume_cb = self.call_soon(transport.resume_reading) try: await waiter except BaseException: transport.close() conmade_cb.cancel() resume_cb.cancel() raise return ssl_protocol._app_transport async def create_datagram_endpoint(self, protocol_factory, local_addr=None, remote_addr=None, *, family=0, proto=0, flags=0, reuse_port=None, allow_broadcast=None, sock=None): """Create datagram connection.""" if sock is not None: if sock.type == socket.SOCK_STREAM: raise ValueError( f'A datagram socket was expected, got {sock!r}') if (local_addr or remote_addr or family or proto or flags or reuse_port or allow_broadcast): # show the problematic kwargs in exception msg opts = dict(local_addr=local_addr, remote_addr=remote_addr, family=family, proto=proto, flags=flags, reuse_port=reuse_port, allow_broadcast=allow_broadcast) problems = ', '.join(f'{k}={v}' for k, v in opts.items() if v) raise ValueError( f'socket modifier keyword arguments can not be used ' f'when sock is specified. ({problems})') sock.setblocking(False) r_addr = None else: if not (local_addr or remote_addr): if family == 0: raise ValueError('unexpected address family') addr_pairs_info = (((family, proto), (None, None)),) elif hasattr(socket, 'AF_UNIX') and family == socket.AF_UNIX: for addr in (local_addr, remote_addr): if addr is not None and not isinstance(addr, str): raise TypeError('string is expected') if local_addr and local_addr[0] not in (0, '\x00'): try: if stat.S_ISSOCK(os.stat(local_addr).st_mode): os.remove(local_addr) except FileNotFoundError: pass except OSError as err: # Directory may have permissions only to create socket. logger.error('Unable to check or remove stale UNIX ' 'socket %r: %r', local_addr, err) addr_pairs_info = (((family, proto), (local_addr, remote_addr)), ) else: # join address by (family, protocol) addr_infos = {} # Using order preserving dict for idx, addr in ((0, local_addr), (1, remote_addr)): if addr is not None: if not (isinstance(addr, tuple) and len(addr) == 2): raise TypeError('2-tuple is expected') infos = await self._ensure_resolved( addr, family=family, type=socket.SOCK_DGRAM, proto=proto, flags=flags, loop=self) if not infos: raise OSError('getaddrinfo() returned empty list') for fam, _, pro, _, address in infos: key = (fam, pro) if key not in addr_infos: addr_infos[key] = [None, None] addr_infos[key][idx] = address # each addr has to have info for each (family, proto) pair addr_pairs_info = [ (key, addr_pair) for key, addr_pair in addr_infos.items() if not ((local_addr and addr_pair[0] is None) or (remote_addr and addr_pair[1] is None))] if not addr_pairs_info: raise ValueError('can not get address information') exceptions = [] for ((family, proto), (local_address, remote_address)) in addr_pairs_info: sock = None r_addr = None try: sock = socket.socket( family=family, type=socket.SOCK_DGRAM, proto=proto) if reuse_port: _set_reuseport(sock) if allow_broadcast: sock.setsockopt( socket.SOL_SOCKET, socket.SO_BROADCAST, 1) sock.setblocking(False) if local_addr: sock.bind(local_address) if remote_addr: if not allow_broadcast: await self.sock_connect(sock, remote_address) r_addr = remote_address except OSError as exc: if sock is not None: sock.close() exceptions.append(exc) except: if sock is not None: sock.close() raise else: break else: raise exceptions[0] protocol = protocol_factory() waiter = self.create_future() transport = self._make_datagram_transport( sock, protocol, r_addr, waiter) if self._debug: if local_addr: logger.info("Datagram endpoint local_addr=%r remote_addr=%r " "created: (%r, %r)", local_addr, remote_addr, transport, protocol) else: logger.debug("Datagram endpoint remote_addr=%r created: " "(%r, %r)", remote_addr, transport, protocol) try: await waiter except: transport.close() raise return transport, protocol async def _ensure_resolved(self, address, *, family=0, type=socket.SOCK_STREAM, proto=0, flags=0, loop): host, port = address[:2] info = _ipaddr_info(host, port, family, type, proto, *address[2:]) if info is not None: # "host" is already a resolved IP. return [info] else: return await loop.getaddrinfo(host, port, family=family, type=type, proto=proto, flags=flags) async def _create_server_getaddrinfo(self, host, port, family, flags): infos = await self._ensure_resolved((host, port), family=family, type=socket.SOCK_STREAM, flags=flags, loop=self) if not infos: raise OSError(f'getaddrinfo({host!r}) returned empty list') return infos async def create_server( self, protocol_factory, host=None, port=None, *, family=socket.AF_UNSPEC, flags=socket.AI_PASSIVE, sock=None, backlog=100, ssl=None, reuse_address=None, reuse_port=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): """Create 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. """ if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if ssl_handshake_timeout is not None and ssl is None: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and ssl is None: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) if host is not None or port is not None: if sock is not None: raise ValueError( 'host/port and sock can not be specified at the same time') if reuse_address is None: reuse_address = os.name == "posix" and sys.platform != "cygwin" sockets = [] if host == '': hosts = [None] elif (isinstance(host, str) or not isinstance(host, collections.abc.Iterable)): hosts = [host] else: hosts = host fs = [self._create_server_getaddrinfo(host, port, family=family, flags=flags) for host in hosts] infos = await tasks.gather(*fs) infos = set(itertools.chain.from_iterable(infos)) completed = False try: for res in infos: af, socktype, proto, canonname, sa = res try: sock = socket.socket(af, socktype, proto) except socket.error: # Assume it's a bad family/type/protocol combination. if self._debug: logger.warning('create_server() failed to create ' 'socket.socket(%r, %r, %r)', af, socktype, proto, exc_info=True) continue sockets.append(sock) if reuse_address: sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, True) # Since Linux 6.12.9, SO_REUSEPORT is not allowed # on other address families than AF_INET/AF_INET6. if reuse_port and af in (socket.AF_INET, socket.AF_INET6): _set_reuseport(sock) # Disable IPv4/IPv6 dual stack support (enabled by # default on Linux) which makes a single socket # listen on both address families. if (_HAS_IPv6 and af == socket.AF_INET6 and hasattr(socket, 'IPPROTO_IPV6')): sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, True) try: sock.bind(sa) except OSError as err: msg = ('error while attempting ' 'to bind on address %r: %s' % (sa, str(err).lower())) if err.errno == errno.EADDRNOTAVAIL: # Assume the family is not enabled (bpo-30945) sockets.pop() sock.close() if self._debug: logger.warning(msg) continue raise OSError(err.errno, msg) from None if not sockets: raise OSError('could not bind on any address out of %r' % ([info[4] for info in infos],)) completed = True finally: if not completed: for sock in sockets: sock.close() else: if sock is None: raise ValueError('Neither host/port nor sock were specified') if sock.type != socket.SOCK_STREAM: raise ValueError(f'A Stream Socket was expected, got {sock!r}') sockets = [sock] for sock in sockets: sock.setblocking(False) server = Server(self, sockets, protocol_factory, ssl, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) if start_serving: server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) if self._debug: logger.info("%r is serving", server) return server async def connect_accepted_socket( self, protocol_factory, sock, *, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): if sock.type != socket.SOCK_STREAM: raise ValueError(f'A Stream Socket was expected, got {sock!r}') if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if sock is not None: _check_ssl_socket(sock) transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, '', server_side=True, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) if self._debug: # Get the socket from the transport because SSL transport closes # the old socket and creates a new SSL socket sock = transport.get_extra_info('socket') logger.debug("%r handled: (%r, %r)", sock, transport, protocol) return transport, protocol async def connect_read_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_read_pipe_transport(pipe, protocol, waiter) try: await waiter except: transport.close() raise if self._debug: logger.debug('Read pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol async def connect_write_pipe(self, protocol_factory, pipe): protocol = protocol_factory() waiter = self.create_future() transport = self._make_write_pipe_transport(pipe, protocol, waiter) try: await waiter except: transport.close() raise if self._debug: logger.debug('Write pipe %r connected: (%r, %r)', pipe.fileno(), transport, protocol) return transport, protocol def _log_subprocess(self, msg, stdin, stdout, stderr): info = [msg] if stdin is not None: info.append(f'stdin={_format_pipe(stdin)}') if stdout is not None and stderr == subprocess.STDOUT: info.append(f'stdout=stderr={_format_pipe(stdout)}') else: if stdout is not None: info.append(f'stdout={_format_pipe(stdout)}') if stderr is not None: info.append(f'stderr={_format_pipe(stderr)}') logger.debug(' '.join(info)) async def subprocess_shell(self, protocol_factory, cmd, *, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=True, bufsize=0, encoding=None, errors=None, text=None, **kwargs): if not isinstance(cmd, (bytes, str)): raise ValueError("cmd must be a string") if universal_newlines: raise ValueError("universal_newlines must be False") if not shell: raise ValueError("shell must be True") if bufsize != 0: raise ValueError("bufsize must be 0") if text: raise ValueError("text must be False") if encoding is not None: raise ValueError("encoding must be None") if errors is not None: raise ValueError("errors must be None") protocol = protocol_factory() debug_log = None if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = 'run shell command %r' % cmd self._log_subprocess(debug_log, stdin, stdout, stderr) transport = await self._make_subprocess_transport( protocol, cmd, True, stdin, stdout, stderr, bufsize, **kwargs) if self._debug and debug_log is not None: logger.info('%s: %r', debug_log, transport) return transport, protocol async def subprocess_exec(self, protocol_factory, program, *args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=False, shell=False, bufsize=0, encoding=None, errors=None, text=None, **kwargs): if universal_newlines: raise ValueError("universal_newlines must be False") if shell: raise ValueError("shell must be False") if bufsize != 0: raise ValueError("bufsize must be 0") if text: raise ValueError("text must be False") if encoding is not None: raise ValueError("encoding must be None") if errors is not None: raise ValueError("errors must be None") popen_args = (program,) + args protocol = protocol_factory() debug_log = None if self._debug: # don't log parameters: they may contain sensitive information # (password) and may be too long debug_log = f'execute program {program!r}' self._log_subprocess(debug_log, stdin, stdout, stderr) transport = await self._make_subprocess_transport( protocol, popen_args, False, stdin, stdout, stderr, bufsize, **kwargs) if self._debug and debug_log is not None: logger.info('%s: %r', debug_log, transport) return transport, protocol def get_exception_handler(self): """Return an exception handler, or None if the default one is in use. """ return self._exception_handler def set_exception_handler(self, handler): """Set 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). """ if handler is not None and not callable(handler): raise TypeError(f'A callable object or None is expected, ' f'got {handler!r}') self._exception_handler = handler def default_exception_handler(self, context): """Default 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()`. """ message = context.get('message') if not message: message = 'Unhandled exception in event loop' exception = context.get('exception') if exception is not None: exc_info = (type(exception), exception, exception.__traceback__) else: exc_info = False if ('source_traceback' not in context and self._current_handle is not None and self._current_handle._source_traceback): context['handle_traceback'] = \ self._current_handle._source_traceback log_lines = [message] for key in sorted(context): if key in {'message', 'exception'}: continue value = context[key] if key == 'source_traceback': tb = ''.join(traceback.format_list(value)) value = 'Object created at (most recent call last):\n' value += tb.rstrip() elif key == 'handle_traceback': tb = ''.join(traceback.format_list(value)) value = 'Handle created at (most recent call last):\n' value += tb.rstrip() else: value = repr(value) log_lines.append(f'{key}: {value}') logger.error('\n'.join(log_lines), exc_info=exc_info) def call_exception_handler(self, context): """Call 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. """ if self._exception_handler is None: try: self.default_exception_handler(context) except (SystemExit, KeyboardInterrupt): raise except BaseException: # Second protection layer for unexpected errors # in the default implementation, as well as for subclassed # event loops with overloaded "default_exception_handler". logger.error('Exception in default exception handler', exc_info=True) else: try: ctx = None thing = context.get("task") if thing is None: # Even though Futures don't have a context, # Task is a subclass of Future, # and sometimes the 'future' key holds a Task. thing = context.get("future") if thing is None: # Handles also have a context. thing = context.get("handle") if thing is not None and hasattr(thing, "get_context"): ctx = thing.get_context() if ctx is not None and hasattr(ctx, "run"): ctx.run(self._exception_handler, self, context) else: self._exception_handler(self, context) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: # Exception in the user set custom exception handler. try: # Let's try default handler. self.default_exception_handler({ 'message': 'Unhandled error in exception handler', 'exception': exc, 'context': context, }) except (SystemExit, KeyboardInterrupt): raise except BaseException: # Guard 'default_exception_handler' in case it is # overloaded. logger.error('Exception in default exception handler ' 'while handling an unexpected error ' 'in custom exception handler', exc_info=True) def _add_callback(self, handle): """Add a Handle to _ready.""" if not handle._cancelled: self._ready.append(handle) def _add_callback_signalsafe(self, handle): """Like _add_callback() but called from a signal handler.""" self._add_callback(handle) self._write_to_self() def _timer_handle_cancelled(self, handle): """Notification that a TimerHandle has been cancelled.""" if handle._scheduled: self._timer_cancelled_count += 1 def _run_once(self): """Run 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. """ sched_count = len(self._scheduled) if (sched_count > _MIN_SCHEDULED_TIMER_HANDLES and self._timer_cancelled_count / sched_count > _MIN_CANCELLED_TIMER_HANDLES_FRACTION): # Remove delayed calls that were cancelled if their number # is too high new_scheduled = [] for handle in self._scheduled: if handle._cancelled: handle._scheduled = False else: new_scheduled.append(handle) heapq.heapify(new_scheduled) self._scheduled = new_scheduled self._timer_cancelled_count = 0 else: # Remove delayed calls that were cancelled from head of queue. while self._scheduled and self._scheduled[0]._cancelled: self._timer_cancelled_count -= 1 handle = heapq.heappop(self._scheduled) handle._scheduled = False timeout = None if self._ready or self._stopping: timeout = 0 elif self._scheduled: # Compute the desired timeout. when = self._scheduled[0]._when timeout = min(max(0, when - self.time()), MAXIMUM_SELECT_TIMEOUT) event_list = self._selector.select(timeout) self._process_events(event_list) # Needed to break cycles when an exception occurs. event_list = None # Handle 'later' callbacks that are ready. end_time = self.time() + self._clock_resolution while self._scheduled: handle = self._scheduled[0] if handle._when >= end_time: break handle = heapq.heappop(self._scheduled) handle._scheduled = False self._ready.append(handle) # This is the only place where callbacks are actually *called*. # All other places just add them to ready. # Note: We run all currently scheduled callbacks, but not any # callbacks scheduled by callbacks run this time around -- # they will be run the next time (after another I/O poll). # Use an idiom that is thread-safe without using locks. ntodo = len(self._ready) for i in range(ntodo): handle = self._ready.popleft() if handle._cancelled: continue if self._debug: try: self._current_handle = handle t0 = self.time() handle._run() dt = self.time() - t0 if dt >= self.slow_callback_duration: logger.warning('Executing %s took %.3f seconds', _format_handle(handle), dt) finally: self._current_handle = None else: handle._run() handle = None # Needed to break cycles when an exception occurs. def _set_coroutine_origin_tracking(self, enabled): if bool(enabled) == bool(self._coroutine_origin_tracking_enabled): return if enabled: self._coroutine_origin_tracking_saved_depth = ( sys.get_coroutine_origin_tracking_depth()) sys.set_coroutine_origin_tracking_depth( constants.DEBUG_STACK_DEPTH) else: sys.set_coroutine_origin_tracking_depth( self._coroutine_origin_tracking_saved_depth) self._coroutine_origin_tracking_enabled = enabled def get_debug(self): return self._debug def set_debug(self, enabled): self._debug = enabled if self.is_running(): self.call_soon_threadsafe(self._set_coroutine_origin_tracking, enabled) trsock.py000064400000004653152343231170006434 0ustar00import socket class TransportSocket: """A socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. """ __slots__ = ('_sock',) def __init__(self, sock: socket.socket): self._sock = sock @property def family(self): return self._sock.family @property def type(self): return self._sock.type @property def proto(self): return self._sock.proto def __repr__(self): s = ( f"" def __getstate__(self): raise TypeError("Cannot serialize asyncio.TransportSocket object") def fileno(self): return self._sock.fileno() def dup(self): return self._sock.dup() def get_inheritable(self): return self._sock.get_inheritable() def shutdown(self, how): # asyncio doesn't currently provide a high-level transport API # to shutdown the connection. self._sock.shutdown(how) def getsockopt(self, *args, **kwargs): return self._sock.getsockopt(*args, **kwargs) def setsockopt(self, *args, **kwargs): self._sock.setsockopt(*args, **kwargs) def getpeername(self): return self._sock.getpeername() def getsockname(self): return self._sock.getsockname() def getsockbyname(self): return self._sock.getsockbyname() def settimeout(self, value): if value == 0: return raise ValueError( 'settimeout(): only 0 timeout is allowed on transport sockets') def gettimeout(self): return 0 def setblocking(self, flag): if not flag: return raise ValueError( 'setblocking(): transport sockets cannot be blocking') threads.py000064400000001426152343231170006554 0ustar00"""High-level support for working with threads in asyncio""" import functools import contextvars from . import events __all__ = "to_thread", async def to_thread(func, /, *args, **kwargs): """Asynchronously run function *func* in a separate thread. Any *args and **kwargs supplied for this function are directly passed to *func*. Also, the current :class:`contextvars.Context` is propagated, allowing context variables from the main thread to be accessed in the separate thread. Return a coroutine that can be awaited to get the eventual result of *func*. """ loop = events.get_running_loop() ctx = contextvars.copy_context() func_call = functools.partial(ctx.run, func, *args, **kwargs) return await loop.run_in_executor(None, func_call) tasks.py000064400000110762152343231170006253 0ustar00"""Support for tasks, coroutines and the scheduler.""" __all__ = ( 'Task', 'create_task', 'FIRST_COMPLETED', 'FIRST_EXCEPTION', 'ALL_COMPLETED', 'wait', 'wait_for', 'as_completed', 'sleep', 'gather', 'shield', 'ensure_future', 'run_coroutine_threadsafe', 'current_task', 'all_tasks', 'create_eager_task_factory', 'eager_task_factory', '_register_task', '_unregister_task', '_enter_task', '_leave_task', ) import concurrent.futures import contextvars import functools import inspect import itertools import types import warnings import weakref from types import GenericAlias from . import base_tasks from . import coroutines from . import events from . import exceptions from . import futures from . import timeouts # Helper to generate new task names # This uses itertools.count() instead of a "+= 1" operation because the latter # is not thread safe. See bpo-11866 for a longer explanation. _task_name_counter = itertools.count(1).__next__ def current_task(loop=None): """Return a currently executed task.""" if loop is None: loop = events.get_running_loop() return _current_tasks.get(loop) def all_tasks(loop=None): """Return a set of all tasks for the loop.""" if loop is None: loop = events.get_running_loop() # capturing the set of eager tasks first, so if an eager task "graduates" # to a regular task in another thread, we don't risk missing it. eager_tasks = list(_eager_tasks) # Looping over the WeakSet isn't safe as it can be updated from another # thread, therefore we cast it to list prior to filtering. The list cast # itself requires iteration, so we repeat it several times ignoring # RuntimeErrors (which are not very likely to occur). # See issues 34970 and 36607 for details. scheduled_tasks = None i = 0 while True: try: scheduled_tasks = list(_scheduled_tasks) except RuntimeError: i += 1 if i >= 1000: raise else: break return {t for t in itertools.chain(scheduled_tasks, eager_tasks) if futures._get_loop(t) is loop and not t.done()} def _set_task_name(task, name): if name is not None: try: set_name = task.set_name except AttributeError: warnings.warn("Task.set_name() was added in Python 3.8, " "the method support will be mandatory for third-party " "task implementations since 3.13.", DeprecationWarning, stacklevel=3) else: set_name(name) class Task(futures._PyFuture): # Inherit Python Task implementation # from a Python Future implementation. """A coroutine wrapped in a Future.""" # An important invariant maintained while a Task not done: # _fut_waiter is either None or a Future. The Future # can be either done() or not done(). # The task can be in any of 3 states: # # - 1: _fut_waiter is not None and not _fut_waiter.done(): # __step() is *not* scheduled and the Task is waiting for _fut_waiter. # - 2: (_fut_waiter is None or _fut_waiter.done()) and __step() is scheduled: # the Task is waiting for __step() to be executed. # - 3: _fut_waiter is None and __step() is *not* scheduled: # the Task is currently executing (in __step()). # # * In state 1, one of the callbacks of __fut_waiter must be __wakeup(). # * The transition from 1 to 2 happens when _fut_waiter becomes done(), # as it schedules __wakeup() to be called (which calls __step() so # we way that __step() is scheduled). # * It transitions from 2 to 3 when __step() is executed, and it clears # _fut_waiter to None. # If False, don't log a message if the task is destroyed while its # status is still pending _log_destroy_pending = True def __init__(self, coro, *, loop=None, name=None, context=None, eager_start=False): super().__init__(loop=loop) if self._source_traceback: del self._source_traceback[-1] if not coroutines.iscoroutine(coro): # raise after Future.__init__(), attrs are required for __del__ # prevent logging for pending task in __del__ self._log_destroy_pending = False raise TypeError(f"a coroutine was expected, got {coro!r}") if name is None: self._name = f'Task-{_task_name_counter()}' else: self._name = str(name) self._num_cancels_requested = 0 self._must_cancel = False self._fut_waiter = None self._coro = coro if context is None: self._context = contextvars.copy_context() else: self._context = context if eager_start and self._loop.is_running(): self.__eager_start() else: self._loop.call_soon(self.__step, context=self._context) _register_task(self) def __del__(self): if self._state == futures._PENDING and self._log_destroy_pending: context = { 'task': self, 'message': 'Task was destroyed but it is pending!', } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) super().__del__() __class_getitem__ = classmethod(GenericAlias) def __repr__(self): return base_tasks._task_repr(self) def get_coro(self): return self._coro def get_context(self): return self._context def get_name(self): return self._name def set_name(self, value): self._name = str(value) def set_result(self, result): raise RuntimeError('Task does not support set_result operation') def set_exception(self, exception): raise RuntimeError('Task does not support set_exception operation') def get_stack(self, *, limit=None): """Return the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. """ return base_tasks._task_get_stack(self, limit) def print_stack(self, *, limit=None, file=None): """Print the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. """ return base_tasks._task_print_stack(self, limit, file) def cancel(self, msg=None): """Request that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). This also increases the task's count of cancellation requests. """ self._log_traceback = False if self.done(): return False self._num_cancels_requested += 1 # These two lines are controversial. See discussion starting at # https://github.com/python/cpython/pull/31394#issuecomment-1053545331 # Also remember that this is duplicated in _asynciomodule.c. # if self._num_cancels_requested > 1: # return False if self._fut_waiter is not None: if self._fut_waiter.cancel(msg=msg): # Leave self._fut_waiter; it may be a Task that # catches and ignores the cancellation so we may have # to cancel it again later. return True # It must be the case that self.__step is already scheduled. self._must_cancel = True self._cancel_message = msg return True def cancelling(self): """Return the count of the task's cancellation requests. This count is incremented when .cancel() is called and may be decremented using .uncancel(). """ return self._num_cancels_requested def uncancel(self): """Decrement the task's count of cancellation requests. This should be called by the party that called `cancel()` on the task beforehand. Returns the remaining number of cancellation requests. """ if self._num_cancels_requested > 0: self._num_cancels_requested -= 1 return self._num_cancels_requested def __eager_start(self): prev_task = _swap_current_task(self._loop, self) try: _register_eager_task(self) try: self._context.run(self.__step_run_and_handle_result, None) finally: _unregister_eager_task(self) finally: try: curtask = _swap_current_task(self._loop, prev_task) assert curtask is self finally: if self.done(): self._coro = None self = None # Needed to break cycles when an exception occurs. else: _register_task(self) def __step(self, exc=None): if self.done(): raise exceptions.InvalidStateError( f'_step(): already done: {self!r}, {exc!r}') if self._must_cancel: if not isinstance(exc, exceptions.CancelledError): exc = self._make_cancelled_error() self._must_cancel = False self._fut_waiter = None _enter_task(self._loop, self) try: self.__step_run_and_handle_result(exc) finally: _leave_task(self._loop, self) self = None # Needed to break cycles when an exception occurs. def __step_run_and_handle_result(self, exc): coro = self._coro try: if exc is None: # We use the `send` method directly, because coroutines # don't have `__iter__` and `__next__` methods. result = coro.send(None) else: result = coro.throw(exc) except StopIteration as exc: if self._must_cancel: # Task is cancelled right before coro stops. self._must_cancel = False super().cancel(msg=self._cancel_message) else: super().set_result(exc.value) except exceptions.CancelledError as exc: # Save the original exception so we can chain it later. self._cancelled_exc = exc super().cancel() # I.e., Future.cancel(self). except (KeyboardInterrupt, SystemExit) as exc: super().set_exception(exc) raise except BaseException as exc: super().set_exception(exc) else: blocking = getattr(result, '_asyncio_future_blocking', None) if blocking is not None: # Yielded Future must come from Future.__iter__(). if futures._get_loop(result) is not self._loop: new_exc = RuntimeError( f'Task {self!r} got Future ' f'{result!r} attached to a different loop') self._loop.call_soon( self.__step, new_exc, context=self._context) elif blocking: if result is self: new_exc = RuntimeError( f'Task cannot await on itself: {self!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) else: result._asyncio_future_blocking = False result.add_done_callback( self.__wakeup, context=self._context) self._fut_waiter = result if self._must_cancel: if self._fut_waiter.cancel( msg=self._cancel_message): self._must_cancel = False else: new_exc = RuntimeError( f'yield was used instead of yield from ' f'in task {self!r} with {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) elif result is None: # Bare yield relinquishes control for one event loop iteration. self._loop.call_soon(self.__step, context=self._context) elif inspect.isgenerator(result): # Yielding a generator is just wrong. new_exc = RuntimeError( f'yield was used instead of yield from for ' f'generator in task {self!r} with {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) else: # Yielding something else is an error. new_exc = RuntimeError(f'Task got bad yield: {result!r}') self._loop.call_soon( self.__step, new_exc, context=self._context) finally: self = None # Needed to break cycles when an exception occurs. def __wakeup(self, future): try: future.result() except BaseException as exc: # This may also be a cancellation. self.__step(exc) else: # Don't pass the value of `future.result()` explicitly, # as `Future.__iter__` and `Future.__await__` don't need it. # If we call `_step(value, None)` instead of `_step()`, # Python eval loop would use `.send(value)` method call, # instead of `__next__()`, which is slower for futures # that return non-generator iterators from their `__iter__`. self.__step() self = None # Needed to break cycles when an exception occurs. _PyTask = Task try: import _asyncio except ImportError: pass else: # _CTask is needed for tests. Task = _CTask = _asyncio.Task def create_task(coro, *, name=None, context=None): """Schedule the execution of a coroutine object in a spawn task. Return a Task object. """ loop = events.get_running_loop() if context is None: # Use legacy API if context is not needed task = loop.create_task(coro) else: task = loop.create_task(coro, context=context) _set_task_name(task, name) return task # wait() and as_completed() similar to those in PEP 3148. FIRST_COMPLETED = concurrent.futures.FIRST_COMPLETED FIRST_EXCEPTION = concurrent.futures.FIRST_EXCEPTION ALL_COMPLETED = concurrent.futures.ALL_COMPLETED async def wait(fs, *, timeout=None, return_when=ALL_COMPLETED): """Wait for the Futures or Tasks given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect a list of futures, not {type(fs).__name__}") if not fs: raise ValueError('Set of Tasks/Futures is empty.') if return_when not in (FIRST_COMPLETED, FIRST_EXCEPTION, ALL_COMPLETED): raise ValueError(f'Invalid return_when value: {return_when}') fs = set(fs) if any(coroutines.iscoroutine(f) for f in fs): raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") loop = events.get_running_loop() return await _wait(fs, timeout, return_when, loop) def _release_waiter(waiter, *args): if not waiter.done(): waiter.set_result(None) async def wait_for(fut, timeout): """Wait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. If the task suppresses the cancellation and returns a value instead, that value is returned. This function is a coroutine. """ # The special case for timeout <= 0 is for the following case: # # async def test_waitfor(): # func_started = False # # async def func(): # nonlocal func_started # func_started = True # # try: # await asyncio.wait_for(func(), 0) # except asyncio.TimeoutError: # assert not func_started # else: # assert False # # asyncio.run(test_waitfor()) if timeout is not None and timeout <= 0: fut = ensure_future(fut) if fut.done(): return fut.result() await _cancel_and_wait(fut) try: return fut.result() except exceptions.CancelledError as exc: raise TimeoutError from exc async with timeouts.timeout(timeout): return await fut async def _wait(fs, timeout, return_when, loop): """Internal helper for wait(). The fs argument must be a collection of Futures. """ assert fs, 'Set of Futures is empty.' waiter = loop.create_future() timeout_handle = None if timeout is not None: timeout_handle = loop.call_later(timeout, _release_waiter, waiter) counter = len(fs) def _on_completion(f): nonlocal counter counter -= 1 if (counter <= 0 or return_when == FIRST_COMPLETED or return_when == FIRST_EXCEPTION and (not f.cancelled() and f.exception() is not None)): if timeout_handle is not None: timeout_handle.cancel() if not waiter.done(): waiter.set_result(None) for f in fs: f.add_done_callback(_on_completion) try: await waiter finally: if timeout_handle is not None: timeout_handle.cancel() for f in fs: f.remove_done_callback(_on_completion) done, pending = set(), set() for f in fs: if f.done(): done.add(f) else: pending.add(f) return done, pending async def _cancel_and_wait(fut): """Cancel the *fut* future or task and wait until it completes.""" loop = events.get_running_loop() waiter = loop.create_future() cb = functools.partial(_release_waiter, waiter) fut.add_done_callback(cb) try: fut.cancel() # We cannot wait on *fut* directly to make # sure _cancel_and_wait itself is reliably cancellable. await waiter finally: fut.remove_done_callback(cb) # This is *not* a @coroutine! It is just an iterator (yielding Futures). def as_completed(fs, *, timeout=None): """Return an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = await f # The 'await' may raise. # Use result. If a timeout is specified, the 'await' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. """ if futures.isfuture(fs) or coroutines.iscoroutine(fs): raise TypeError(f"expect an iterable of futures, not {type(fs).__name__}") from .queues import Queue # Import here to avoid circular import problem. done = Queue() loop = events.get_event_loop() todo = {ensure_future(f, loop=loop) for f in set(fs)} timeout_handle = None def _on_timeout(): for f in todo: f.remove_done_callback(_on_completion) done.put_nowait(None) # Queue a dummy value for _wait_for_one(). todo.clear() # Can't do todo.remove(f) in the loop. def _on_completion(f): if not todo: return # _on_timeout() was here first. todo.remove(f) done.put_nowait(f) if not todo and timeout_handle is not None: timeout_handle.cancel() async def _wait_for_one(): f = await done.get() if f is None: # Dummy value from _on_timeout(). raise exceptions.TimeoutError return f.result() # May raise f.exception(). for f in todo: f.add_done_callback(_on_completion) if todo and timeout is not None: timeout_handle = loop.call_later(timeout, _on_timeout) for _ in range(len(todo)): yield _wait_for_one() @types.coroutine def __sleep0(): """Skip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. """ yield async def sleep(delay, result=None): """Coroutine that completes after a given time (in seconds).""" if delay <= 0: await __sleep0() return result loop = events.get_running_loop() future = loop.create_future() h = loop.call_later(delay, futures._set_result_unless_cancelled, future, result) try: return await future finally: h.cancel() def ensure_future(coro_or_future, *, loop=None): """Wrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. """ if futures.isfuture(coro_or_future): if loop is not None and loop is not futures._get_loop(coro_or_future): raise ValueError('The future belongs to a different loop than ' 'the one specified as the loop argument') return coro_or_future should_close = True if not coroutines.iscoroutine(coro_or_future): if inspect.isawaitable(coro_or_future): async def _wrap_awaitable(awaitable): return await awaitable coro_or_future = _wrap_awaitable(coro_or_future) should_close = False else: raise TypeError('An asyncio.Future, a coroutine or an awaitable ' 'is required') if loop is None: loop = events.get_event_loop() try: return loop.create_task(coro_or_future) except RuntimeError: if should_close: coro_or_future.close() raise class _GatheringFuture(futures.Future): """Helper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. """ def __init__(self, children, *, loop): assert loop is not None super().__init__(loop=loop) self._children = children self._cancel_requested = False def cancel(self, msg=None): if self.done(): return False ret = False for child in self._children: if child.cancel(msg=msg): ret = True if ret: # If any child tasks were actually cancelled, we should # propagate the cancellation request regardless of # *return_exceptions* argument. See issue 32684. self._cancel_requested = True return ret def gather(*coros_or_futures, return_exceptions=False): """Return a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. """ if not coros_or_futures: loop = events.get_event_loop() outer = loop.create_future() outer.set_result([]) return outer def _done_callback(fut): nonlocal nfinished nfinished += 1 if outer is None or outer.done(): if not fut.cancelled(): # Mark exception retrieved. fut.exception() return if not return_exceptions: if fut.cancelled(): # Check if 'fut' is cancelled first, as # 'fut.exception()' will *raise* a CancelledError # instead of returning it. exc = fut._make_cancelled_error() outer.set_exception(exc) return else: exc = fut.exception() if exc is not None: outer.set_exception(exc) return if nfinished == nfuts: # All futures are done; create a list of results # and set it to the 'outer' future. results = [] for fut in children: if fut.cancelled(): # Check if 'fut' is cancelled first, as 'fut.exception()' # will *raise* a CancelledError instead of returning it. # Also, since we're adding the exception return value # to 'results' instead of raising it, don't bother # setting __context__. This also lets us preserve # calling '_make_cancelled_error()' at most once. res = exceptions.CancelledError( '' if fut._cancel_message is None else fut._cancel_message) else: res = fut.exception() if res is None: res = fut.result() results.append(res) if outer._cancel_requested: # If gather is being cancelled we must propagate the # cancellation regardless of *return_exceptions* argument. # See issue 32684. exc = fut._make_cancelled_error() outer.set_exception(exc) else: outer.set_result(results) arg_to_fut = {} children = [] nfuts = 0 nfinished = 0 done_futs = [] loop = None outer = None # bpo-46672 for arg in coros_or_futures: if arg not in arg_to_fut: fut = ensure_future(arg, loop=loop) if loop is None: loop = futures._get_loop(fut) if fut is not arg: # 'arg' was not a Future, therefore, 'fut' is a new # Future created specifically for 'arg'. Since the caller # can't control it, disable the "destroy pending task" # warning. fut._log_destroy_pending = False nfuts += 1 arg_to_fut[arg] = fut if fut.done(): done_futs.append(fut) else: fut.add_done_callback(_done_callback) else: # There's a duplicate Future object in coros_or_futures. fut = arg_to_fut[arg] children.append(fut) outer = _GatheringFuture(children, loop=loop) # Run done callbacks after GatheringFuture created so any post-processing # can be performed at this point # optimization: in the special case that *all* futures finished eagerly, # this will effectively complete the gather eagerly, with the last # callback setting the result (or exception) on outer before returning it for fut in done_futs: _done_callback(fut) return outer def shield(arg): """Wait for a future, shielding it from cancellation. The statement task = asyncio.create_task(something()) res = await shield(task) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: task = asyncio.create_task(something()) try: res = await shield(task) except CancelledError: res = None Save a reference to tasks passed to this function, to avoid a task disappearing mid-execution. The event loop only keeps weak references to tasks. A task that isn't referenced elsewhere may get garbage collected at any time, even before it's done. """ inner = ensure_future(arg) if inner.done(): # Shortcut. return inner loop = futures._get_loop(inner) outer = loop.create_future() def _inner_done_callback(inner): if outer.cancelled(): if not inner.cancelled(): # Mark inner's result as retrieved. inner.exception() return if inner.cancelled(): outer.cancel() else: exc = inner.exception() if exc is not None: outer.set_exception(exc) else: outer.set_result(inner.result()) def _outer_done_callback(outer): if not inner.done(): inner.remove_done_callback(_inner_done_callback) inner.add_done_callback(_inner_done_callback) outer.add_done_callback(_outer_done_callback) return outer def run_coroutine_threadsafe(coro, loop): """Submit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. """ if not coroutines.iscoroutine(coro): raise TypeError('A coroutine object is required') future = concurrent.futures.Future() def callback(): try: futures._chain_future(ensure_future(coro, loop=loop), future) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: if future.set_running_or_notify_cancel(): future.set_exception(exc) raise loop.call_soon_threadsafe(callback) return future def create_eager_task_factory(custom_task_constructor): """Create a function suitable for use as a task factory on an event-loop. Example usage: loop.set_task_factory( asyncio.create_eager_task_factory(my_task_constructor)) Now, tasks created will be started immediately (rather than being first scheduled to an event loop). The constructor argument can be any callable that returns a Task-compatible object and has a signature compatible with `Task.__init__`; it must have the `eager_start` keyword argument. Most applications will use `Task` for `custom_task_constructor` and in this case there's no need to call `create_eager_task_factory()` directly. Instead the global `eager_task_factory` instance can be used. E.g. `loop.set_task_factory(asyncio.eager_task_factory)`. """ def factory(loop, coro, *, name=None, context=None): return custom_task_constructor( coro, loop=loop, name=name, context=context, eager_start=True) return factory eager_task_factory = create_eager_task_factory(Task) # Collectively these two sets hold references to the complete set of active # tasks. Eagerly executed tasks use a faster regular set as an optimization # but may graduate to a WeakSet if the task blocks on IO. _scheduled_tasks = weakref.WeakSet() _eager_tasks = set() # Dictionary containing tasks that are currently active in # all running event loops. {EventLoop: Task} _current_tasks = {} def _register_task(task): """Register an asyncio Task scheduled to run on an event loop.""" _scheduled_tasks.add(task) def _register_eager_task(task): """Register an asyncio Task about to be eagerly executed.""" _eager_tasks.add(task) def _enter_task(loop, task): current_task = _current_tasks.get(loop) if current_task is not None: raise RuntimeError(f"Cannot enter into task {task!r} while another " f"task {current_task!r} is being executed.") _current_tasks[loop] = task def _leave_task(loop, task): current_task = _current_tasks.get(loop) if current_task is not task: raise RuntimeError(f"Leaving task {task!r} does not match " f"the current task {current_task!r}.") del _current_tasks[loop] def _swap_current_task(loop, task): prev_task = _current_tasks.get(loop) if task is None: del _current_tasks[loop] else: _current_tasks[loop] = task return prev_task def _unregister_task(task): """Unregister a completed, scheduled Task.""" _scheduled_tasks.discard(task) def _unregister_eager_task(task): """Unregister a task which finished its first eager step.""" _eager_tasks.discard(task) _py_current_task = current_task _py_register_task = _register_task _py_register_eager_task = _register_eager_task _py_unregister_task = _unregister_task _py_unregister_eager_task = _unregister_eager_task _py_enter_task = _enter_task _py_leave_task = _leave_task _py_swap_current_task = _swap_current_task try: from _asyncio import (_register_task, _register_eager_task, _unregister_task, _unregister_eager_task, _enter_task, _leave_task, _swap_current_task, _scheduled_tasks, _eager_tasks, _current_tasks, current_task) except ImportError: pass else: _c_current_task = current_task _c_register_task = _register_task _c_register_eager_task = _register_eager_task _c_unregister_task = _unregister_task _c_unregister_eager_task = _unregister_eager_task _c_enter_task = _enter_task _c_leave_task = _leave_task _c_swap_current_task = _swap_current_task runners.py000064400000016076152343231170006625 0ustar00__all__ = ('Runner', 'run') import contextvars import enum import functools import threading import signal from . import coroutines from . import events from . import exceptions from . import tasks from . import constants class _State(enum.Enum): CREATED = "created" INITIALIZED = "initialized" CLOSED = "closed" class Runner: """A context manager that controls event loop life cycle. The context manager always creates a new event loop, allows to run async functions inside it, and properly finalizes the loop at the context manager exit. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. asyncio.run(main(), debug=True) is a shortcut for with asyncio.Runner(debug=True) as runner: runner.run(main()) The run() method can be called multiple times within the runner's context. This can be useful for interactive console (e.g. IPython), unittest runners, console tools, -- everywhere when async code is called from existing sync framework and where the preferred single asyncio.run() call doesn't work. """ # Note: the class is final, it is not intended for inheritance. def __init__(self, *, debug=None, loop_factory=None): self._state = _State.CREATED self._debug = debug self._loop_factory = loop_factory self._loop = None self._context = None self._interrupt_count = 0 self._set_event_loop = False def __enter__(self): self._lazy_init() return self def __exit__(self, exc_type, exc_val, exc_tb): self.close() def close(self): """Shutdown and close event loop.""" if self._state is not _State.INITIALIZED: return try: loop = self._loop _cancel_all_tasks(loop) loop.run_until_complete(loop.shutdown_asyncgens()) loop.run_until_complete( loop.shutdown_default_executor(constants.THREAD_JOIN_TIMEOUT)) finally: if self._set_event_loop: events.set_event_loop(None) loop.close() self._loop = None self._state = _State.CLOSED def get_loop(self): """Return embedded event loop.""" self._lazy_init() return self._loop def run(self, coro, *, context=None): """Run a coroutine inside the embedded event loop.""" if not coroutines.iscoroutine(coro): raise ValueError("a coroutine was expected, got {!r}".format(coro)) if events._get_running_loop() is not None: # fail fast with short traceback raise RuntimeError( "Runner.run() cannot be called from a running event loop") self._lazy_init() if context is None: context = self._context task = self._loop.create_task(coro, context=context) if (threading.current_thread() is threading.main_thread() and signal.getsignal(signal.SIGINT) is signal.default_int_handler ): sigint_handler = functools.partial(self._on_sigint, main_task=task) try: signal.signal(signal.SIGINT, sigint_handler) except ValueError: # `signal.signal` may throw if `threading.main_thread` does # not support signals (e.g. embedded interpreter with signals # not registered - see gh-91880) sigint_handler = None else: sigint_handler = None self._interrupt_count = 0 try: return self._loop.run_until_complete(task) except exceptions.CancelledError: if self._interrupt_count > 0: uncancel = getattr(task, "uncancel", None) if uncancel is not None and uncancel() == 0: raise KeyboardInterrupt() raise # CancelledError finally: if (sigint_handler is not None and signal.getsignal(signal.SIGINT) is sigint_handler ): signal.signal(signal.SIGINT, signal.default_int_handler) def _lazy_init(self): if self._state is _State.CLOSED: raise RuntimeError("Runner is closed") if self._state is _State.INITIALIZED: return if self._loop_factory is None: self._loop = events.new_event_loop() if not self._set_event_loop: # Call set_event_loop only once to avoid calling # attach_loop multiple times on child watchers events.set_event_loop(self._loop) self._set_event_loop = True else: self._loop = self._loop_factory() if self._debug is not None: self._loop.set_debug(self._debug) self._context = contextvars.copy_context() self._state = _State.INITIALIZED def _on_sigint(self, signum, frame, main_task): self._interrupt_count += 1 if self._interrupt_count == 1 and not main_task.done(): main_task.cancel() # wakeup loop if it is blocked by select() with long timeout self._loop.call_soon_threadsafe(lambda: None) return raise KeyboardInterrupt() def run(main, *, debug=None, loop_factory=None): """Execute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop, finalizing asynchronous generators and closing the default executor. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. If loop_factory is passed, it is used for new event loop creation. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. The executor is given a timeout duration of 5 minutes to shutdown. If the executor hasn't finished within that duration, a warning is emitted and the executor is closed. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) """ if events._get_running_loop() is not None: # fail fast with short traceback raise RuntimeError( "asyncio.run() cannot be called from a running event loop") with Runner(debug=debug, loop_factory=loop_factory) as runner: return runner.run(main) def _cancel_all_tasks(loop): to_cancel = tasks.all_tasks(loop) if not to_cancel: return for task in to_cancel: task.cancel() loop.run_until_complete(tasks.gather(*to_cancel, return_exceptions=True)) for task in to_cancel: if task.cancelled(): continue if task.exception() is not None: loop.call_exception_handler({ 'message': 'unhandled exception during asyncio.run() shutdown', 'exception': task.exception(), 'task': task, }) unix_events.py000064400000147604152343231170007502 0ustar00"""Selector event loop for Unix with signal handling.""" import errno import io import itertools import os import selectors import signal import socket import stat import subprocess import sys import threading import warnings from . import base_events from . import base_subprocess from . import constants from . import coroutines from . import events from . import exceptions from . import futures from . import selector_events from . import tasks from . import transports from .log import logger __all__ = ( 'SelectorEventLoop', 'AbstractChildWatcher', 'SafeChildWatcher', 'FastChildWatcher', 'PidfdChildWatcher', 'MultiLoopChildWatcher', 'ThreadedChildWatcher', 'DefaultEventLoopPolicy', ) if sys.platform == 'win32': # pragma: no cover raise ImportError('Signals are not really supported on Windows') def _sighandler_noop(signum, frame): """Dummy signal handler.""" pass def waitstatus_to_exitcode(status): try: return os.waitstatus_to_exitcode(status) except ValueError: # The child exited, but we don't understand its status. # This shouldn't happen, but if it does, let's just # return that status; perhaps that helps debug it. return status class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop): """Unix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. """ def __init__(self, selector=None): super().__init__(selector) self._signal_handlers = {} def close(self): super().close() if not sys.is_finalizing(): for sig in list(self._signal_handlers): self.remove_signal_handler(sig) else: if self._signal_handlers: warnings.warn(f"Closing the loop {self!r} " f"on interpreter shutdown " f"stage, skipping signal handlers removal", ResourceWarning, source=self) self._signal_handlers.clear() def _process_self_data(self, data): for signum in data: if not signum: # ignore null bytes written by _write_to_self() continue self._handle_signal(signum) def add_signal_handler(self, sig, callback, *args): """Add a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if (coroutines.iscoroutine(callback) or coroutines.iscoroutinefunction(callback)): raise TypeError("coroutines cannot be used " "with add_signal_handler()") self._check_signal(sig) self._check_closed() try: # set_wakeup_fd() raises ValueError if this is not the # main thread. By calling it early we ensure that an # event loop running in another thread cannot add a signal # handler. signal.set_wakeup_fd(self._csock.fileno()) except (ValueError, OSError) as exc: raise RuntimeError(str(exc)) handle = events.Handle(callback, args, self, None) self._signal_handlers[sig] = handle try: # Register a dummy signal handler to ask Python to write the signal # number in the wakeup file descriptor. _process_self_data() will # read signal numbers from this file descriptor to handle signals. signal.signal(sig, _sighandler_noop) # Set SA_RESTART to limit EINTR occurrences. signal.siginterrupt(sig, False) except OSError as exc: del self._signal_handlers[sig] if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as nexc: logger.info('set_wakeup_fd(-1) failed: %s', nexc) if exc.errno == errno.EINVAL: raise RuntimeError(f'sig {sig} cannot be caught') else: raise def _handle_signal(self, sig): """Internal helper that is the actual signal handler.""" handle = self._signal_handlers.get(sig) if handle is None: return # Assume it's some race condition. if handle._cancelled: self.remove_signal_handler(sig) # Remove it properly. else: self._add_callback_signalsafe(handle) def remove_signal_handler(self, sig): """Remove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. """ self._check_signal(sig) try: del self._signal_handlers[sig] except KeyError: return False if sig == signal.SIGINT: handler = signal.default_int_handler else: handler = signal.SIG_DFL try: signal.signal(sig, handler) except OSError as exc: if exc.errno == errno.EINVAL: raise RuntimeError(f'sig {sig} cannot be caught') else: raise if not self._signal_handlers: try: signal.set_wakeup_fd(-1) except (ValueError, OSError) as exc: logger.info('set_wakeup_fd(-1) failed: %s', exc) return True def _check_signal(self, sig): """Internal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. """ if not isinstance(sig, int): raise TypeError(f'sig must be an int, not {sig!r}') if sig not in signal.valid_signals(): raise ValueError(f'invalid signal number {sig}') def _make_read_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixReadPipeTransport(self, pipe, protocol, waiter, extra) def _make_write_pipe_transport(self, pipe, protocol, waiter=None, extra=None): return _UnixWritePipeTransport(self, pipe, protocol, waiter, extra) async def _make_subprocess_transport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, extra=None, **kwargs): with warnings.catch_warnings(): warnings.simplefilter('ignore', DeprecationWarning) watcher = events.get_child_watcher() with watcher: if not watcher.is_active(): # Check early. # Raising exception before process creation # prevents subprocess execution if the watcher # is not ready to handle it. raise RuntimeError("asyncio.get_child_watcher() is not activated, " "subprocess support is not installed.") waiter = self.create_future() transp = _UnixSubprocessTransport(self, protocol, args, shell, stdin, stdout, stderr, bufsize, waiter=waiter, extra=extra, **kwargs) watcher.add_child_handler(transp.get_pid(), self._child_watcher_callback, transp) try: await waiter except (SystemExit, KeyboardInterrupt): raise except BaseException: transp.close() await transp._wait() raise return transp def _child_watcher_callback(self, pid, returncode, transp): self.call_soon_threadsafe(transp._process_exited, returncode) async def create_unix_connection( self, protocol_factory, path=None, *, ssl=None, sock=None, server_hostname=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None): assert server_hostname is None or isinstance(server_hostname, str) if ssl: if server_hostname is None: raise ValueError( 'you have to pass server_hostname when using ssl') else: if server_hostname is not None: raise ValueError('server_hostname is only meaningful with ssl') if ssl_handshake_timeout is not None: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') path = os.fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM, 0) try: sock.setblocking(False) await self.sock_connect(sock, path) except: sock.close() raise else: if sock is None: raise ValueError('no path and sock were specified') if (sock.family != socket.AF_UNIX or sock.type != socket.SOCK_STREAM): raise ValueError( f'A UNIX Domain Stream Socket was expected, got {sock!r}') sock.setblocking(False) transport, protocol = await self._create_connection_transport( sock, protocol_factory, ssl, server_hostname, ssl_handshake_timeout=ssl_handshake_timeout, ssl_shutdown_timeout=ssl_shutdown_timeout) return transport, protocol async def create_unix_server( self, protocol_factory, path=None, *, sock=None, backlog=100, ssl=None, ssl_handshake_timeout=None, ssl_shutdown_timeout=None, start_serving=True): if isinstance(ssl, bool): raise TypeError('ssl argument must be an SSLContext or None') if ssl_handshake_timeout is not None and not ssl: raise ValueError( 'ssl_handshake_timeout is only meaningful with ssl') if ssl_shutdown_timeout is not None and not ssl: raise ValueError( 'ssl_shutdown_timeout is only meaningful with ssl') if path is not None: if sock is not None: raise ValueError( 'path and sock can not be specified at the same time') path = os.fspath(path) sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) # Check for abstract socket. `str` and `bytes` paths are supported. if path[0] not in (0, '\x00'): try: if stat.S_ISSOCK(os.stat(path).st_mode): os.remove(path) except FileNotFoundError: pass except OSError as err: # Directory may have permissions only to create socket. logger.error('Unable to check or remove stale UNIX socket ' '%r: %r', path, err) try: sock.bind(path) except OSError as exc: sock.close() if exc.errno == errno.EADDRINUSE: # Let's improve the error message by adding # with what exact address it occurs. msg = f'Address {path!r} is already in use' raise OSError(errno.EADDRINUSE, msg) from None else: raise except: sock.close() raise else: if sock is None: raise ValueError( 'path was not specified, and no sock specified') if (sock.family != socket.AF_UNIX or sock.type != socket.SOCK_STREAM): raise ValueError( f'A UNIX Domain Stream Socket was expected, got {sock!r}') sock.setblocking(False) server = base_events.Server(self, [sock], protocol_factory, ssl, backlog, ssl_handshake_timeout, ssl_shutdown_timeout) if start_serving: server._start_serving() # Skip one loop iteration so that all 'loop.add_reader' # go through. await tasks.sleep(0) return server async def _sock_sendfile_native(self, sock, file, offset, count): try: os.sendfile except AttributeError: raise exceptions.SendfileNotAvailableError( "os.sendfile() is not available") try: fileno = file.fileno() except (AttributeError, io.UnsupportedOperation) as err: raise exceptions.SendfileNotAvailableError("not a regular file") try: fsize = os.fstat(fileno).st_size except OSError: raise exceptions.SendfileNotAvailableError("not a regular file") blocksize = count if count else fsize if not blocksize: return 0 # empty file fut = self.create_future() self._sock_sendfile_native_impl(fut, None, sock, fileno, offset, count, blocksize, 0) return await fut def _sock_sendfile_native_impl(self, fut, registered_fd, sock, fileno, offset, count, blocksize, total_sent): fd = sock.fileno() if registered_fd is not None: # Remove the callback early. It should be rare that the # selector says the fd is ready but the call still returns # EAGAIN, and I am willing to take a hit in that case in # order to simplify the common case. self.remove_writer(registered_fd) if fut.cancelled(): self._sock_sendfile_update_filepos(fileno, offset, total_sent) return if count: blocksize = count - total_sent if blocksize <= 0: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_result(total_sent) return try: sent = os.sendfile(fd, fileno, offset, blocksize) except (BlockingIOError, InterruptedError): if registered_fd is None: self._sock_add_cancellation_callback(fut, sock) self.add_writer(fd, self._sock_sendfile_native_impl, fut, fd, sock, fileno, offset, count, blocksize, total_sent) except OSError as exc: if (registered_fd is not None and exc.errno == errno.ENOTCONN and type(exc) is not ConnectionError): # If we have an ENOTCONN and this isn't a first call to # sendfile(), i.e. the connection was closed in the middle # of the operation, normalize the error to ConnectionError # to make it consistent across all Posix systems. new_exc = ConnectionError( "socket is not connected", errno.ENOTCONN) new_exc.__cause__ = exc exc = new_exc if total_sent == 0: # We can get here for different reasons, the main # one being 'file' is not a regular mmap(2)-like # file, in which case we'll fall back on using # plain send(). err = exceptions.SendfileNotAvailableError( "os.sendfile call failed") self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(err) else: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(exc) except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_exception(exc) else: if sent == 0: # EOF self._sock_sendfile_update_filepos(fileno, offset, total_sent) fut.set_result(total_sent) else: offset += sent total_sent += sent if registered_fd is None: self._sock_add_cancellation_callback(fut, sock) self.add_writer(fd, self._sock_sendfile_native_impl, fut, fd, sock, fileno, offset, count, blocksize, total_sent) def _sock_sendfile_update_filepos(self, fileno, offset, total_sent): if total_sent > 0: os.lseek(fileno, offset, os.SEEK_SET) def _sock_add_cancellation_callback(self, fut, sock): def cb(fut): if fut.cancelled(): fd = sock.fileno() if fd != -1: self.remove_writer(fd) fut.add_done_callback(cb) class _UnixReadPipeTransport(transports.ReadTransport): max_size = 256 * 1024 # max bytes we read in one event loop iteration def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra) self._extra['pipe'] = pipe self._loop = loop self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._closing = False self._paused = False mode = os.fstat(self._fileno).st_mode if not (stat.S_ISFIFO(mode) or stat.S_ISSOCK(mode) or stat.S_ISCHR(mode)): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is for pipes/sockets only.") os.set_blocking(self._fileno, False) self._loop.call_soon(self._protocol.connection_made, self) # only start reading when connection_made() has been called self._loop.call_soon(self._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def _add_reader(self, fd, callback): if not self.is_reading(): return self._loop._add_reader(fd, callback) def is_reading(self): return not self._paused and not self._closing def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._fileno}') selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_READ) if polling: info.append('polling') else: info.append('idle') elif self._pipe is not None: info.append('open') else: info.append('closed') return '<{}>'.format(' '.join(info)) def _read_ready(self): try: data = os.read(self._fileno, self.max_size) except (BlockingIOError, InterruptedError): pass except OSError as exc: self._fatal_error(exc, 'Fatal read error on pipe transport') else: if data: self._protocol.data_received(data) else: if self._loop.get_debug(): logger.info("%r was closed by peer", self) self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._protocol.eof_received) self._loop.call_soon(self._call_connection_lost, None) def pause_reading(self): if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._fileno) if self._loop.get_debug(): logger.debug("%r pauses reading", self) def resume_reading(self): if self._closing or not self._paused: return self._paused = False self._loop._add_reader(self._fileno, self._read_ready) if self._loop.get_debug(): logger.debug("%r resumes reading", self) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if not self._closing: self._close(None) def __del__(self, _warn=warnings.warn): if self._pipe is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._pipe.close() def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if (isinstance(exc, OSError) and exc.errno == errno.EIO): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc): self._closing = True self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None class _UnixWritePipeTransport(transports._FlowControlMixin, transports.WriteTransport): def __init__(self, loop, pipe, protocol, waiter=None, extra=None): super().__init__(extra, loop) self._extra['pipe'] = pipe self._pipe = pipe self._fileno = pipe.fileno() self._protocol = protocol self._buffer = bytearray() self._conn_lost = 0 self._closing = False # Set when close() or write_eof() called. mode = os.fstat(self._fileno).st_mode is_char = stat.S_ISCHR(mode) is_fifo = stat.S_ISFIFO(mode) is_socket = stat.S_ISSOCK(mode) if not (is_char or is_fifo or is_socket): self._pipe = None self._fileno = None self._protocol = None raise ValueError("Pipe transport is only for " "pipes, sockets and character devices") os.set_blocking(self._fileno, False) self._loop.call_soon(self._protocol.connection_made, self) # On AIX, the reader trick (to be notified when the read end of the # socket is closed) only works for sockets. On other platforms it # works for pipes and sockets. (Exception: OS X 10.4? Issue #19294.) if is_socket or (is_fifo and not sys.platform.startswith("aix")): # only start reading when connection_made() has been called self._loop.call_soon(self._loop._add_reader, self._fileno, self._read_ready) if waiter is not None: # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: info.append('closed') elif self._closing: info.append('closing') info.append(f'fd={self._fileno}') selector = getattr(self._loop, '_selector', None) if self._pipe is not None and selector is not None: polling = selector_events._test_selector_event( selector, self._fileno, selectors.EVENT_WRITE) if polling: info.append('polling') else: info.append('idle') bufsize = self.get_write_buffer_size() info.append(f'bufsize={bufsize}') elif self._pipe is not None: info.append('open') else: info.append('closed') return '<{}>'.format(' '.join(info)) def get_write_buffer_size(self): return len(self._buffer) def _read_ready(self): # Pipe was closed by peer. if self._loop.get_debug(): logger.info("%r was closed by peer", self) if self._buffer: self._close(BrokenPipeError()) else: self._close() def write(self, data): assert isinstance(data, (bytes, bytearray, memoryview)), repr(data) if isinstance(data, bytearray): data = memoryview(data) if not data: return if self._conn_lost or self._closing: if self._conn_lost >= constants.LOG_THRESHOLD_FOR_CONNLOST_WRITES: logger.warning('pipe closed by peer or ' 'os.write(pipe, data) raised exception.') self._conn_lost += 1 return if not self._buffer: # Attempt to send it right away first. try: n = os.write(self._fileno, data) except (BlockingIOError, InterruptedError): n = 0 except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._conn_lost += 1 self._fatal_error(exc, 'Fatal write error on pipe transport') return if n == len(data): return elif n > 0: data = memoryview(data)[n:] self._loop._add_writer(self._fileno, self._write_ready) self._buffer += data self._maybe_pause_protocol() def _write_ready(self): assert self._buffer, 'Data should not be empty' try: n = os.write(self._fileno, self._buffer) except (BlockingIOError, InterruptedError): pass except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: self._buffer.clear() self._conn_lost += 1 # Remove writer here, _fatal_error() doesn't it # because _buffer is empty. self._loop._remove_writer(self._fileno) self._fatal_error(exc, 'Fatal write error on pipe transport') else: if n == len(self._buffer): self._buffer.clear() self._loop._remove_writer(self._fileno) self._maybe_resume_protocol() # May append to buffer. if self._closing: self._loop._remove_reader(self._fileno) self._call_connection_lost(None) return elif n > 0: del self._buffer[:n] def can_write_eof(self): return True def write_eof(self): if self._closing: return assert self._pipe self._closing = True if not self._buffer: self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, None) def set_protocol(self, protocol): self._protocol = protocol def get_protocol(self): return self._protocol def is_closing(self): return self._closing def close(self): if self._pipe is not None and not self._closing: # write_eof is all what we needed to close the write pipe self.write_eof() def __del__(self, _warn=warnings.warn): if self._pipe is not None: _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) self._pipe.close() def abort(self): self._close(None) def _fatal_error(self, exc, message='Fatal error on pipe transport'): # should be called by exception handler only if isinstance(exc, OSError): if self._loop.get_debug(): logger.debug("%r: %s", self, message, exc_info=True) else: self._loop.call_exception_handler({ 'message': message, 'exception': exc, 'transport': self, 'protocol': self._protocol, }) self._close(exc) def _close(self, exc=None): self._closing = True if self._buffer: self._loop._remove_writer(self._fileno) self._buffer.clear() self._loop._remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, exc) def _call_connection_lost(self, exc): try: self._protocol.connection_lost(exc) finally: self._pipe.close() self._pipe = None self._protocol = None self._loop = None class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): stdin_w = None if stdin == subprocess.PIPE and sys.platform.startswith('aix'): # Use a socket pair for stdin on AIX, since it does not # support selecting read events on the write end of a # socket (which we use in order to detect closing of the # other end). stdin, stdin_w = socket.socketpair() try: self._proc = subprocess.Popen( args, shell=shell, stdin=stdin, stdout=stdout, stderr=stderr, universal_newlines=False, bufsize=bufsize, **kwargs) if stdin_w is not None: stdin.close() self._proc.stdin = open(stdin_w.detach(), 'wb', buffering=bufsize) stdin_w = None finally: if stdin_w is not None: stdin.close() stdin_w.close() class AbstractChildWatcher: """Abstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. """ def __init_subclass__(cls) -> None: if cls.__module__ != __name__: warnings._deprecated("AbstractChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def add_child_handler(self, pid, callback, *args): """Register a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. """ raise NotImplementedError() def remove_child_handler(self, pid): """Removes the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.""" raise NotImplementedError() def attach_loop(self, loop): """Attach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. """ raise NotImplementedError() def close(self): """Close the watcher. This must be called to make sure that any underlying resource is freed. """ raise NotImplementedError() def is_active(self): """Return ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. """ raise NotImplementedError() def __enter__(self): """Enter the watcher's context and allow starting new processes This function must return self""" raise NotImplementedError() def __exit__(self, a, b, c): """Exit the watcher's context""" raise NotImplementedError() class PidfdChildWatcher(AbstractChildWatcher): """Child watcher implementation using Linux's pid file descriptors. This child watcher polls process file descriptors (pidfds) to await child process termination. In some respects, PidfdChildWatcher is a "Goldilocks" child watcher implementation. It doesn't require signals or threads, doesn't interfere with any processes launched outside the event loop, and scales linearly with the number of subprocesses launched by the event loop. The main disadvantage is that pidfds are specific to Linux, and only work on recent (5.3+) kernels. """ def __enter__(self): return self def __exit__(self, exc_type, exc_value, exc_traceback): pass def is_active(self): return True def close(self): pass def attach_loop(self, loop): pass def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() pidfd = os.pidfd_open(pid) loop._add_reader(pidfd, self._do_wait, pid, pidfd, callback, args) def _do_wait(self, pid, pidfd, callback, args): loop = events.get_running_loop() loop._remove_reader(pidfd) try: _, status = os.waitpid(pid, 0) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). returncode = 255 logger.warning( "child process pid %d exit status already read: " " will report returncode 255", pid) else: returncode = waitstatus_to_exitcode(status) os.close(pidfd) callback(pid, returncode, *args) def remove_child_handler(self, pid): # asyncio never calls remove_child_handler() !!! # The method is no-op but is implemented because # abstract base classes require it. return True class BaseChildWatcher(AbstractChildWatcher): def __init__(self): self._loop = None self._callbacks = {} def close(self): self.attach_loop(None) def is_active(self): return self._loop is not None and self._loop.is_running() def _do_waitpid(self, expected_pid): raise NotImplementedError() def _do_waitpid_all(self): raise NotImplementedError() def attach_loop(self, loop): assert loop is None or isinstance(loop, events.AbstractEventLoop) if self._loop is not None and loop is None and self._callbacks: warnings.warn( 'A loop is being detached ' 'from a child watcher with pending handlers', RuntimeWarning) if self._loop is not None: self._loop.remove_signal_handler(signal.SIGCHLD) self._loop = loop if loop is not None: loop.add_signal_handler(signal.SIGCHLD, self._sig_chld) # Prevent a race condition in case a child terminated # during the switch. self._do_waitpid_all() def _sig_chld(self): try: self._do_waitpid_all() except (SystemExit, KeyboardInterrupt): raise except BaseException as exc: # self._loop should always be available here # as '_sig_chld' is added as a signal handler # in 'attach_loop' self._loop.call_exception_handler({ 'message': 'Unknown exception in SIGCHLD handler', 'exception': exc, }) class SafeChildWatcher(BaseChildWatcher): """'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) """ def __init__(self): super().__init__() warnings._deprecated("SafeChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def close(self): self._callbacks.clear() super().close() def __enter__(self): return self def __exit__(self, a, b, c): pass def add_child_handler(self, pid, callback, *args): self._callbacks[pid] = (callback, args) # Prevent a race condition in case the child is already terminated. self._do_waitpid(pid) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): for pid in list(self._callbacks): self._do_waitpid(pid) def _do_waitpid(self, expected_pid): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, os.WNOHANG) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) else: if pid == 0: # The child process is still alive. return returncode = waitstatus_to_exitcode(status) if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) try: callback, args = self._callbacks.pop(pid) except KeyError: # pragma: no cover # May happen if .remove_child_handler() is called # after os.waitpid() returns. if self._loop.get_debug(): logger.warning("Child watcher got an unexpected pid: %r", pid, exc_info=True) else: callback(pid, returncode, *args) class FastChildWatcher(BaseChildWatcher): """'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). """ def __init__(self): super().__init__() self._lock = threading.Lock() self._zombies = {} self._forks = 0 warnings._deprecated("FastChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def close(self): self._callbacks.clear() self._zombies.clear() super().close() def __enter__(self): with self._lock: self._forks += 1 return self def __exit__(self, a, b, c): with self._lock: self._forks -= 1 if self._forks or not self._zombies: return collateral_victims = str(self._zombies) self._zombies.clear() logger.warning( "Caught subprocesses termination from unknown pids: %s", collateral_victims) def add_child_handler(self, pid, callback, *args): assert self._forks, "Must use the context manager" with self._lock: try: returncode = self._zombies.pop(pid) except KeyError: # The child is running. self._callbacks[pid] = callback, args return # The child is dead already. We can fire the callback. callback(pid, returncode, *args) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def _do_waitpid_all(self): # Because of signal coalescing, we must keep calling waitpid() as # long as we're able to reap a child. while True: try: pid, status = os.waitpid(-1, os.WNOHANG) except ChildProcessError: # No more child processes exist. return else: if pid == 0: # A child process is still alive. return returncode = waitstatus_to_exitcode(status) with self._lock: try: callback, args = self._callbacks.pop(pid) except KeyError: # unknown child if self._forks: # It may not be registered yet. self._zombies[pid] = returncode if self._loop.get_debug(): logger.debug('unknown process %s exited ' 'with returncode %s', pid, returncode) continue callback = None else: if self._loop.get_debug(): logger.debug('process %s exited with returncode %s', pid, returncode) if callback is None: logger.warning( "Caught subprocess termination from unknown pid: " "%d -> %d", pid, returncode) else: callback(pid, returncode, *args) class MultiLoopChildWatcher(AbstractChildWatcher): """A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). """ # Implementation note: # The class keeps compatibility with AbstractChildWatcher ABC # To achieve this it has empty attach_loop() method # and doesn't accept explicit loop argument # for add_child_handler()/remove_child_handler() # but retrieves the current loop by get_running_loop() def __init__(self): self._callbacks = {} self._saved_sighandler = None warnings._deprecated("MultiLoopChildWatcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) def is_active(self): return self._saved_sighandler is not None def close(self): self._callbacks.clear() if self._saved_sighandler is None: return handler = signal.getsignal(signal.SIGCHLD) if handler != self._sig_chld: logger.warning("SIGCHLD handler was changed by outside code") else: signal.signal(signal.SIGCHLD, self._saved_sighandler) self._saved_sighandler = None def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): pass def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() self._callbacks[pid] = (loop, callback, args) # Prevent a race condition in case the child is already terminated. self._do_waitpid(pid) def remove_child_handler(self, pid): try: del self._callbacks[pid] return True except KeyError: return False def attach_loop(self, loop): # Don't save the loop but initialize itself if called first time # The reason to do it here is that attach_loop() is called from # unix policy only for the main thread. # Main thread is required for subscription on SIGCHLD signal if self._saved_sighandler is not None: return self._saved_sighandler = signal.signal(signal.SIGCHLD, self._sig_chld) if self._saved_sighandler is None: logger.warning("Previous SIGCHLD handler was set by non-Python code, " "restore to default handler on watcher close.") self._saved_sighandler = signal.SIG_DFL # Set SA_RESTART to limit EINTR occurrences. signal.siginterrupt(signal.SIGCHLD, False) def _do_waitpid_all(self): for pid in list(self._callbacks): self._do_waitpid(pid) def _do_waitpid(self, expected_pid): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, os.WNOHANG) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) debug_log = False else: if pid == 0: # The child process is still alive. return returncode = waitstatus_to_exitcode(status) debug_log = True try: loop, callback, args = self._callbacks.pop(pid) except KeyError: # pragma: no cover # May happen if .remove_child_handler() is called # after os.waitpid() returns. logger.warning("Child watcher got an unexpected pid: %r", pid, exc_info=True) else: if loop.is_closed(): logger.warning("Loop %r that handles pid %r is closed", loop, pid) else: if debug_log and loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) loop.call_soon_threadsafe(callback, pid, returncode, *args) def _sig_chld(self, signum, frame): try: self._do_waitpid_all() except (SystemExit, KeyboardInterrupt): raise except BaseException: logger.warning('Unknown exception in SIGCHLD handler', exc_info=True) class ThreadedChildWatcher(AbstractChildWatcher): """Threaded child watcher implementation. The watcher uses a thread per process for waiting for the process finish. It doesn't require subscription on POSIX signal but a thread creation is not free. The watcher has O(1) complexity, its performance doesn't depend on amount of spawn processes. """ def __init__(self): self._pid_counter = itertools.count(0) self._threads = {} def is_active(self): return True def close(self): pass def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): pass def __del__(self, _warn=warnings.warn): threads = [thread for thread in list(self._threads.values()) if thread.is_alive()] if threads: _warn(f"{self.__class__} has registered but not finished child processes", ResourceWarning, source=self) def add_child_handler(self, pid, callback, *args): loop = events.get_running_loop() thread = threading.Thread(target=self._do_waitpid, name=f"asyncio-waitpid-{next(self._pid_counter)}", args=(loop, pid, callback, args), daemon=True) self._threads[pid] = thread thread.start() def remove_child_handler(self, pid): # asyncio never calls remove_child_handler() !!! # The method is no-op but is implemented because # abstract base classes require it. return True def attach_loop(self, loop): pass def _do_waitpid(self, loop, expected_pid, callback, args): assert expected_pid > 0 try: pid, status = os.waitpid(expected_pid, 0) except ChildProcessError: # The child process is already reaped # (may happen if waitpid() is called elsewhere). pid = expected_pid returncode = 255 logger.warning( "Unknown child process pid %d, will report returncode 255", pid) else: returncode = waitstatus_to_exitcode(status) if loop.get_debug(): logger.debug('process %s exited with returncode %s', expected_pid, returncode) if loop.is_closed(): logger.warning("Loop %r that handles pid %r is closed", loop, pid) else: loop.call_soon_threadsafe(callback, pid, returncode, *args) self._threads.pop(expected_pid) def can_use_pidfd(): if not hasattr(os, 'pidfd_open'): return False try: pid = os.getpid() os.close(os.pidfd_open(pid, 0)) except OSError: # blocked by security policy like SECCOMP return False return True class _UnixDefaultEventLoopPolicy(events.BaseDefaultEventLoopPolicy): """UNIX event loop policy with a watcher for child processes.""" _loop_factory = _UnixSelectorEventLoop def __init__(self): super().__init__() self._watcher = None def _init_watcher(self): with events._lock: if self._watcher is None: # pragma: no branch if can_use_pidfd(): self._watcher = PidfdChildWatcher() else: self._watcher = ThreadedChildWatcher() def set_event_loop(self, loop): """Set the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. """ super().set_event_loop(loop) if (self._watcher is not None and threading.current_thread() is threading.main_thread()): self._watcher.attach_loop(loop) def get_child_watcher(self): """Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. """ if self._watcher is None: self._init_watcher() warnings._deprecated("get_child_watcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) return self._watcher def set_child_watcher(self, watcher): """Set the watcher for child processes.""" assert watcher is None or isinstance(watcher, AbstractChildWatcher) if self._watcher is not None: self._watcher.close() self._watcher = watcher warnings._deprecated("set_child_watcher", "{name!r} is deprecated as of Python 3.12 and will be " "removed in Python {remove}.", remove=(3, 14)) SelectorEventLoop = _UnixSelectorEventLoop DefaultEventLoopPolicy = _UnixDefaultEventLoopPolicy protocols.py000064400000015455152343231170007155 0ustar00"""Abstract Protocol base classes.""" __all__ = ( 'BaseProtocol', 'Protocol', 'DatagramProtocol', 'SubprocessProtocol', 'BufferedProtocol', ) class BaseProtocol: """Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe """ __slots__ = () def connection_made(self, transport): """Called when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. """ def connection_lost(self, exc): """Called when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). """ def pause_writing(self): """Called when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). """ def resume_writing(self): """Called when the transport's buffer drains below the low-water mark. See pause_writing() for details. """ class Protocol(BaseProtocol): """Interface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() """ __slots__ = () def data_received(self, data): """Called when some data is received. The argument is a bytes object. """ def eof_received(self): """Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ class BufferedProtocol(BaseProtocol): """Interface for stream protocol with manual buffer control. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() """ __slots__ = () def get_buffer(self, sizehint): """Called to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. """ def buffer_updated(self, nbytes): """Called when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. """ def eof_received(self): """Called when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. """ class DatagramProtocol(BaseProtocol): """Interface for datagram protocol.""" __slots__ = () def datagram_received(self, data, addr): """Called when some datagram is received.""" def error_received(self, exc): """Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) """ class SubprocessProtocol(BaseProtocol): """Interface for protocol for subprocess calls.""" __slots__ = () def pipe_data_received(self, fd, data): """Called when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. """ def pipe_connection_lost(self, fd, exc): """Called when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. """ def process_exited(self): """Called when subprocess has exited.""" def _feed_data_to_buffered_proto(proto, data): data_len = len(data) while data_len: buf = proto.get_buffer(data_len) buf_len = len(buf) if not buf_len: raise RuntimeError('get_buffer() returned an empty buffer') if buf_len >= data_len: buf[:data_len] = data proto.buffer_updated(data_len) return else: buf[:buf_len] = data[:buf_len] proto.buffer_updated(buf_len) data = data[buf_len:] data_len = len(data) taskgroups.py000064400000022527152343231170007331 0ustar00# Adapted with permission from the EdgeDB project; # license: PSFL. __all__ = ("TaskGroup",) from . import events from . import exceptions from . import tasks class TaskGroup: """Asynchronous context manager for managing groups of tasks. Example use: async with asyncio.TaskGroup() as group: task1 = group.create_task(some_coroutine(...)) task2 = group.create_task(other_coroutine(...)) print("Both tasks have completed now.") All tasks are awaited when the context manager exits. Any exceptions other than `asyncio.CancelledError` raised within a task will cancel all remaining tasks and wait for them to exit. The exceptions are then combined and raised as an `ExceptionGroup`. """ def __init__(self): self._entered = False self._exiting = False self._aborting = False self._loop = None self._parent_task = None self._parent_cancel_requested = False self._tasks = set() self._errors = [] self._base_error = None self._on_completed_fut = None def __repr__(self): info = [''] if self._tasks: info.append(f'tasks={len(self._tasks)}') if self._errors: info.append(f'errors={len(self._errors)}') if self._aborting: info.append('cancelling') elif self._entered: info.append('entered') info_str = ' '.join(info) return f'' async def __aenter__(self): if self._entered: raise RuntimeError( f"TaskGroup {self!r} has already been entered") if self._loop is None: self._loop = events.get_running_loop() self._parent_task = tasks.current_task(self._loop) if self._parent_task is None: raise RuntimeError( f'TaskGroup {self!r} cannot determine the parent task') self._entered = True return self async def __aexit__(self, et, exc, tb): tb = None try: return await self._aexit(et, exc) finally: # Exceptions are heavy objects that can have object # cycles (bad for GC); let's not keep a reference to # a bunch of them. It would be nicer to use a try/finally # in __aexit__ directly but that introduced some diff noise self._parent_task = None self._errors = None self._base_error = None exc = None async def _aexit(self, et, exc): self._exiting = True if (exc is not None and self._is_base_error(exc) and self._base_error is None): self._base_error = exc propagate_cancellation_error = \ exc if et is exceptions.CancelledError else None if self._parent_cancel_requested: # If this flag is set we *must* call uncancel(). if self._parent_task.uncancel() == 0: # If there are no pending cancellations left, # don't propagate CancelledError. propagate_cancellation_error = None if et is not None: if not self._aborting: # Our parent task is being cancelled: # # async with TaskGroup() as g: # g.create_task(...) # await ... # <- CancelledError # # or there's an exception in "async with": # # async with TaskGroup() as g: # g.create_task(...) # 1 / 0 # self._abort() # We use while-loop here because "self._on_completed_fut" # can be cancelled multiple times if our parent task # is being cancelled repeatedly (or even once, when # our own cancellation is already in progress) while self._tasks: if self._on_completed_fut is None: self._on_completed_fut = self._loop.create_future() try: await self._on_completed_fut except exceptions.CancelledError as ex: if not self._aborting: # Our parent task is being cancelled: # # async def wrapper(): # async with TaskGroup() as g: # g.create_task(foo) # # "wrapper" is being cancelled while "foo" is # still running. propagate_cancellation_error = ex self._abort() self._on_completed_fut = None assert not self._tasks if self._base_error is not None: try: raise self._base_error finally: exc = None # Propagate CancelledError if there is one, except if there # are other errors -- those have priority. try: if propagate_cancellation_error and not self._errors: try: raise propagate_cancellation_error finally: exc = None finally: propagate_cancellation_error = None if et is not None and et is not exceptions.CancelledError: self._errors.append(exc) if self._errors: try: raise BaseExceptionGroup( 'unhandled errors in a TaskGroup', self._errors, ) from None finally: exc = None def create_task(self, coro, *, name=None, context=None): """Create a new task in this group and return it. Similar to `asyncio.create_task`. """ if not self._entered: raise RuntimeError(f"TaskGroup {self!r} has not been entered") if self._exiting and not self._tasks: raise RuntimeError(f"TaskGroup {self!r} is finished") if self._aborting: raise RuntimeError(f"TaskGroup {self!r} is shutting down") if context is None: task = self._loop.create_task(coro) else: task = self._loop.create_task(coro, context=context) tasks._set_task_name(task, name) # Always schedule the done callback even if the task is # already done (e.g. if the coro was able to complete eagerly), # otherwise if the task completes with an exception then it will cancel # the current task too early. gh-128550, gh-128588 self._tasks.add(task) task.add_done_callback(self._on_task_done) try: return task finally: # gh-128552: prevent a refcycle of # task.exception().__traceback__->TaskGroup.create_task->task del task # Since Python 3.8 Tasks propagate all exceptions correctly, # except for KeyboardInterrupt and SystemExit which are # still considered special. def _is_base_error(self, exc: BaseException) -> bool: assert isinstance(exc, BaseException) return isinstance(exc, (SystemExit, KeyboardInterrupt)) def _abort(self): self._aborting = True for t in self._tasks: if not t.done(): t.cancel() def _on_task_done(self, task): self._tasks.discard(task) if self._on_completed_fut is not None and not self._tasks: if not self._on_completed_fut.done(): self._on_completed_fut.set_result(True) if task.cancelled(): return exc = task.exception() if exc is None: return self._errors.append(exc) if self._is_base_error(exc) and self._base_error is None: self._base_error = exc if self._parent_task.done(): # Not sure if this case is possible, but we want to handle # it anyways. self._loop.call_exception_handler({ 'message': f'Task {task!r} has errored out but its parent ' f'task {self._parent_task} is already completed', 'exception': exc, 'task': task, }) return if not self._aborting and not self._parent_cancel_requested: # If parent task *is not* being cancelled, it means that we want # to manually cancel it to abort whatever is being run right now # in the TaskGroup. But we want to mark parent task as # "not cancelled" later in __aexit__. Example situation that # we need to handle: # # async def foo(): # try: # async with TaskGroup() as g: # g.create_task(crash_soon()) # await something # <- this needs to be canceled # # by the TaskGroup, e.g. # # foo() needs to be cancelled # except Exception: # # Ignore any exceptions raised in the TaskGroup # pass # await something_else # this line has to be called # # after TaskGroup is finished. self._abort() self._parent_cancel_requested = True self._parent_task.cancel() coroutines.py000064400000006416152343231170007320 0ustar00__all__ = 'iscoroutinefunction', 'iscoroutine' import collections.abc import inspect import os import sys import types def _is_debug_mode(): # See: https://docs.python.org/3/library/asyncio-dev.html#asyncio-debug-mode. return sys.flags.dev_mode or (not sys.flags.ignore_environment and bool(os.environ.get('PYTHONASYNCIODEBUG'))) # A marker for iscoroutinefunction. _is_coroutine = object() def iscoroutinefunction(func): """Return True if func is a decorated coroutine function.""" return (inspect.iscoroutinefunction(func) or getattr(func, '_is_coroutine', None) is _is_coroutine) # Prioritize native coroutine check to speed-up # asyncio.iscoroutine. _COROUTINE_TYPES = (types.CoroutineType, collections.abc.Coroutine) _iscoroutine_typecache = set() def iscoroutine(obj): """Return True if obj is a coroutine object.""" if type(obj) in _iscoroutine_typecache: return True if isinstance(obj, _COROUTINE_TYPES): # Just in case we don't want to cache more than 100 # positive types. That shouldn't ever happen, unless # someone stressing the system on purpose. if len(_iscoroutine_typecache) < 100: _iscoroutine_typecache.add(type(obj)) return True else: return False def _format_coroutine(coro): assert iscoroutine(coro) def get_name(coro): # Coroutines compiled with Cython sometimes don't have # proper __qualname__ or __name__. While that is a bug # in Cython, asyncio shouldn't crash with an AttributeError # in its __repr__ functions. if hasattr(coro, '__qualname__') and coro.__qualname__: coro_name = coro.__qualname__ elif hasattr(coro, '__name__') and coro.__name__: coro_name = coro.__name__ else: # Stop masking Cython bugs, expose them in a friendly way. coro_name = f'<{type(coro).__name__} without __name__>' return f'{coro_name}()' def is_running(coro): try: return coro.cr_running except AttributeError: try: return coro.gi_running except AttributeError: return False coro_code = None if hasattr(coro, 'cr_code') and coro.cr_code: coro_code = coro.cr_code elif hasattr(coro, 'gi_code') and coro.gi_code: coro_code = coro.gi_code coro_name = get_name(coro) if not coro_code: # Built-in types might not have __qualname__ or __name__. if is_running(coro): return f'{coro_name} running' else: return coro_name coro_frame = None if hasattr(coro, 'gi_frame') and coro.gi_frame: coro_frame = coro.gi_frame elif hasattr(coro, 'cr_frame') and coro.cr_frame: coro_frame = coro.cr_frame # If Cython's coroutine has a fake code object without proper # co_filename -- expose that. filename = coro_code.co_filename or '' lineno = 0 if coro_frame is not None: lineno = coro_frame.f_lineno coro_repr = f'{coro_name} running at {filename}:{lineno}' else: lineno = coro_code.co_firstlineno coro_repr = f'{coro_name} done, defined at {filename}:{lineno}' return coro_repr __init__.py000064400000002304152343231170006655 0ustar00"""The asyncio package, tracking PEP 3156.""" # flake8: noqa import sys # This relies on each of the submodules having an __all__ variable. from .base_events import * from .coroutines import * from .events import * from .exceptions import * from .futures import * from .locks import * from .protocols import * from .runners import * from .queues import * from .streams import * from .subprocess import * from .tasks import * from .taskgroups import * from .timeouts import * from .threads import * from .transports import * __all__ = (base_events.__all__ + coroutines.__all__ + events.__all__ + exceptions.__all__ + futures.__all__ + locks.__all__ + protocols.__all__ + runners.__all__ + queues.__all__ + streams.__all__ + subprocess.__all__ + tasks.__all__ + taskgroups.__all__ + threads.__all__ + timeouts.__all__ + transports.__all__) if sys.platform == 'win32': # pragma: no cover from .windows_events import * __all__ += windows_events.__all__ else: from .unix_events import * # pragma: no cover __all__ += unix_events.__all__ locks.py000064400000045063152343231170006242 0ustar00"""Synchronization primitives.""" __all__ = ('Lock', 'Event', 'Condition', 'Semaphore', 'BoundedSemaphore', 'Barrier') import collections import enum from . import exceptions from . import mixins class _ContextManagerMixin: async def __aenter__(self): await self.acquire() # We have no use for the "as ..." clause in the with # statement for locks. return None async def __aexit__(self, exc_type, exc, tb): self.release() class Lock(_ContextManagerMixin, mixins._LoopBoundMixin): """Primitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... """ def __init__(self): self._waiters = None self._locked = False def __repr__(self): res = super().__repr__() extra = 'locked' if self._locked else 'unlocked' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def locked(self): """Return True if lock is acquired.""" return self._locked async def acquire(self): """Acquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. """ if (not self._locked and (self._waiters is None or all(w.cancelled() for w in self._waiters))): self._locked = True return True if self._waiters is None: self._waiters = collections.deque() fut = self._get_loop().create_future() self._waiters.append(fut) # Finally block should be called before the CancelledError # handling as we don't want CancelledError to call # _wake_up_first() and attempt to wake up itself. try: try: await fut finally: self._waiters.remove(fut) except exceptions.CancelledError: if not self._locked: self._wake_up_first() raise self._locked = True return True def release(self): """Release a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. """ if self._locked: self._locked = False self._wake_up_first() else: raise RuntimeError('Lock is not acquired.') def _wake_up_first(self): """Wake up the first waiter if it isn't done.""" if not self._waiters: return try: fut = next(iter(self._waiters)) except StopIteration: return # .done() necessarily means that a waiter will wake up later on and # either take the lock, or, if it was cancelled and lock wasn't # taken already, will hit this again and wake up a new waiter. if not fut.done(): fut.set_result(True) class Event(mixins._LoopBoundMixin): """Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. """ def __init__(self): self._waiters = collections.deque() self._value = False def __repr__(self): res = super().__repr__() extra = 'set' if self._value else 'unset' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def is_set(self): """Return True if and only if the internal flag is true.""" return self._value def set(self): """Set the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. """ if not self._value: self._value = True for fut in self._waiters: if not fut.done(): fut.set_result(True) def clear(self): """Reset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.""" self._value = False async def wait(self): """Block until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. """ if self._value: return True fut = self._get_loop().create_future() self._waiters.append(fut) try: await fut return True finally: self._waiters.remove(fut) class Condition(_ContextManagerMixin, mixins._LoopBoundMixin): """Asynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. """ def __init__(self, lock=None): if lock is None: lock = Lock() self._lock = lock # Export the lock's locked(), acquire() and release() methods. self.locked = lock.locked self.acquire = lock.acquire self.release = lock.release self._waiters = collections.deque() def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else 'unlocked' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' async def wait(self): """Wait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. """ if not self.locked(): raise RuntimeError('cannot wait on un-acquired lock') self.release() try: fut = self._get_loop().create_future() self._waiters.append(fut) try: await fut return True finally: self._waiters.remove(fut) finally: # Must reacquire lock even if wait is cancelled cancelled = False while True: try: await self.acquire() break except exceptions.CancelledError: cancelled = True if cancelled: raise exceptions.CancelledError async def wait_for(self, predicate): """Wait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. """ result = predicate() while not result: await self.wait() result = predicate() return result def notify(self, n=1): """By default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. """ if not self.locked(): raise RuntimeError('cannot notify on un-acquired lock') idx = 0 for fut in self._waiters: if idx >= n: break if not fut.done(): idx += 1 fut.set_result(False) def notify_all(self): """Wake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. """ self.notify(len(self._waiters)) class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin): """A Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. """ def __init__(self, value=1): if value < 0: raise ValueError("Semaphore initial value must be >= 0") self._waiters = None self._value = value def __repr__(self): res = super().__repr__() extra = 'locked' if self.locked() else f'unlocked, value:{self._value}' if self._waiters: extra = f'{extra}, waiters:{len(self._waiters)}' return f'<{res[1:-1]} [{extra}]>' def locked(self): """Returns True if semaphore cannot be acquired immediately.""" return self._value == 0 or ( any(not w.cancelled() for w in (self._waiters or ()))) async def acquire(self): """Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. """ if not self.locked(): self._value -= 1 return True if self._waiters is None: self._waiters = collections.deque() fut = self._get_loop().create_future() self._waiters.append(fut) # Finally block should be called before the CancelledError # handling as we don't want CancelledError to call # _wake_up_first() and attempt to wake up itself. try: try: await fut finally: self._waiters.remove(fut) except exceptions.CancelledError: if not fut.cancelled(): self._value += 1 self._wake_up_next() raise if self._value > 0: self._wake_up_next() return True def release(self): """Release a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. """ self._value += 1 self._wake_up_next() def _wake_up_next(self): """Wake up the first waiter that isn't done.""" if not self._waiters: return for fut in self._waiters: if not fut.done(): self._value -= 1 fut.set_result(True) return class BoundedSemaphore(Semaphore): """A bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. """ def __init__(self, value=1): self._bound_value = value super().__init__(value) def release(self): if self._value >= self._bound_value: raise ValueError('BoundedSemaphore released too many times') super().release() class _BarrierState(enum.Enum): FILLING = 'filling' DRAINING = 'draining' RESETTING = 'resetting' BROKEN = 'broken' class Barrier(mixins._LoopBoundMixin): """Asyncio equivalent to threading.Barrier Implements a Barrier primitive. Useful for synchronizing a fixed number of tasks at known synchronization points. Tasks block on 'wait()' and are simultaneously awoken once they have all made their call. """ def __init__(self, parties): """Create a barrier, initialised to 'parties' tasks.""" if parties < 1: raise ValueError('parties must be >= 1') self._cond = Condition() # notify all tasks when state changes self._parties = parties self._state = _BarrierState.FILLING self._count = 0 # count tasks in Barrier def __repr__(self): res = super().__repr__() extra = f'{self._state.value}' if not self.broken: extra += f', waiters:{self.n_waiting}/{self.parties}' return f'<{res[1:-1]} [{extra}]>' async def __aenter__(self): # wait for the barrier reaches the parties number # when start draining release and return index of waited task return await self.wait() async def __aexit__(self, *args): pass async def wait(self): """Wait for the barrier. When the specified number of tasks have started waiting, they are all simultaneously awoken. Returns an unique and individual index number from 0 to 'parties-1'. """ async with self._cond: await self._block() # Block while the barrier drains or resets. try: index = self._count self._count += 1 if index + 1 == self._parties: # We release the barrier await self._release() else: await self._wait() return index finally: self._count -= 1 # Wake up any tasks waiting for barrier to drain. self._exit() async def _block(self): # Block until the barrier is ready for us, # or raise an exception if it is broken. # # It is draining or resetting, wait until done # unless a CancelledError occurs await self._cond.wait_for( lambda: self._state not in ( _BarrierState.DRAINING, _BarrierState.RESETTING ) ) # see if the barrier is in a broken state if self._state is _BarrierState.BROKEN: raise exceptions.BrokenBarrierError("Barrier aborted") async def _release(self): # Release the tasks waiting in the barrier. # Enter draining state. # Next waiting tasks will be blocked until the end of draining. self._state = _BarrierState.DRAINING self._cond.notify_all() async def _wait(self): # Wait in the barrier until we are released. Raise an exception # if the barrier is reset or broken. # wait for end of filling # unless a CancelledError occurs await self._cond.wait_for(lambda: self._state is not _BarrierState.FILLING) if self._state in (_BarrierState.BROKEN, _BarrierState.RESETTING): raise exceptions.BrokenBarrierError("Abort or reset of barrier") def _exit(self): # If we are the last tasks to exit the barrier, signal any tasks # waiting for the barrier to drain. if self._count == 0: if self._state in (_BarrierState.RESETTING, _BarrierState.DRAINING): self._state = _BarrierState.FILLING self._cond.notify_all() async def reset(self): """Reset the barrier to the initial state. Any tasks currently waiting will get the BrokenBarrier exception raised. """ async with self._cond: if self._count > 0: if self._state is not _BarrierState.RESETTING: #reset the barrier, waking up tasks self._state = _BarrierState.RESETTING else: self._state = _BarrierState.FILLING self._cond.notify_all() async def abort(self): """Place the barrier into a 'broken' state. Useful in case of error. Any currently waiting tasks and tasks attempting to 'wait()' will have BrokenBarrierError raised. """ async with self._cond: self._state = _BarrierState.BROKEN self._cond.notify_all() @property def parties(self): """Return the number of tasks required to trip the barrier.""" return self._parties @property def n_waiting(self): """Return the number of tasks currently waiting at the barrier.""" if self._state is _BarrierState.FILLING: return self._count return 0 @property def broken(self): """Return True if the barrier is in a broken state.""" return self._state is _BarrierState.BROKEN futures.py000064400000034004152343231170006615 0ustar00"""A Future class similar to the one in PEP 3148.""" __all__ = ( 'Future', 'wrap_future', 'isfuture', ) import concurrent.futures import contextvars import logging import sys from types import GenericAlias from . import base_futures from . import events from . import exceptions from . import format_helpers isfuture = base_futures.isfuture _PENDING = base_futures._PENDING _CANCELLED = base_futures._CANCELLED _FINISHED = base_futures._FINISHED STACK_DEBUG = logging.DEBUG - 1 # heavy-duty debugging class Future: """This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) """ # Class variables serving as defaults for instance variables. _state = _PENDING _result = None _exception = None _loop = None _source_traceback = None _cancel_message = None # A saved CancelledError for later chaining as an exception context. _cancelled_exc = None # This field is used for a dual purpose: # - Its presence is a marker to declare that a class implements # the Future protocol (i.e. is intended to be duck-type compatible). # The value must also be not-None, to enable a subclass to declare # that it is not compatible by setting this to None. # - It is set by __iter__() below so that Task._step() can tell # the difference between # `await Future()` or`yield from Future()` (correct) vs. # `yield Future()` (incorrect). _asyncio_future_blocking = False __log_traceback = False def __init__(self, *, loop=None): """Initialize the future. The optional event_loop argument allows explicitly setting the event loop object used by the future. If it's not provided, the future uses the default event loop. """ if loop is None: self._loop = events.get_event_loop() else: self._loop = loop self._callbacks = [] if self._loop.get_debug(): self._source_traceback = format_helpers.extract_stack( sys._getframe(1)) def __repr__(self): return base_futures._future_repr(self) def __del__(self): if not self.__log_traceback: # set_exception() was not called, or result() or exception() # has consumed the exception return exc = self._exception context = { 'message': f'{self.__class__.__name__} exception was never retrieved', 'exception': exc, 'future': self, } if self._source_traceback: context['source_traceback'] = self._source_traceback self._loop.call_exception_handler(context) __class_getitem__ = classmethod(GenericAlias) @property def _log_traceback(self): return self.__log_traceback @_log_traceback.setter def _log_traceback(self, val): if val: raise ValueError('_log_traceback can only be set to False') self.__log_traceback = False def get_loop(self): """Return the event loop the Future is bound to.""" loop = self._loop if loop is None: raise RuntimeError("Future object is not initialized.") return loop def _make_cancelled_error(self): """Create the CancelledError to raise if the Future is cancelled. This should only be called once when handling a cancellation since it erases the saved context exception value. """ if self._cancelled_exc is not None: exc = self._cancelled_exc self._cancelled_exc = None return exc if self._cancel_message is None: exc = exceptions.CancelledError() else: exc = exceptions.CancelledError(self._cancel_message) exc.__context__ = self._cancelled_exc # Remove the reference since we don't need this anymore. self._cancelled_exc = None return exc def cancel(self, msg=None): """Cancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. """ self.__log_traceback = False if self._state != _PENDING: return False self._state = _CANCELLED self._cancel_message = msg self.__schedule_callbacks() return True def __schedule_callbacks(self): """Internal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. """ callbacks = self._callbacks[:] if not callbacks: return self._callbacks[:] = [] for callback, ctx in callbacks: self._loop.call_soon(callback, self, context=ctx) def cancelled(self): """Return True if the future was cancelled.""" return self._state == _CANCELLED # Don't implement running(); see http://bugs.python.org/issue18699 def done(self): """Return True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. """ return self._state != _PENDING def result(self): """Return the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. """ if self._state == _CANCELLED: raise self._make_cancelled_error() if self._state != _FINISHED: raise exceptions.InvalidStateError('Result is not ready.') self.__log_traceback = False if self._exception is not None: raise self._exception.with_traceback(self._exception_tb) return self._result def exception(self): """Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. """ if self._state == _CANCELLED: raise self._make_cancelled_error() if self._state != _FINISHED: raise exceptions.InvalidStateError('Exception is not set.') self.__log_traceback = False return self._exception def add_done_callback(self, fn, *, context=None): """Add a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. """ if self._state != _PENDING: self._loop.call_soon(fn, self, context=context) else: if context is None: context = contextvars.copy_context() self._callbacks.append((fn, context)) # New method not in PEP 3148. def remove_done_callback(self, fn): """Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. """ filtered_callbacks = [(f, ctx) for (f, ctx) in self._callbacks if f != fn] removed_count = len(self._callbacks) - len(filtered_callbacks) if removed_count: self._callbacks[:] = filtered_callbacks return removed_count # So-called internal methods (note: no set_running_or_notify_cancel()). def set_result(self, result): """Mark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise exceptions.InvalidStateError(f'{self._state}: {self!r}') self._result = result self._state = _FINISHED self.__schedule_callbacks() def set_exception(self, exception): """Mark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. """ if self._state != _PENDING: raise exceptions.InvalidStateError(f'{self._state}: {self!r}') if isinstance(exception, type): exception = exception() if isinstance(exception, StopIteration): new_exc = RuntimeError("StopIteration interacts badly with " "generators and cannot be raised into a " "Future") new_exc.__cause__ = exception new_exc.__context__ = exception exception = new_exc self._exception = exception self._exception_tb = exception.__traceback__ self._state = _FINISHED self.__schedule_callbacks() self.__log_traceback = True def __await__(self): if not self.done(): self._asyncio_future_blocking = True yield self # This tells Task to wait for completion. if not self.done(): raise RuntimeError("await wasn't used with future") return self.result() # May raise too. __iter__ = __await__ # make compatible with 'yield from'. # Needed for testing purposes. _PyFuture = Future def _get_loop(fut): # Tries to call Future.get_loop() if it's available. # Otherwise fallbacks to using the old '_loop' property. try: get_loop = fut.get_loop except AttributeError: pass else: return get_loop() return fut._loop def _set_result_unless_cancelled(fut, result): """Helper setting the result only if the future was not cancelled.""" if fut.cancelled(): return fut.set_result(result) def _convert_future_exc(exc): exc_class = type(exc) if exc_class is concurrent.futures.CancelledError: return exceptions.CancelledError(*exc.args) elif exc_class is concurrent.futures.TimeoutError: return exceptions.TimeoutError(*exc.args) elif exc_class is concurrent.futures.InvalidStateError: return exceptions.InvalidStateError(*exc.args) else: return exc def _set_concurrent_future_state(concurrent, source): """Copy state from a future to a concurrent.futures.Future.""" assert source.done() if source.cancelled(): concurrent.cancel() if not concurrent.set_running_or_notify_cancel(): return exception = source.exception() if exception is not None: concurrent.set_exception(_convert_future_exc(exception)) else: result = source.result() concurrent.set_result(result) def _copy_future_state(source, dest): """Internal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. """ assert source.done() if dest.cancelled(): return assert not dest.done() if source.cancelled(): dest.cancel() else: exception = source.exception() if exception is not None: dest.set_exception(_convert_future_exc(exception)) else: result = source.result() dest.set_result(result) def _chain_future(source, destination): """Chain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. """ if not isfuture(source) and not isinstance(source, concurrent.futures.Future): raise TypeError('A future is required for source argument') if not isfuture(destination) and not isinstance(destination, concurrent.futures.Future): raise TypeError('A future is required for destination argument') source_loop = _get_loop(source) if isfuture(source) else None dest_loop = _get_loop(destination) if isfuture(destination) else None def _set_state(future, other): if isfuture(future): _copy_future_state(other, future) else: _set_concurrent_future_state(future, other) def _call_check_cancel(destination): if destination.cancelled(): if source_loop is None or source_loop is dest_loop: source.cancel() else: source_loop.call_soon_threadsafe(source.cancel) def _call_set_state(source): if (destination.cancelled() and dest_loop is not None and dest_loop.is_closed()): return if dest_loop is None or dest_loop is source_loop: _set_state(destination, source) else: if dest_loop.is_closed(): return dest_loop.call_soon_threadsafe(_set_state, destination, source) destination.add_done_callback(_call_check_cancel) source.add_done_callback(_call_set_state) def wrap_future(future, *, loop=None): """Wrap concurrent.futures.Future object.""" if isfuture(future): return future assert isinstance(future, concurrent.futures.Future), \ f'concurrent.futures.Future is expected, got {future!r}' if loop is None: loop = events.get_event_loop() new_future = loop.create_future() _chain_future(future, new_future) return new_future try: import _asyncio except ImportError: pass else: # _CFuture is needed for tests. Future = _CFuture = _asyncio.Future __pycache__/coroutines.cpython-36.opt-1.pyc000064400000020376152343301150014540 0ustar003 \+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r */usr/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCs>||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGs4tj}|j}|jj|jtkr(|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr!r/Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r9szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r:szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r;szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r<szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr=r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rAszCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rr r r r=szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rBszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rCszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rDszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr:rDrz%r was never yielded fromr)zB Coroutine object created at (most recent call last, truncated to z last lines): r+) r*r4joinr8 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr/msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr0rr_YIELD_FROM_BUGrr6r9propertyr:r;r<rZPY35r@rAr=rBrCrDrLr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r ZisfutureinspectZ isgenerator isinstancer$ _AwaitableABCr@AttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..coroNcs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr+)r$r)r*rr)rSkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionrOisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rXr )r"r r rs   cCst|ddtkpt|S)z6Return True if func is a decorated coroutine function.r_N)r*r_rY)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rP_COROUTINE_TYPES)objr r r rsc Cst|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk r~y |j}Wntk rxYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkrt j |fi}d}t|dr|jr|j}nt|dr|jr|j}d}t|dr0|jr0|j}nt|d rJ|jrJ|j}d }|rb|jrb|j}d }|}t|t rtj|j  r|j dk rt j|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r|j}d |||f}|S)NrCr<rrz{}()Fz {} runningrDr:zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr?rBrRr;rPr$r rrZ_format_callbackrCr<rDr: co_filenamerOrZZ_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor.sourcer r r r,sx              r,).__all__r[rOZopcodeosr'r8typesrErrrr logr Zopmapr5flagsignore_environmentboolenvirongetr]rr^ CoroutineTypeZ_types_CoroutineTyperRrrYcollections.abcrZ _CoroutineABCrrQ ImportErrorr#rMr%r$objectr_ GeneratorTyper`rr,r r r r sZ         j:     __pycache__/__init__.cpython-36.opt-2.pyc000064400000001324152343301150014076 0ustar003 \@s>ddlZyddlmZWnek r4ddlZYnXejdkrnyddlmZWnek rlddlZYnXddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTejejeje je je je je jejejejZejdkr(ddlTeej7ZnddlTeej7ZdS)N) selectorsZwin32) _overlapped)*)sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r (/usr/lib64/python3.6/asyncio/__init__.pys6  :  __pycache__/proactor_events.cpython-36.opt-2.pyc000064400000037557152343301150015575 0ustar003 \O@sdgZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lm Z dd l m Z Gd d d e j e j ZGd ddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercs~eZdZdfdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ dddZ ddZddZddZZS)_ProactorBasePipeTransportNcstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__//usr/lib64/python3.6/asyncio/proactor_events.pyr s$    z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jdk rN|jd|jj|jdk rh|jd|j|jdk r|jd|j|jrt |j}|jd||j r|jddd j |S) Nclosedclosingzfd=%szread=%szwrite=%rzwrite_bufsize=%sz EOF writtenz<%s> ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs8eZdZd fdd ZddZddZd dd ZZS) _ProactorReadPipeTransportNcs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrQrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrQrRrrrSrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z"yH|dk r0d|_|j}|jr>d}dS|dkrJdS|jjj|jd|_Wnt k r}z2|js|j |dn|jj rt j dddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r}z|j |dWYdd}~Xn0tjk r&|js"YnX|jj|jWd|rN|jj|n:|dk r|jj rpt j d||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rQrRrresultrr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrSrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rSsH     z(_ProactorReadPipeTransport._loop_reading)NNN)N)r(rMrNr rTrUrSrOr#r#)r"r$rPs  rPc@s6eZdZddZd ddZddZdd Zd d ZdS) _ProactorBaseWritePipeTransportcCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr rhZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rrvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJrn)rr#r#r$rsys   z"_ProactorSocketTransport.write_eof)NNN)r(rMrNr rrrrsrOr#r#)r"r$r}\s r}cseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rX _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r})rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler|Z SSLProtocolr}Z_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r{)rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rP)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)ru)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningrg is_closed_stop_accept_futures_close_self_piperXr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rXrY)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rXro)rrr`r#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rXZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rXaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r|)rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rWrXrYrrr] ExceptionrDrr^r)rrqrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rro)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr~)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rWZ_debugr rCrrrrXrr\r*rDr7rr]rr^)rqZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrX _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrOr#r#)r"r$rs4          ()__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrPZWriteTransportraruZ Transportr{r}Z BaseEventLooprr#r#r#r$s0        M T  #__pycache__/protocols.cpython-36.pyc000064400000013533152343301150013430 0ustar003 \@sRdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s0eZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr)/usr/lib64/python3.6/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs c@s eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>sc@s eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgsc@s(eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrtsN)r__all__rrrrrrrrs 7) __pycache__/compat.cpython-36.pyc000064400000001336152343301150012665 0ustar003 \@s6dZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCstsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar &/usr/lib64/python3.6/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s    __pycache__/constants.cpython-36.pyc000064400000000375152343301150013420 0ustar003 \s@sdZdZdZdZdS)z Constants. N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr)/usr/lib64/python3.6/asyncio/constants.pys__pycache__/tasks.cpython-36.opt-2.pyc000064400000027356152343301150013501 0ustar003 \a @sdddddddddd d d d g Zd dlZd dlZd dlZd dlZd dlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddl m Z Gddde jZeZy d dlZWnek rYn XejZZej jZej jZej jZe ddedddZddZe ddddZe ddZdddd dZe d.ddd!dZddd"d#Zeed<de_[ddd$d Z e d%d&Z!Gd'd(d(e jZ"dd)d*d+d Z#ddd,d Z$d-d Z%dS)/TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZejZiZdZedddZ edddZ ddfdd Z e j rTd d Zd d ZddddZdddddZddZdfdd ZddZZS)rTNcCs|dkrtj}|jj|S)N)rget_event_loop_current_tasksget)clsloopr%/usr/lib64/python3.6/asyncio/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsNtj|d|jr|jd=||_d|_d|_|jj|j|j j j |dS)N)rrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r-rrr&Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr'rZcall_exception_handlerFuture__del__)r/contextrrrr5Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r/rrr _repr_info^szTask._repr_info)limitcCs tj||S)N)rZ_task_get_stack)r/r8rrr get_stackaszTask.get_stack)r8filecCstj|||S)N)rZ_task_print_stack)r/r8r:rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)NFT)Z_log_tracebackdoner)cancelr*)r/rrrr=s  z Task.cancelcsf|jr t|tjstj}d|_|j}d|_||jj|j<zy"|dkrT|j d}n |j |}Wnt k r}z.|jrd|_|j tjn |j |jWYdd}~Xntjk rtjYn|tk r}z|j |WYdd}~XnPtk r(}z|j |WYdd}~Xn Xt|dd}|dk r|j|jk rl|jj|jtdj||n||r||kr|jj|jtdj|n2d|_|j|j||_|jr|jjrd|_n|jj|jtdj||n^|dkr|jj|jnDtj|r.|jj|jtdj||n|jj|jtdj|Wd|jjj|jd}XdS)NF_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r* isinstancerCancelledErrorr(r)r-rrsendthrow StopIteration set_exception set_resultvaluer%r= Exception BaseExceptiongetattrr+r, RuntimeErrorformatr>add_done_callback_wakeupinspectZ isgeneratorpop)r/excr0resultZblocking)r-rrr,s~           z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rQrGr,)r/futurerPrrrrMs  z Task._wakeup)N)N)N)__name__ __module__ __qualname__weakrefWeakSetr"rr3 classmethodrr#r&rZPY34r5r7r9r;r=r,rM __classcell__rr)r-rrs      !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)Nz expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}csh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturer iscoroutine TypeErrortyperS ValueErrorrrrrKrrset_wait)fsrrZr[r)rrrscGs|js|jddS)N)r<rE)waiterargsrrr_release_waiter<srg)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)N)r)rr create_future call_laterrg functoolspartialr rLrr@remove_done_callbackr=r<rQ TimeoutError)futrZrretimeout_handlecbrrrrAs,       c #s|jd|dk r"|j|tt|fdd}x|D]}|j|qBWzEdHWddk rtjXtt}}x4|D],}|j||jr|j |q|j |qW||fS)Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr=r<rE)r\)counterr[rorerr_on_completion|s z_wait.._on_completion) rhrirglenrLr=rbrlr<r.)rdrZr[rrtr\r<pendingr)rsr[rorerrcos&     rc)rrZc#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd}fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS) Nz expect a list of futures, not %scsh|]}t|dqS))r)r )rr\)rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)rl put_nowaitclear)r\)rtr<todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)removerxr=)r\)r<rorzrrrts   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrmrQ)r\)r<rr _wait_for_onesz#as_completed.._wait_for_one)rr]rr^r_r`rSrrrbZqueuesrwrrLrirangeru)rdrrZrwr{r}r\_r)rtr<rrorzrrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)Nr)rrrhrrirZ_set_result_unless_cancelledr=)ZdelayrQrrRhrrrrs cCstjdtddt||dS)Nz;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr]rrarr^rrZ create_taskr'rZPY35rNZ isawaitabler _wrap_awaitabler_)rrr1rrrr s   ccs|jEdHS)N) __await__)Z awaitablerrrrsrcs*eZdZddfdd ZddZZS)_GatheringFutureN)rcstj|d||_d|_dS)N)rF)r%r& _children_cancel_requested)r/childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r<rr=r)r/ZretZchildrrrr=)s z_GatheringFuture.cancel)rSrTrUr&r=rYrr)r-rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd}x&t |D]\}}|jtj||qWS) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r<rqrrrr@rDZ _exceptionZ_resultrrE)irnres) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrhrErbrr]r rr3rarur enumeraterLrjrk)rrZcoros_or_futuresrrnrrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)N)rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rqrrr=rDrErQ)innerrP)rrrrs  zshield.._done_callback)r r<rrhrL)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)NzA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rGZset_running_or_notify_cancelrD)rP)r0rRrrrcallbacks  z*run_coroutine_threadsafe..callback)rr^r_ concurrentrr4Zcall_soon_threadsafe)r0rrr)r0rRrrr s    )N)&__all__Zconcurrent.futuresrrjrNrrVrrrrrrr4rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrgrrcrrrglobalsrSr rrr r r rrrrsX        s  - -8  W5__pycache__/base_events.cpython-36.opt-2.pyc000064400000075031152343301150014643 0ustar003 \@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlmZddlmZddlmZddlmZddlmZddlmZdd lmZd gZd Zd ZeeefZe ed Z!d(Z"ddZ#ddZ$ddZ%ddZ&ddZ'ddZ(dej)dddddZ*e edrNd d!Z+nd"d!Z+d#d$Z,Gd%d&d&ej-Z.Gd'd d ej/Z0dS))N)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr+/usr/lib64/python3.6/asyncio/base_events.py_format_handle?s rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeHs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)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_SOCKETrOSError)sockrrr_set_reuseportQs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket\s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_sockeths r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infopsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*|jdS)Nrr)rVrU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr^)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr^s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrcrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r]r_r`r^rrdrrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMd d d d dXdYdZZ.ed[d\Z/ede0j1e0j2d d]d d d d^d_d`Z3ed dadbdcZ4edddeZ5edfdgZ6dhdiZ7ee8j9e8j9e8j9ddjdMdkdldmZ:ee8j9e8j9e8j9dddMdkdndoZ;dpdqZdvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\ s zBaseEventLoop.__repr__cCs tj|dS)N)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)N)rHr) _check_closedr~rr_source_traceback)rXcoroZtaskrrr create_task)s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)Nz'task factory must be a callable or None)callabler5r~)rXfactoryrrrset_task_factory7s zBaseEventLoop.set_task_factorycCs|jS)N)r~)rXrrrget_task_factoryEszBaseEventLoop.get_task_factoryN)extraservercCstdS)N)NotImplementedError)rXr%protocolrcrrrrr_make_socket_transportIsz$BaseEventLoop._make_socket_transportF) server_sideserver_hostnamerrc CstdS)N)r) rXZrawsockr sslcontextrcrrrrrrr_make_ssl_transportNsz!BaseEventLoop._make_ssl_transportcCstdS)N)r)rXr%rrGrcrrrr_make_datagram_transportTsz&BaseEventLoop._make_datagram_transportcCstdS)N)r)rXpiperrcrrrr_make_read_pipe_transportYsz'BaseEventLoop._make_read_pipe_transportcCstdS)N)r)rXrrrcrrrr_make_write_pipe_transport^sz(BaseEventLoop._make_write_pipe_transportc KstdS)N)r) rXrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportcsz(BaseEventLoop._make_subprocess_transportcCstdS)N)r)rXrrr_write_to_selfjszBaseEventLoop._write_to_selfcCstdS)N)r)rX event_listrrr_process_eventssszBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rj RuntimeError)rXrrrrwszBaseEventLoop._check_closedcCs*|jj||js&|j|j|jdS)N)rdiscardrcall_soon_threadsaferaclose)rXagenrrr_asyncgen_finalizer_hook{s z&BaseEventLoop._asyncgen_finalizer_hookcCs,|jrtjdj|t|d|jj|dS)NzNasynchronous generator {!r} was scheduled after loop.shutdown_asyncgens() call)source)rwarningswarnformatResourceWarningradd)rXrrrr_asyncgen_firstiter_hooks  z&BaseEventLoop._asyncgen_firstiter_hookccsd|_|jdkst|j r dSt|j}|jjtjdd|Dd|d}|EdH}x8t||D]*\}}t|t rf|j dj |||dqfWdS)NTcSsg|] }|jqSr)r).0Zagrrr sz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrqrrvrhset_asyncgen_hooksrrZ_set_running_loop _run_oncerk)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)N)rHFz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrraZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)NT)rk)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)Nz!Cannot close a running event loopzClose %rTF)wait) rrrjrr debugrnrrorpZshutdown)rXexecutorrrrr`s   zBaseEventLoop.closecCs|jS)N)rj)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrr`)rXrrr__del__ s  zBaseEventLoop.__del__cCs |jdk S)N)rq)rXrrrrszBaseEventLoop.is_runningcCstjS)N)rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)Nrr)call_atrrr)rXZdelaycallbackrtimerrrr call_later szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|jr@|jd=tj|j |d|_ |S)NrrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushro)rXwhenrrrrrrr5s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|S)N call_soonrr)rrrr _call_soonr)rXrrrrrrrEs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrrXs   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rZHandlerrnr9)rXrrrrrrrcs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rqrrr)rXZ thread_idrrrrjs  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)Nrrr)rrrrrr)rXrrrrrrr{s  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrp concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rp)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrrr rFr|rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d| dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfd d|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerr`rr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrrxrrr`) rXr%rrrrrrcrrrrrr=s  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#s8| dk rt| js tdj| s@s@|s@|s@|s@|s@|s@| r~t|||||| d} djdd| jD} tdj| | jdd} n*ps|dkrtd ||fdff}ntj }xdfd ffD]~\}}|dk rt ||t j |||d EdH}|s t d xB|D]:\}}}}}||f}||kr>ddg||<||||<qWqWfd d|jD}|sztdg}|dkrtjdkotjdk}x|D]\\}}\}}d} d} yt j |t j |d} |r| jt jt jd |rt| | r| jt jt jd | jdr,| j|rH|j| |EdH|} Wn^t k r}z"| dk rp| j|j|WYdd}~Xn"| dk r| jYnXPqW|d|}|j}|j| || |}|jr rtjd||ntj d||y|EdHWn|jYnX||fS)Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrisz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)!r-r>r!rdictritemsrrl OrderedDictrKr r,r$rynamervplatformr"r# SO_REUSEADDRr&Z SO_BROADCASTrrr`r9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrcrr)rrrcreate_datagram_endpointUs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | diEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttd r|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rrxr5r!ryrrvrrrlIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#r r&r8r rrZ IPV6_V6ONLYrr$rrrr`r+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%r rrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)Nz&A Stream Socket was expected, got {!r}r0T)rr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketAs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrr`rr rfileno)rXrrrrcrrrrconnect_read_pipeXszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrr`rr rr)rXrrrrcrrrrconnect_write_pipeisz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocesszszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rrrr rI) rXrcmdrrrr rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rrrr rI)rXrZprogramrrrr rrrrZ popen_argsargrr"rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)N)rt)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)Nz/A callable object or None is expected, got {!r})rr5rrt)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|d kr~qp||}|dkrdjtj|}d}||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)Nrz!Unhandled exception in event looprFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r{r> __traceback__r}rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)Nz&Exception in default exception handlerT)rz$Unhandled error in exception handler)rrr.zeException in default exception handler while handling an unexpected error in custom exception handler)rtr1rOr r)rXr.rRrrrrs" z$BaseEventLoop.call_exception_handlercCs|jr dS|jj|dS)N) _cancelledrnr9)rXrrrr _add_callback9szBaseEventLoop._add_callbackcCs|j||jdS)N)r3r)rXrrrr_add_callback_signalsafeAs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)Nr)rori)rXrrrr_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d|d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) NFrrg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rro_MIN_SCHEDULED_TIMER_HANDLESri%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr2r9rheapifyheappoprnrkZ_whenminmaxrrMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrsrangepopleftr}Z_runr|rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrKs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krsT            ;   /__pycache__/base_tasks.cpython-36.opt-1.pyc000064400000003507152343301150014462 0ustar003 \@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror */usr/lib64/python3.6/asyncio/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   __pycache__/coroutines.cpython-36.opt-2.pyc000064400000020026152343301150014531 0ustar003 \+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r */usr/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCs>||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGs4tj}|j}|jj|jtkr(|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr!r/Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r9szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r:szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r;szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r<szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr=r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rAszCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rr r r r=szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rBszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rCszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rDszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr:rDrz%r was never yielded fromr)zB Coroutine object created at (most recent call last, truncated to z last lines): r+) r*r4joinr8 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr/msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr0rr_YIELD_FROM_BUGrr6r9propertyr:r;r<rZPY35r@rAr=rBrCrDrLr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)Nc ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r ZisfutureinspectZ isgenerator isinstancer$ _AwaitableABCr@AttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr+)r$r)r*rr)rSkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionrOisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rXr )r"r r rs   cCst|ddtkpt|S)Nr_)r*r_rY)r r r r rscCs t|tS)N)rP_COROUTINE_TYPES)objr r r rsc Cst|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk r~y |j}Wntk rxYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkrt j |fi}d}t|dr|jr|j}nt|dr|jr|j}d}t|dr0|jr0|j}nt|d rJ|jrJ|j}d }|rb|jrb|j}d }|}t|t rtj|j  r|j dk rt j|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r|j}d |||f}|S)NrCr<rrz{}()Fz {} runningrDr:zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr?rBrRr;rPr$r rrZ_format_callbackrCr<rDr: co_filenamerOrZZ_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor.sourcer r r r,sx              r,).__all__r[rOZopcodeosr'r8typesrErrrr logr Zopmapr5flagsignore_environmentboolenvirongetr]rr^ CoroutineTypeZ_types_CoroutineTyperRrrYcollections.abcrZ _CoroutineABCrrQ ImportErrorr#rMr%r$objectr_ GeneratorTyper`rr,r r r r sZ         j:     __pycache__/futures.cpython-36.opt-1.pyc000064400000032300152343301150014031 0ustar003 \> @s dZddddddgZddlZddlZddlZddlZd d lmZd d lm Z d d lm Z ej Z ej Z ej Z ejZejZejZejZejd ZGd ddZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s4eZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr'/usr/lib64/python3.6/asyncio/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr) __name__ __module__ __qualname____doc__ __slots__rrrr&rrrrr s 0r c@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZejrRd d Zd d Zd dZddZddZddZddZddZddZddZddZdd ZejreZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r5_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N)r-r call_soon)rZ callbackscallbackrrrr;s  zFuture._schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r8r:)rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r8r9)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN)r8r:r _FINISHEDrr5r6_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r8r:rrArr5r6)rrrrr4s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r8r9rr=r-append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. csg|]}|kr|qSrr).0f)rErr sz/Future.remove_done_callback..N)r-len)rrEZfiltered_callbacksZ removed_countr)rErremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r8r9rformatrBrAr;)rrCrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL isinstancetype StopIteration TypeErrorr6rAr;r PY34r5r Z _tb_loggerrr=r)rr4rrr set_exception,s    zFuture.set_exceptionccs|jsd|_|V|jS)NT)r@_asyncio_future_blockingrC)rrrr__iter__DszFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr Z_future_repr_infor2r3r rRr&r<r;r?r@rCr4rFrKrMrSrUZPY35 __await__rrrrrns4   cCs|jr dS|j|dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr_set_result_unless_cancelledSsrWcCsN|jr|j|jsdS|j}|dk r8|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N)r?r<Zset_running_or_notify_cancelr4rSrCrM) concurrentsourcer4rCrrr_set_concurrent_future_stateZs rZcCsP|jr dS|jr|jn.|j}|dk r:|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r?r<r4rSrCrM)rYdestr4rCrrr_copy_future_stateis  r\cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|rt||n t||dS)N)rr\rZ)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r?r<call_soon_threadsafe) destination) dest_looprY source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r?Z is_closedr_)rY)r^rar`rbrr_call_set_states  z&_chain_future.._call_set_state)rrNrXZfuturesrrQrrF)rYr`rcrdr)r^rar`rYrbr _chain_future}s   re)r cCs2t|r |S|dkrtj}|j}t|||S)z&Wrap concurrent.futures.Future object.N)rr r,Z create_futurere)rr Z new_futurerrrrs )r*__all__Zconcurrent.futuresrXZloggingr/rrr r r rrrrr9r:rADEBUGZ STACK_DEBUGr rZ _PyFuturerWrZr\rerZ_asyncio ImportErrorZ_CFuturerrrrs>     Pc*  __pycache__/base_events.cpython-36.opt-1.pyc000064400000114305152343301150014640 0ustar003 \@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ e!e dZ"d)Z#ddZ$ddZ%ddZ&ddZ'ddZ(ddZ)de j*dddddZ+e!e d rRd!d"Z,nd#d"Z,d$d%Z-Gd&d'd'ej.Z/Gd(d d ej0Z1dS)*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)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr+/usr/lib64/python3.6/asyncio/base_events.py_format_handle?s rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeHs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)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_SOCKETrOSError)sockrrr_set_reuseportQs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket\s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_sockeths r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infopsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs|jd7_dS)Nr)rV)rXrrr_attachszServer._attachcCs.|jd8_|jdkr*|jdkr*|jdS)Nrr)rVrU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr^)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr^s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrcrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r]r_r`r^rrdrrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMd d d d dXdYdZZ.ed[d\Z/ede0j1e0j2d d]d d d d^d_d`Z3ed dadbdcZ4edddeZ5edfdgZ6dhdiZ7ee8j9e8j9e8j9ddjdMdkdldmZ:ee8j9e8j9e8j9dddMdkdndoZ;dpdqZdvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\ s zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)zDSchedule a coroutine object. Return a task object. N)rHr) _check_closedr~rr_source_traceback)rXcoroZtaskrrr create_task)s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)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)callabler5r~)rXfactoryrrrset_task_factory7s zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrqrrvrhset_asyncgen_hooksrrZ_set_running_loop _run_oncerk)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)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. )rHFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrraZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)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)rk)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)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 %rTF)wait) rrrjrr debugrnrrorpZshutdown)rXexecutorrrrr`s   zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rj)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrr`)rXrrr__del__ s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rq)rXrrrrszBaseEventLoop.is_runningcCstjS)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. )rrrg)rXrrrrrszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)a8Arrange 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 undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrrr)rXZdelaycallbackrtimerrrr call_later szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|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. rrTr) rr _check_thread_check_callbackrZ TimerHandlerheapqheappushro)rXwhenrrrrrrr5s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|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_soonrr)rrrr _call_soonr)rXrrrrrrrEs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrrXs   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rZHandlerrnr9)rXrrrrrrrcs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)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)rqrrr)rXZ thread_idrrrrjs  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)z"Like call_soon(), but thread-safe.rrr)rrrrrr)rXrrrrrrr{s  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrp concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rp)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrrr rFr|rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d | dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfdd|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerr`rr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrrxrrr`) rXr%rrrrrrcrrrrrr=s  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#s8| dk rt| js tdj| s@s@|s@|s@|s@|s@|s@| r~t|||||| d} djdd| jD} tdj| | jdd} n*ps|d krtd ||fdff}ntj }xd fd ffD]~\}}|dk rt ||t j |||d EdH}|s t d xB|D]:\}}}}}||f}||kr>ddg||<||||<qWqWfdd|jD}|sztdg}|dkrtjdkotjdk}x|D]\\}}\}}d} d} yt j |t j |d} |r| jt jt jd |rt| | r| jt jt jd | jdr,| j|rH|j| |EdH|} Wn^t k r}z"| dk rp| j|j|WYdd}~Xn"| dk r| jYnXPqW|d |}|j}|j| || |}|jr rtjd||ntj d||y|EdHWn|jYnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrisz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyr)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)!r-r>r!rdictritemsrrl OrderedDictrKr r,r$rynamervplatformr"r# SO_REUSEADDRr&Z SO_BROADCASTrrr`r9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrcrr)rrrcreate_datagram_endpointUs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | d iEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttdr|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rrxr5r!ryrrvrrrlIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#r r&r8r rrZ IPV6_V6ONLYrr$rrrr`r+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%r rrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r0T)rNr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketAs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrr`rr rfileno)rXrrrrcrrrrconnect_read_pipeXszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrr`rr rr)rXrrrrcrrrrconnect_write_pipeisz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocesszszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rrrr rI) rXrcmdrrrr rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rrrr rI)rXrZprogramrrrr rrrrZ popen_argsargrr"rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rt)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)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 {!r})rr5rrt)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|dkr~qp||}|dkrdjtj|}d }||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)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()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r{r> __traceback__r}rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)aCall 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; - '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 handlerT)rz$Unhandled error in exception handler)rrr.zeException in default exception handler while handling an unexpected error in custom exception handler)rtr1rOr r)rXr.rRrrrrs" z$BaseEventLoop.call_exception_handlercCs|jr dS|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrnr9)rXrrrr _add_callback9szBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r3r)rXrrrr_add_callback_signalsafeAs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rori)rXrrrr_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d |d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) 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. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rro_MIN_SCHEDULED_TIMER_HANDLESri%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr2r9rheapifyheappoprnrkZ_whenminmaxrrMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrsrangepopleftr}Z_runr|rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrKs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krsV            ;   /__pycache__/log.cpython-36.pyc000064400000000334152343301150012160 0ustar003 \|@sdZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.6/asyncio/log.pys__pycache__/coroutines.cpython-36.pyc000064400000020552152343301150013575 0ustar003 \+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r */usr/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCsZtj|stj|st|||_||_tjtj d|_ t |dd|_ t |dd|_ dS)Nrrr)inspect isgeneratorrAssertionErrorrr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner, __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGsBtj}|j}|jdkst|jj|jtkr6|d}|jj |S)Nr) r*r+f_backf_lastir(f_codeco_code _YIELD_FROMrr)rr!r2Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r9szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r<szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r=szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r>szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r?szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r-r RuntimeErrorformat)rr@r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rDszCoroWrapper.gi_yieldfromcCs|jjS)N)rr@)rr r r r@szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rEszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rFszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rGszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr=rGrz%r was never yielded fromr,zB Coroutine object created at (most recent call last, truncated to z last lines): r.) r-r5joinr; format_listrZDEBUG_STACK_DEPTHrstripr error)rrr2msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr3rr_YIELD_FROM_BUGrr9r<propertyr=r>r?rZPY35rCrDr@rErFrGrOr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r Zisfuturer&r' isinstancer$ _AwaitableABCrCAttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..coroNcs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr.)r$r,r-rr)rUkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionr&isgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rZr )r"r r rs   cCst|ddtkpt|S)z6Return True if func is a decorated coroutine function.raN)r-rar[)r r r r rscCs t|tS)z)Return True if obj is a coroutine object.)rR_COROUTINE_TYPES)objr r r rsc Cs&t|s tt|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk ry |j }Wntk rYnXYnX|rdj|S|Sd}t |t r|j }|j }|dk rdj|}n|}|dkrtj|fi}d}t|do|jr|j}nt|dr|jr|j}d}t|dr>|jr>|j}nt|d rX|jrX|j}d }|rp|jrp|j}d }|}t |t rtj|j  r|j dk rtj|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r"|j}d |||f}|S)NrFr?rrz{}()Fz {} runningrGr=zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)rr(hasattrr-r:rrBrErTr>rRr$r rrZ_format_callbackrFr?rGr= co_filenamer&r\Z_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor1sourcer r r r/sz               r/).__all__r]r&Zopcodeosr*r;typesrHrrrr logr Zopmapr8flagsignore_environmentboolenvirongetr_rr` CoroutineTypeZ_types_CoroutineTyperTrr[collections.abcrZ _CoroutineABCrrS ImportErrorr#rPr%r$objectra GeneratorTyperbrr/r r r r sZ         j:     __pycache__/subprocess.cpython-36.opt-2.pyc000064400000014745152343301150014542 0ustar003 \@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)SubprocessStreamProtocolcs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__*/usr/lib64/python3.6/asyncio/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr9)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr<szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr>szProcess.terminatecCs|jjdS)N)rkill)rrrrr?sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrBr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|j}|jjrJ|dkr8dnd}tjd|||jEdH}|jjr|dkrndnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&r@r rBreadr-)rr*r(streamnameoutputrrr _read_streams   zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rFrGrrLrrZgatherr&r;)rrErrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr:r r;r<r>r?rFrGrLrMrrrrr8ks      r8c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr8) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrOsz(create_subprocess_exec..)rrr)rrPZsubprocess_execr8) Zprogramrrrr rargsrRrSr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r8Z_DEFAULT_LIMITrrrrrrs(      X] __pycache__/selector_events.cpython-36.opt-1.pyc000064400000071507152343301150015554 0ustar003 \ @s<dZdgZddlZddlZddlZddlZddlZddlZy ddlZWne k r^dZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)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)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.6/asyncio/selector_events.py_test_selector_event s rcsreZdZdZdOfdd ZdPdddddZdQddddd d d Zddddd d d ZdRddZfddZ ddZ ddZ ddZ ddZ ddZddZdSdd ZdTd!d"ZedUd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Z ed?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(Z)S)VrzJSelector event loop. See events.EventLoop for API specification. NcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)zAdd a reader callback.)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)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. This method is a coroutine. rzthe socket must be non-blockingN)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)aSend 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. This method is a coroutine. rzthe socket must be non-blockingN)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIX)familyprotoloopN)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)a|Accept 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. This method is a coroutine. rzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r __module__ __qualname____doc__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sT      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jr dSy|jj|j}Wn\ttfk r4Yntk rx}z*|jj|j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrHrrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs&   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0) r__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsD             ii__pycache__/compat.cpython-36.opt-1.pyc000064400000001336152343301150013624 0ustar003 \@s6dZddlZejd kZejd kZejd kZddZdS) z8Compatibility helpers for the different Python versions.NcCstsdd|D}dj|S)z-Concatenate a sequence of bytes-like objects.css$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar &/usr/lib64/python3.6/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)__doc__sys version_inforZPY35ZPY352rr r r r s    __pycache__/unix_events.cpython-36.opt-2.pyc000064400000063623152343301150014720 0ustar003 \ @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZdddddgZejdkredddZy ejZWnek r(ddZYnXGdddejZe edrRddZ!nddl"Z"ddZ!Gd d!d!ej#Z$Gd"d#d#ej%ej&Z'e ed$rej(Z)nddl"Z"d%d&Z)Gd'd(d(e j*Z+Gd)ddZ,Gd*d+d+e,Z-Gd,dde-Z.Gd-dde-Z/Gd.d/d/ej0Z1eZ2e1Z3dS)0N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)N)signumframerr+/usr/lib64/python3.6/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZd!fdd ZddZfddZdd Zd d Zd d ZddZ ddZ d"ddZ d#ddZ e d$ddZddZe ddddddZe d%dddddd ZZS)&_UnixSelectorEventLoopNcstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)rrrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)rsig)r!rrr%>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)rdatarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)Nz3coroutines cannot be used with add_signal_handler()Frzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)rr.callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)NFzsig {} cannot be caughtrzset_wakeup_fd(-1) failed: %sTr2)r4rKeyErrorr5SIGINTdefault_int_handlerSIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)Nzsig must be an int, not {!r}rzsig {} out of range(1, {})) isinstanceintr3r@r5NSIGr8)rr.rrrr4s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)rpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)rrOrPrQrRrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rQrR) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)rrPrBshellstdinstdoutstderrbufsizerRkwargswatcherrQtransprCerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)rpid returncoderbrrrrYsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|r|dkr&tdn|dk r&td|dk r|dk r>tdtjtjtjd}y |jd|j||EdHWq|jYqXnB|dkrtd|jtjkstj |j  rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r8r"AF_UNIX SOCK_STREAM setblockingZ sock_connectr%familyr_is_stream_sockettyper@Z_create_connection_transport)rprotocol_factoryrrgrhri transportrPrrrcreate_unix_connections8    z-_UnixSelectorEventLoop.create_unix_connectiond)rhbacklogrgc !Cst|trtd|dk r0|dk r,tdt|}tjtjtj}|dd kry tj t j|j rnt j |WnBt k rYn0tk r}ztjd||WYdd}~XnXy|j|Wnjtk r}z8|j|jtjkrdj|}ttj|dnWYdd}~Xn|jYnXn>|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rru)rKboolr3r8_fspathr"rjrkstatS_ISSOCKosst_moderemoveFileNotFoundErrorr9rerrorZbindr%r>Z EADDRINUSEr@rmrrnroZServerZlistenrlZ_start_serving) rrprrhrtrgrcrCmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname__rr#r%r1rEr/r)r4rSrUr rdrYrrr __classcell__rr)r!rr1s* -      %r set_blockingcCstj|ddS)NF)rzr)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrz O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rNiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrOFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper7_fileno _protocol_closingrzfstatr{rxS_ISFIFOryS_ISCHRr8r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rlooprOrPrQrRmode)r!rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r!rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)rr=r rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rzreadrmax_sizeBlockingIOErrorInterruptedErrorr9 _fatal_errorrZ data_receivedr get_debugrr=r_remove_readerrZ eof_received_call_connection_lost)rr0rCrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)rrrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)rrrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)rrPrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)rrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)rrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)rrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrqrP) rKr9r>ZEIOrrrdebugcall_exception_handlerrr)rrCrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)rrCrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)rrCrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr%rPY34rrrrrrr)r!rrNMs rNcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rTNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrOrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr7rr bytearray_buffer _conn_lostrrzrr{rxrrryr8rrrrr&platform startswithrrr r) rrrOrPrQrRrZis_charZis_fifoZ is_socket)r!rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r!rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)rr=r rr_rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)rrrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr=rrBrokenPipeError)rrrrrs   z#_UnixWritePipeTransport._read_readycCst|trt|}|sdS|js&|jrN|jtjkrs&   z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr dSd|_|js4|jj|j|jj|jddS)NT)rrrrrrr)rrrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)rrPrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)rrrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)rrrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)rrrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrqrP) rKrZ_FATAL_ERROR_IGNORErrrrrrr)rrCrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr-rrr)rrCrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)rrCrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr%rrrrrrrrrr)r!rrTs$% !   rTset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rWc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r[r\r]r^Zuniversal_newlinesr_wb) buffering) subprocessPIPErr#rr7Popen_procr%rdetachr\) rrBr[r\r]r^r_r`Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrWsrWc@s<eZdZddZddZddZddZd d Zd d Zd S)rcGs tdS)N)NotImplementedError)rrerArBrrrrXs z&AbstractChildWatcher.add_child_handlercCs tdS)N)r)rrerrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)N)r)rrrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)N)r)rrrrr%szAbstractChildWatcher.closecCs tdS)N)r)rrrr __enter__szAbstractChildWatcher.__enter__cCs tdS)N)r)rabcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrXrrr%rrrrrrrs   c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)rrrrrszBaseChildWatcher.__init__cCs|jddS)N)r)rrrrr%szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)rrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk r$|dkr$|jr$tjdt|jdk r<|jjtj||_|dk rb|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrr*r+RuntimeWarningr)r5SIGCHLDrE _sig_chldr)rrrrrrs zBaseChildWatcher.attach_loopcCsFy |jWn4tk r@}z|jjd|dWYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)rr)rrZrr)rrCrrrr1s  zBaseChildWatcher._sig_chldcCs2tj|rtj| Stj|r*tj|S|SdS)N)rz WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)rstatusrrr_compute_returncode=s     z$BaseChildWatcher._compute_returncodeN) rrrrr%rrrrrrrrrrs rcsLeZdZfddZddZddZddZd d Zd d Zd dZ Z S)rcs|jjtjdS)N)rr-rr%)r)r!rrr%Vs zSafeChildWatcher.closecCs|S)Nr)rrrrrZszSafeChildWatcher.__enter__cCsdS)Nr)rrrrrrrr]szSafeChildWatcher.__exit__cGs.|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rr)rrerArBrrrrX`s  z"SafeChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrks z%SafeChildWatcher.remove_child_handlercCs"xt|jD]}|j|q WdS)N)r(rr)rrerrrrrsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn(tk r>|}d}tjd|Yn0X|dkrLdS|j|}|jjrntj d||y|j j |\}}Wn.t k r|jjrtjd|ddYnX|||f|dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r) rzwaitpidWNOHANGChildProcessErrorrrrrrrrpoprG)rrrerrfrArBrrrrws*    zSafeChildWatcher._do_waitpid) rrrr%rrrXrrrrrr)r!rrKs  csPeZdZfddZfddZddZddZd d Zd d Zd dZ Z S)rcs$tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r)r!rrrs  zFastChildWatcher.__init__cs"|jj|jjtjdS)N)rr-rrr%)r)r!rrr%s  zFastChildWatcher.closec Cs$|j|jd7_|SQRXdS)Nr)rr)rrrrrszFastChildWatcher.__enter__c CsV|j:|jd8_|js$|j r(dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr;r-rr)rrrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGsl|jdkrtd|j:y|jj|}Wn"tk rL||f|j|<dSXWdQRX|||f|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rrrrGr)rrerArBrfrrrrXs z"FastChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrs z%FastChildWatcher.remove_child_handlercCsxytjdtj\}}Wntk r,dSX|dkr:dS|j|}|jvy|jj|\}}WnBtk r|j r||j |<|j j rt jd||wd}YnX|j j rt jd||WdQRX|dkrt jd||q|||f|qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)rzrrrrrrrrGrrrrrrr)rrerrfrArBrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrr%rrrXrrrrr)r!rrs  csDeZdZeZfddZddZfddZddZd d Z Z S) _UnixDefaultEventLoopPolicycstjd|_dS)N)rr_watcher)r)r!rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrKrcurrent_thread _MainThreadr_localr)rrrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)N)rset_event_looprrKrrrr)rr)r!rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)N)rr)rrrrrV&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|jj||_dS)N)rr%)rrarrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrZ _loop_factoryrrrrVrrrr)r!rrs    r)4r>rzr5r"rxrr&rr*rrrrrrr r r r r logr__all__r ImportErrorrfspathrwAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrNZ_FlowControlMixinZWriteTransportrTrrZBaseSubprocessTransportrWrrrrZBaseDefaultEventLoopPolicyrrrrrrrsl                O  F=On2__pycache__/windows_utils.cpython-36.opt-1.pyc000064400000012256152343301150015256 0ustar003 \@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdfd dZd de dddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces NZwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd \}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)prefixrrNT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@s\eZdZdZddZddZeddZdd Ze j d d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r" __class____name__)r#r$rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r"r )r#rrrfilenos zPipeHandle.fileno)r cCs|jdk r||jd|_dS)N)r")r#r rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r"warningswarnResourceWarningr)r#rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r#rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r#tvtbrrr__exit__szPipeHandle.__exit__N)r( __module__ __qualname____doc__r%r)propertyr$r*rr rr/r0r4rrrrrs cs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|d}}}d} } } |tkr@tddd\} } tj| tj}n|}|tkrhtdd\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy tj|f|||d|Wn4x$| | | fD]}|dk rt j |qWYn>X| dk rt | |_ | dk r"t | |_ | dk r6t | |_Wd|tkrNtj||tkrbtj||tkrvtj|XdS) NFT)rr)rr)stdinstdoutstderr)FT)TF)TF)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr%rr rr9r:r;r)r#argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r'rrr%sH            zPopen.__init__)NNN)r(r5r6r7r% __classcell__rr)r'rrs)TT)r7sysplatform ImportErrorr itertoolsr<rr subprocessrr,__all__ZBUFSIZErr>countrhasattrrr r rrrrrrrs,  .0-__pycache__/base_events.cpython-36.pyc000064400000114663152343301150013710 0ustar003 \@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZd gZd Zd ZeeefZ e!e dZ"d)Z#ddZ$ddZ%ddZ&ddZ'ddZ(ddZ)de j*dddddZ+e!e d rRd!d"Z,nd#d"Z,d$d%Z-Gd&d'd'ej.Z/Gd(d d ej0Z1dS)*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)compat) coroutines)events)futures)tasks) coroutine)logger BaseEventLoopdg?AF_INET6icCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrrTaskreprrstr)handlecbr+/usr/lib64/python3.6/asyncio/base_events.py_format_handle?s rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeHs   rc CsLttdstdn4y|jtjtjdWntk rFtdYnXdS)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_SOCKETrOSError)sockrrr_set_reuseportQs   r&cCs&ttdr|d@tjkS|tjkSdS)N SOCK_NONBLOCK)rr SOCK_STREAM) sock_typerrr_is_stream_socket\s r+cCs&ttdr|d@tjkS|tjkSdS)Nr'r()rr SOCK_DGRAM)r*rrr_is_dgram_sockeths r-cCsvttdsdS|dtjtjhks(|dkr,dSt|rt|tr|dkrd}n&y t |}Wnt t fk rdSX|tj krtj g}tr|jtjn|g}t|tr|jd}d|krdSxp|D]h}yJtj||tr@|tjkr@|||d||ddffS|||d||ffSWntk rjYnXqWdS)N inet_ptonrZidna%)rr IPPROTO_TCPZ IPPROTO_UDPr+r-rbytesrint TypeErrorr! AF_UNSPECAF_INET _HAS_IPv6appendr decoder.r$)hostportfamilytypeprotoZafsafrrr _ipaddr_infopsL         rA)r=r>r?flagsc CsZ|dd\}}t|||||}|dk r@|j} | j|g| S|j||||||dSdS)N)r=r>r?rB)rA create_future set_result getaddrinfo) addressr=r>r?rBloopr;r<infofutrrr_ensure_resolveds  rK TCP_NODELAYcCs>|jtjtjhkr:t|jr:|jtjkr:|jtjtj ddS)Nr) r=r r7r r+r>r?r2r"rL)r%rrr _set_nodelays  rMcCsdS)Nr)r%rrrrMscCs.|j}t|tr t|t r dS|jjdS)N)Z _exceptionr BaseException Exception_loopstop)rJexcrrr_run_until_complete_cbs   rSc@sHeZdZddZddZddZddZd d Zd d Ze d dZ dS)ServercCs||_||_d|_g|_dS)Nr)rPsockets _active_count_waiters)selfrHrUrrr__init__szServer.__init__cCsd|jj|jfS)Nz<%s sockets=%r>) __class____name__rU)rXrrr__repr__szServer.__repr__cCs |jdk st|jd7_dS)Nr)rUAssertionErrorrV)rXrrr_attachszServer._attachcCs<|jdkst|jd8_|jdkr8|jdkr8|jdS)Nrr)rVr]rU_wakeup)rXrrr_detachszServer._detachcCsH|j}|dkrdSd|_x|D]}|jj|qW|jdkrD|jdS)Nr)rUrPZ _stop_servingrVr_)rXrUr%rrrcloses  z Server.closecCs0|j}d|_x|D]}|js|j|qWdS)N)rWdonerE)rXwaiterswaiterrrrr_s  zServer._wakeupccs<|jdks|jdkrdS|jj}|jj||EdHdS)N)rUrWrPrDr9)rXrdrrr wait_closeds   zServer.wait_closedN) r[ __module__ __qualname__rYr\r^r`rar_rrerrrrrTs rTc @seZdZddZddZddZddZd d Zd d Zdd d dddZ ddd d d dddZ dddZ dddZ dddZ edddZddZdd Zd!d"Zd#d$Zd%d&Zed'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zejrd3d4Zd5d6Zd7d8Zd9d:Z d;d<Z!d=d>Z"d?d@Z#dAdBZ$dCdDZ%dEdFZ&dGdHZ'dIdJZ(dKdLZ)dMdMdMdMdNdOdPZ*ddQdRZ+edd dMdMdMd d d dSdTdUZ,eddVdWZ-eddMdMdMd d d d dXdYdZZ.ed[d\Z/ede0j1e0j2d d]d d d d^d_d`Z3ed dadbdcZ4edddeZ5edfdgZ6dhdiZ7ee8j9e8j9e8j9ddjdMdkdldmZ:ee8j9e8j9e8j9dddMdkdndoZ;dpdqZdvdwZ?dxdyZ@dzd{ZAd|d}ZBd~dZCddZDddZEddZFd S)r cCsd|_d|_d|_tj|_g|_d|_d|_d|_ t j dj |_ d|_|jtjj odttjjdd|_d|_d|_d|_ttdrtj|_nd|_d|_dS)NrF monotonicZPYTHONASYNCIODEBUGg?get_asyncgen_hooks) _timer_cancelled_count_closed _stopping collectionsdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeZget_clock_infoZ resolution_clock_resolution_exception_handler set_debugsysrBignore_environmentboolosenvirongetslow_callback_duration_current_handle _task_factory_coroutine_wrapper_setrweakrefWeakSet _asyncgens_asyncgens_shutdown_called)rXrrrrYs(   zBaseEventLoop.__init__cCs d|jj|j|j|jfS)Nz"<%s running=%s closed=%s debug=%s>)rZr[ is_running is_closed get_debug)rXrrrr\ s zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.)rH)rZFuture)rXrrrrD%szBaseEventLoop.create_futurecCs@|j|jdkr0tj||d}|jr<|jd=n |j||}|S)zDSchedule a coroutine object. Return a task object. N)rHr) _check_closedrrr_source_traceback)rXcoroZtaskrrr create_task)s   zBaseEventLoop.create_taskcCs$|dk rt| rtd||_dS)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)callabler5r)rXfactoryrrrset_task_factory7s zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrHz?an error occurred during closing of asynchronous generator {!r})message exceptionZasyncgen) rrlenlistclearrgatherziprrOcall_exception_handlerr)rXZ closing_agensZ shutdown_coroZresultsresultrrrrshutdown_asyncgenss"      z BaseEventLoop.shutdown_asyncgensc Cs|j|jrtdtjdk r,td|j|jtj|_ |j dk rft j }t j |j|jdz$tj|x|j|jrtPqtWWdd|_d|_ tjd|jd|j dk rt j |XdS)zRun until stop() is called.z"This event loop is already runningNz7Cannot run the event loop while another loop is running) firstiter finalizerF)rrrrZ_get_running_loop_set_coroutine_wrapper_debug threading get_identrrrrwriset_asyncgen_hooksrrZ_set_running_loop _run_oncerl)rXZold_agen_hooksrrr run_forevers0          zBaseEventLoop.run_forevercCs|jtj| }tj||d}|r,d|_|jtz>y |jWn,|rj|j rj|j rj|j YnXWd|j tX|j st d|jS)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. )rHFNz+Event loop stopped before Future completed.)rrZisfuturerZ ensure_futureZ_log_destroy_pendingZadd_done_callbackrSrrbZ cancelledrZremove_done_callbackrr)rXZfutureZnew_taskrrrrun_until_completes      z BaseEventLoop.run_until_completecCs d|_dS)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)rl)rXrrrrQszBaseEventLoop.stopcCsj|jrtd|jrdS|jr,tjd|d|_|jj|jj|j }|dk rfd|_ |j dddS)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 %rTF)wait) rrrkrr debugrorrprqZshutdown)rXexecutorrrrras   zBaseEventLoop.closecCs|jS)z*Returns True if the event loop was closed.)rk)rXrrrrszBaseEventLoop.is_closedcCs0|js,tjd|t|d|js,|jdS)Nzunclosed event loop %r)r)rrrrrra)rXrrr__del__ s  zBaseEventLoop.__del__cCs |jdk S)z*Returns True if the event loop is running.N)rr)rXrrrrszBaseEventLoop.is_runningcCstjS)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. )rsrh)rXrrrrsszBaseEventLoop.timecGs,|j|j||f|}|jr(|jd=|S)a8Arrange 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 undefined which will be called first. Any positional arguments after the callback will be passed to the callback when it is called. rr)call_atrsr)rXZdelaycallbackrtimerrrr call_later szBaseEventLoop.call_latercGsX|j|jr"|j|j|dtj||||}|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. rrTr) rr _check_thread_check_callbackr TimerHandlerheapqheappushrp)rXwhenrrrrrrr5s zBaseEventLoop.call_atcGs@|j|jr"|j|j|d|j||}|jr<|jd=|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_soonrr)rrrr _call_soonr)rXrrrrrrrEs   zBaseEventLoop.call_sooncCs>tj|stj|r"tdj|t|s:tdj||dS)Nz#coroutines cannot be used with {}()z0a callable object was expected by {}(), got {!r})rZ iscoroutineZiscoroutinefunctionr5rr)rXrmethodrrrrXs   zBaseEventLoop._check_callbackcCs,tj|||}|jr|jd=|jj||S)Nrr)rHandlerror9)rXrrrrrrrcs  zBaseEventLoop._call_sooncCs,|jdkrdStj}||jkr(tddS)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)rrrrr)rXZ thread_idrrrrjs  zBaseEventLoop._check_threadcGs@|j|jr|j|d|j||}|jr4|jd=|j|S)z"Like call_soon(), but thread-safe.rrr)rrrrrr)rXrrrrrrr{s  z"BaseEventLoop.call_soon_threadsafecGsZ|j|jr|j|d|dkr@|j}|dkr@tjj}||_tj|j|f||dS)Nrun_in_executor)rH) rrrrq concurrentrZThreadPoolExecutorZ wrap_futureZsubmit)rXrfuncrrrrrs  zBaseEventLoop.run_in_executorcCs ||_dS)N)rq)rXrrrrset_default_executorsz"BaseEventLoop.set_default_executorc Csd||fg}|r |jd||r2|jd||rD|jd||rV|jd|dj|}tjd||j}tj||||||} |j|} d|| d | f}| |jkrtj|n tj|| S) Nz%s:%rz family=%rztype=%rzproto=%rzflags=%rz, zGet address info %sz(Getting address info %s took %.3f ms: %rg@@) r9joinr rrsr rFr}rI) rXr;r<r=r>r?rBmsgt0Zaddrinfodtrrr_getaddrinfo_debugs(      z BaseEventLoop._getaddrinfo_debugr)r=r>r?rBc Cs>|jr |jd|j||||||S|jdtj||||||SdS)N)rrrr rF)rXr;r<r=r>r?rBrrrrFs   zBaseEventLoop.getaddrinfocCs|jdtj||S)N)rr getnameinfo)rXZsockaddrrBrrrrszBaseEventLoop.getnameinfo)sslr=r?rBr% local_addrrc#s| dk r| rtd| dkr2|r2|s.td|} |dk sD|dk r|dk rTtdt||f|tj|||d} | g} | dk rt| |tj|||d} | j| nd} tj| |dEdH| j}|std| dk r| j}|stdg}x|D]B\}}}}}ytj|||d}|j d | dk rx|D]j\}}}}}y|j |PWnHtk r}z*t|j d j ||j j}|j|WYdd}~XnXq.W|jd}w|jrtjd |||j||EdHWn^tk r}z"|dk r|j|j|WYdd}~Xq|dk r,|jYqXPqWt|d krR|d nJt|d tfdd|Dr~|d tdj djdd|Dn,|dkrtdt|jstdj ||j|||| EdH\}}|jr |jd}tjd|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a hostz8host/port and sock can not be specified at the same time)r=r>r?rBrH)rHz!getaddrinfo() returned empty list)r=r>r?Fz2error while attempting to bind on address {!r}: {}zconnect %r to %rrrc3s|]}t|kVqdS)N)r)rrR)modelrr sz2BaseEventLoop.create_connection..zMultiple exceptions: {}z, css|]}t|VqdS)N)r)rrRrrrr#sz5host and port was not specified and no sock specifiedz&A Stream Socket was expected, got {!r}r z%r connected to %s:%r: (%r, %r))r!rKr r)r9rrrr$ setblockingbinderrnorstrerrorlowerrarr r sock_connectrrallrr+r>_create_connection_transportget_extra_info)rXprotocol_factoryr;r<rr=r?rBr%rrf1fsf2infosZ laddr_infos exceptionsr>ZcnamerG_ZladdrrR transportrr)rrcreate_connections        "        zBaseEventLoop.create_connectionc cs|jd|}|j}|rFt|tr*dn|}|j||||||d} n|j|||} y|EdHWn| jYnX| |fS)NF)rr)rrDrryrrra) rXr%rrrrrrdrrrrrr=s  z*BaseEventLoop._create_connection_transport)r=r?rB reuse_address reuse_portallow_broadcastr%c#sZ| dk rt| js tdj| s@s@|s@|s@|s@|s@|s@| r~t|||||| d} djdd| jD} tdj| | jdd} nLps|d krtd ||fdff}ntj }xd fd ffD]\}}|dk rt |t rt |d kst d t||tj|||dEdH}|s.tdxB|D]:\}}}}}||f}||kr`ddg||<||||<q4WqWfdd|jD}|stdg}|dkrtjdkotjdk}x|D]\\}}\}}d} d} ytj|tj|d} |r| jtjtjd |rt| | r4| jtjtjd | jdrN| j|rj|j| |EdH|} Wn^tk r}z"| dk r| j|j|WYdd}~Xn"| dk r| jYnXPqW|d |}|j}|j | || |}|j!r,rt"j#d||nt"j$d||y|EdHWn|jYnX||fS)zCreate datagram connection.Nz#A UDP Socket was expected, got {!r})r remote_addrr=r?rBrrrz, css"|]\}}|rdj||VqdS)z{}={}N)r)rkvrrrrisz9BaseEventLoop.create_datagram_endpoint..zNsocket modifier keyword arguments can not be used when sock is specified. ({})Frzunexpected address familyrrCz2-tuple is expected)r=r>r?rBrHz!getaddrinfo() returned empty listcs8g|]0\}}r|ddkp*o*|ddks||fqS)rNrr)rkeyZ addr_pair)rrrrrsz:BaseEventLoop.create_datagram_endpoint..zcan not get address informationposixcygwin)r=r>r?z@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))NN)%r-r>r!rdictritemsrrm OrderedDictrtuplerr]rKr r,r$rznamerwplatformr"r# SO_REUSEADDRr&Z SO_BROADCASTrrrar9rDrrr rIr)rXrrrr=r?rBrrrr%ZoptsZproblemsZr_addrZaddr_pairs_infoZ addr_infosidxZaddrrZfamrZprorGrrZ local_addressZremote_addressrRrrdrr)rrrcreate_datagram_endpointUs              z&BaseEventLoop.create_datagram_endpointccs4t||f|tj||dEdH}|s0tdj||S)N)r=r>rBrHz%getaddrinfo({!r}) returned empty list)rKr r)r$r)rXr;r<r=rBrrrr_create_server_getaddrinfos  z(BaseEventLoop._create_server_getaddrinfor )r=rBr%backlogrrrc #st|trtd|dk s$dk r|dk r4td| dkrPtjdkoNtjdk} g} |dkrddg} n$t|ts|t|t j  r|g} n|} fdd| D} t j | d iEdH}t tjj|}d }z x|D] }|\}}}}}ytj|||}Wn6tjk r2jr,tjd |||d d wYnX| j|| rV|jtjtjd | rdt|tr|tjkrttdr|jtjtjd y|j |Wqt!k r}z t!|j"d||j#j$fWYdd}~XqXqWd }Wd|s x| D]}|j%qWXn2|dkr"tdt&|j's.rHFz:create_server() failed to create socket.socket(%r, %r, %r)T)exc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedz&A Stream Socket was expected, got {!r}z %r is serving).rryr5r!rzr rwr rrmIterablerrset itertoolschain from_iterabler errorrr warningr9r"r#r r&r8r rrZ IPV6_V6ONLYrr$rrrrar+r>rrTZlistenrZ_start_servingrI)rXrr;r<r=rBr%rrrrrUZhostsrrZ completedresr@Zsocktyper?Z canonnameZsaerrrr)r=rBr<rXr create_servers     (         zBaseEventLoop.create_server)rccs^t|jstdj||j|||dddEdH\}}|jrV|jd}tjd|||||fS)aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. z&A Stream Socket was expected, got {!r}r0T)rNr z%r handled: (%r, %r)) r+r>r!rrrrr r)rXrr%rrrrrrconnect_accepted_socketAs   z%BaseEventLoop.connect_accepted_socketc csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz Read pipe %r connected: (%r, %r))rDrrarr rfileno)rXrrrrdrrrrconnect_read_pipeXszBaseEventLoop.connect_read_pipec csd|}|j}|j|||}y|EdHWn|jYnX|jr\tjd|j||||fS)Nz!Write pipe %r connected: (%r, %r))rDrrarr rr)rXrrrrdrrrrconnect_write_pipeisz BaseEventLoop.connect_write_pipecCs|g}|dk r |jdt||dk rF|tjkrF|jdt|n4|dk r`|jdt||dk rz|jdt|tjdj|dS)Nzstdin=%szstdout=stderr=%sz stdout=%sz stderr=%s )r9rrrr rr)rXrrrrrIrrr_log_subprocesszszBaseEventLoop._log_subprocessT)rrruniversal_newlinesrrc kst|ttfstd|r"td|s.td|dkr>td|} d} |jrfd|} |j| ||||j| |d||||f| EdH} |jr| dk rtjd| | | | fS) Nzcmd must be a stringz universal_newlines must be Falsezshell must be Truerzbufsize must be 0zrun shell command %rTz%s: %r) rr3rr!rr#rr rI) rXrcmdrrrr$rrrr debug_logrrrrsubprocess_shells$zBaseEventLoop.subprocess_shellcos|r td|rtd|dkr(td|f| } x,| D]$} t| ttfs8tdt| jq8W|} d}|jrd|}|j|||||j | | d||||f| EdH}|jr|dk rt j d|||| fS) Nz universal_newlines must be Falsezshell must be Falserzbufsize must be 0z8program arguments must be a bytes or text string, not %szexecute program %rFz%s: %r) r!rrr3r5r>r[rr#rr rI)rXrZprogramrrrr$rrrrZ popen_argsargrr&rrrrsubprocess_execs,   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )ru)rXrrrget_exception_handlersz#BaseEventLoop.get_exception_handlercCs*|dk r t| r tdj|||_dS)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 {!r})rr5rru)rXZhandlerrrrset_exception_handlers z#BaseEventLoop.set_exception_handlerc Cs|jd}|sd}|jd}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}xt|D]}|dkr~qp||}|dkrdjtj|}d }||j 7}n2|dkrdjtj|}d }||j 7}nt |}|j d j ||qpWt jd j||d dS)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()`. rz!Unhandled exception in event looprNFZsource_tracebackZhandle_tracebackr0z+Object created at (most recent call last): z+Handle created at (most recent call last): z{}: {} )r>rr)r|r> __traceback__r~rsortedr traceback format_listrstriprr9rr r) rXcontextrrrZ log_linesrvaluetbrrrdefault_exception_handlers6    z'BaseEventLoop.default_exception_handlercCs|jdkr>y|j|Wqtk r:tjdddYqXnny|j||Wn\tk r}z@y|jd||dWn"tk rtjdddYnXWYdd}~XnXdS)aCall 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; - '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 handlerT)rz$Unhandled error in exception handler)rrr2zeException in default exception handler while handling an unexpected error in custom exception handler)rur5rOr r)rXr2rRrrrrs" z$BaseEventLoop.call_exception_handlercCs@t|tjstd|jrdSt|tj s0t|jj|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr] _cancelledrror9)rXrrrr _add_callback9s zBaseEventLoop._add_callbackcCs|j||jdS)z6Like _add_callback() but called from a signal handler.N)r7r)rXrrrr_add_callback_signalsafeAs z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rprj)rXrrrr_timer_handle_cancelledFsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkrd|j|tkrdg}x&|jD]}|jr>d|_q,|j|q,Wtj|||_d|_n8x6|jr|jdjr|jd8_tj |j}d|_qfWd}|j s|j rd}n*|jr|jdj }t td||jt}|jo|dkr|j}|jj|}|j|}|dkrtj} ntj} t|} |dkrLtj| d|d| nD| rntj| d|d|d| n"|dkrtj| d |d|dn |jj|}|j||j|j} xD|jr|jd}|j | krPtj |j}d|_|j j|qWt|j } xt| D]|} |j j}|jr*q|jrzD||_|j}|j|j|}||jkrttj d t!||Wdd|_Xn|jqWd}dS) 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. FrrNg?zpoll took %.3f ms: %s eventsg@@z$poll %.3f ms took %.3f ms: %s eventsz"poll %.3f ms took %.3f ms: timeoutzExecuting %s took %.3f seconds)"rrp_MIN_SCHEDULED_TIMER_HANDLESrj%_MIN_CANCELLED_TIMER_HANDLES_FRACTIONr6r9rheapifyheappoprorlZ_whenminmaxrsMAXIMUM_SELECT_TIMEOUTrZ _selectorZselectloggingINFODEBUGr logrrtrangepopleftr~Z_runr}rr)rXZ sched_countZ new_scheduledrZtimeoutrrrrlevelZneventZend_timeZntodoirrrrKs                       zBaseEventLoop._run_oncec Csytj}tj}Wntk r$dSXt|}|j|krsV            ;   /__pycache__/base_subprocess.cpython-36.opt-1.pyc000064400000021720152343301150015522 0ustar003 \#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|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) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@            z BaseSubprocessTransport.__init__cCs |jjg}|jr|jd|jdk r4|jd|j|jdk rP|jd|jn |jdk rf|jdn |jd|jjd}|dk r|jd|j|jjd}|jjd }|dk r||kr|jd |jn0|dk r|jd |j|dk r|jd |jd dj |S)Nclosedzpid=%sz returncode=%sZrunningz not startedrzstdin=%srr zstdout=stderr=%sz stdout=%sz stderr=%sz<%s> ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #sPyj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x"j D]\}}|j|f|qWd_ WnDt k r*}z&|dk r|j r|j|WYdd}~Xn"X|dk rL|j rL|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s6          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrR)r)cbrZr/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r]rZpipe_connection_lost _try_finish)r)rIr[r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r]rZpipe_data_received)r)rIrZr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCst|jjrtjd||||_|jjdkr2||j_|j|jj |j x |j D]}|j sP|j |qPWd|_ dS)Nz%r exited with return code %r)rr#rr8rr returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0_process_exiteds   z'BaseSubprocessTransport._process_exitedccs0|jdk r|jS|jj}|jj||EdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rrZ create_futurerr4)r)r,r/r/r0_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jjDr:d|_|j|jddS)Ncss|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rallrr>rr]_call_connection_lost)r)r/r/r0r^s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r[r/r/r0ris z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rWr pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rWrresume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN) r3rkrlrrSr9rjrnror/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rWr`rI)r)rZr/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { __pycache__/sslproto.cpython-36.opt-2.pyc000064400000032001152343301150014220 0ustar003 \e @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjr|j|jj|t|ks|jrDPqDW||fS)NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr rr7r r;reasonr>r6r?r@rrAr:r8)r#rBoffsetr0ZviewrDrrr feed_appdatas2       z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname__r9r%propertyr$r&r'r)r2r4r5r.rIrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r#loopZ ssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||S)N)rP_get_extra_info)r#namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rP _app_protocol)r#protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rPrW)r#rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rQ)r#rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)NT)rQrP_start_shutdown)r#rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rQwarningswarnResourceWarningr])r#rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)N)rP _transport pause_reading)r#rrrrdQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)N)rPrcresume_reading)r#rrrreYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)N)rPrcset_write_buffer_limits)r#ZhighZlowrrrrfasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)N)rPrcget_write_buffer_size)r#rrrrgvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)Nz/data: expecting a bytes-like instance, got {!r}) isinstancebytes bytearrayrF TypeErrorformattyperJrP_write_appdata)r#rBrrrr7zs z_SSLProtocolTransport.writecCsdS)NFr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)N)rP_abort)r#rrrabortsz_SSLProtocolTransport.abort)N)NN)rJrKrLr%rVrYrZr[r]rZPY34rbrdrerfrgr7rorqrrrrrN&s   rNc@seZdZd'ddZd(ddZdd Zd d Zd d ZddZddZ ddZ d)ddZ ddZ ddZ ddZddZddZd*d!d"Zd#d$Zd%d&ZdS)+ SSLProtocolFNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrOrWrN_app_transport_sslpipe_session_established _in_handshake _in_shutdownrc_call_connection_made)r#rRZ app_protocolrZwaiterrrZcall_connection_maderrrr%s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rzZ cancelledZ set_exceptionZ set_result)r#rDrrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)N)rcrrsrrr|_start_handshake)r# transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)NF)r}rO call_soonrWconnection_lostrcr{r)r#rDrrrrs zSSLProtocol.connection_lostcCs|jjdS)N)rW pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)N)rWresume_writing)r#rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)Nz%r: SSL error %s (reason %s))r|r.r r;rO get_debugrwarningr6rGrprcr7rW data_receivedr\)r#rBr0r1erCrrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl) rOrrdebugrConnectionResetErrorr~rW eof_receivedrrcr])r#Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rurcrV)r#rTrUrrrrS!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr*)rr~rprn)r#rrrr\)s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)rxr:ryrE_process_write_backlog)r#rBrrrrn2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr*r)r*r) rOrrrtime_handshake_start_timer~rxr:r)r#rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr&)$r~r|r&Z getpeercertr rsrr r Z CERT_NONEZmatch_hostname BaseExceptionrOrrhr<rrrcr] ExceptionrrrrruupdaterrrrWrr{r}rr)r#Z handshake_excZsslobjrrDZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q*WWnRtk r8}z4|jr|j|n |j|dt|ts(WYdd}~XnXdS)NrrzFatal error on SSL transport)rcr|rangerErxrIr2rr4 _finalizer7Z_pausedreryrr~ _fatal_errorrhr)r#irBrHr0rCrDrrrrws8      z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrX) rhrZ_FATAL_ERROR_IGNORErOrrrZcall_exception_handlerrcZ _force_close)r#rDrrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r|rcr])r#rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rcrqr)r#rrrrps zSSLProtocol._abort)FNT)N)N)r)rJrKrLr%rrrrrrrrSr\rnrrrrrrprrrrrrs$ "     4, rr)rvr_r ImportErrorrrrrlogrrrrr-r(r3objectrZ_FlowControlMixinZ TransportrNZProtocolrrrrrrs*       wn__pycache__/sslproto.cpython-36.opt-1.pyc000064400000047257152343301150014242 0ustar003 \e @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tj fkr|j tj k|_WYdd}~XnX|jjr|j|jj|t|ks|jrDPqDW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. NFZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewr rr7r r;reasonr>r6r?r@rrAr:r8)r#rBoffsetr0ZviewrDrrr feed_appdatas2       z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname____doc__r9r%propertyr$r&r'r)r2r4r5r.rIrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r#loopZ ssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rQ_get_extra_info)r#namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rQ _app_protocol)r#protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rQrX)r#rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rR)r#rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rRrQ_start_shutdown)r#rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rRwarningswarnResourceWarningr^)r#rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rQ _transport pause_reading)r#rrrreQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rQrdresume_reading)r#rrrrfYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rQrdset_write_buffer_limits)r#ZhighZlowrrrrgasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)z,Return the current size of the write buffer.)rQrdget_write_buffer_size)r#rrrrhvsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrF TypeErrorformattyperJrQ_write_appdata)r#rBrrrr7zs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rQ_abort)r#rrrabortsz_SSLProtocolTransport.abort)N)NN)rJrKrLr%rWrZr[r\r^rZPY34rcrerfrgrhr7rprrrrrrrO&s   rOc@seZdZdZd(ddZd)ddZd d Zd d Zd dZddZ ddZ ddZ d*ddZ ddZ ddZddZddZdd Zd+d"d#Zd$d%Zd&d'ZdS), SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrPrXrO_app_transport_sslpipe_session_established _in_handshake _in_shutdownrd_call_connection_made)r#rSZ app_protocolrZwaiterrrZcall_connection_maderrrr%s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)r{Z cancelledZ set_exceptionZ set_result)r#rDrrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rdrrtrrr}_start_handshake)r# transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)r~rP call_soonrXconnection_lostrdr|r)r#rDrrrrs zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rX pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rXresume_writing)r#rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. Nz%r: SSL error %s (reason %s))r}r.r r;rP get_debugrwarningr6rGrqrdr7rX data_receivedr])r#rBr0r1erCrrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rPrrdebugrConnectionResetErrorrrX eof_receivedrrdr^)r#Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rvrdrW)r#rUrVrrrrT!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr*)rrrqro)r#rrrr])s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)ryr:rzrE_process_write_backlog)r#rBrrrro2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr*r)r*r) rPrrrtime_handshake_start_timerryr:r)r#rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr&)$rr}r&Z getpeercertr rtrr r Z CERT_NONEZmatch_hostname BaseExceptionrPrrir<rrrdr^ ExceptionrrrrrvupdaterrrrXrr|r~rr)r#Z handshake_excZsslobjrrDZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCs>|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj r|jj P|jd=|j t|8_ q*WWnRtk r8}z4|jr|j|n |j|dt|ts(WYdd}~XnXdS)NrrzFatal error on SSL transport)rdr}rangerEryrIr2rr4 _finalizer7Z_pausedrfrzrr _fatal_errorrir)r#irBrHr0rCrDrrrrws8      z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrY) rirZ_FATAL_ERROR_IGNORErPrrrZcall_exception_handlerrdZ _force_close)r#rDrrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r}rdr^)r#rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rdrrr)r#rrrrqs zSSLProtocol._abort)FNT)N)N)r)rJrKrLrMr%rrrrrrrrTr]rorrrrrrqrrrrrss& "     4, rs)rwr`r ImportErrorrrrrlogrrrrr-r(r3objectrZ_FlowControlMixinZ TransportrOZProtocolrsrrrrs*       wn__pycache__/proactor_events.cpython-36.pyc000064400000040670152343301150014623 0ustar003 \O@sdZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j rXddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__//usr/lib64/python3.6/asyncio/proactor_events.pyr s$    z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jdk rN|jd|jj|jdk rh|jd|j|jdk r|jd|j|jrt |j}|jd||j r|jddd j |S) Nclosedclosingzfd=%szread=%szwrite=%rzwrite_bufsize=%sz EOF writtenz<%s> ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname____doc__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs<eZdZdZd fdd ZddZddZd d d ZZS) _ProactorReadPipeTransportzTransport for read pipes.Ncs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrRrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrRrSrrrTrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z@yf|dk rN|j|ks@|jdkr<|js@td|_|j}|jr\d}dS|dkrhdS|jjj|j d|_Wnt k r}z2|js|j |dn|jj rt jdddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r$}z|j |dWYdd}~Xn0tjk rD|js@YnX|jj|jWd|rl|jj|n:|dk r|jj rt jd||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrrAssertionErrorresultr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrTrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rTsL      z(_ProactorReadPipeTransport._loop_reading)NNN)N) r(rMrNrOr rUrVrTrPr#r#)r"r$rQs  rQc@s:eZdZdZddZd ddZddZd d Zd d ZdS)_ProactorBaseWritePipeTransportzTransport for write pipes.cCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr rjZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rtvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJrp)rr#r#r$ruys   z"_ProactorSocketTransport.write_eof)NNN) r(rMrNrOr rrtrurPr#r#)r"r$r\s rcseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rZ _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r)rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler~Z SSLProtocolrZ_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r})rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rQ)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)rw)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningri is_closed_stop_accept_futures_close_self_piperZr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rZr[)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rZrq)rrrbr#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rZZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rZaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r~)rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rYrZr[rrr_ ExceptionrDrr`r)rrsrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rrq)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rYZ_debugr rCrrrrZrr^r*rDr7rr_rr`)rsZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrZ _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrPr#r#)r"r$rs4          ()rO__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrQZWriteTransportrcrwZ Transportr}rZ BaseEventLooprr#r#r#r$s2        M T  #__pycache__/__init__.cpython-36.pyc000064400000001414152343301150013136 0ustar003 \@sBdZddlZyddlmZWnek r8ddlZYnXejdkrryddlmZWnek rpddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkr,ddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorsZwin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r (/usr/lib64/python3.6/asyncio/__init__.pys8  :  __pycache__/compat.cpython-36.opt-2.pyc000064400000001147152343301150013625 0ustar003 \@s2ddlZejdkZejd kZejd kZddZdS) NcCstsdd|D}dj|S)Ncss$|]}t|trt|n|VqdS)N) isinstance memoryviewbytes).0datar &/usr/lib64/python3.6/asyncio/compat.py sz%flatten_list_bytes..)PY34join)Z list_of_datar r r flatten_list_bytes sr)rr)rr)rrr)sys version_inforZPY35ZPY352rr r r r s   __pycache__/base_subprocess.cpython-36.opt-2.pyc000064400000021552152343301150015526 0ustar003 \#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|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) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@            z BaseSubprocessTransport.__init__cCs |jjg}|jr|jd|jdk r4|jd|j|jdk rP|jd|jn |jdk rf|jdn |jd|jjd}|dk r|jd|j|jjd}|jjd }|dk r||kr|jd |jn0|dk r|jd |j|dk r|jd |jd dj |S)Nclosedzpid=%sz returncode=%sZrunningz not startedrzstdin=%srr zstdout=stderr=%sz stdout=%sz stderr=%sz<%s> ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #sPyj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<|jj j x"j D]\}}|j|f|qWd_ WnDt k r*}z&|dk r|j r|j|WYdd}~Xn"X|dk rL|j rL|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s6          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrR)r)cbrZr/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r]rZpipe_connection_lost _try_finish)r)rIr[r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r]rZpipe_data_received)r)rIrZr/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCst|jjrtjd||||_|jjdkr2||j_|j|jj |j x |j D]}|j sP|j |qPWd|_ dS)Nz%r exited with return code %r)rr#rr8rr returncoder]rZprocess_exitedr^rrUrV)r)rar,r/r/r0_process_exiteds   z'BaseSubprocessTransport._process_exitedccs0|jdk r|jS|jj}|jj||EdHS)N)rrZ create_futurerr4)r)r,r/r/r0_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jjDr:d|_|j|jddS)Ncss|]}|dk o|jVqdS)N) disconnected).0pr/r/r0 sz6BaseSubprocessTransport._try_finish..T)rallrr>rr]_call_connection_lost)r)r/r/r0r^s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r[r/r/r0ris z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r]r_r`rbrcr^ri __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rWrIr6rd)r)rWrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rSsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rdrWr_rI)r)r[r/r/r0rjsz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rWr pause_writing)r)r/r/r0rnsz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rWrresume_writing)r)r/r/r0rosz'WriteSubprocessPipeProto.resume_writingN) r3rkrlrrSr9rjrnror/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rWr`rI)r)rZr/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rkrlrpr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { __pycache__/queues.cpython-36.pyc000064400000020326152343301150012711 0ustar003 \@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr&/usr/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrsc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS)*ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts  z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7remove ValueErrorr8r( get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr>s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rr=rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r@r>rArCrrrrrs&      c@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrEr%rFr"rrrrrsc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs JoinableQueue)r__all__rrGrr r Z coroutinesr ExceptionrrrrrZPY35rIr#rrrrs     H __pycache__/locks.cpython-36.opt-1.pyc000064400000036132152343301150013456 0ustar003 \<@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s(eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr%/usr/lib64/python3.6/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s r c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s  rcsReZdZdZddddZfddZdd Zed d Zd d Z ddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... N)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r?r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)z*Wake up the first waiter if it isn't done.NT)nextiterr( StopIterationdone set_result)rr@rrrr?s zLock._wake_up_first) rrrrrr0r,r rrr? __classcell__rr)r5rrYs4  csReZdZdZddddZfddZdd Zd d Zd d Ze ddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. N)r%cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rGr(rDrE)rr@rrrrHs  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rG)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rGr*r;r(r<r=)rr@rrrwait s   z Event.wait) rrrrrr0rIrHrJr rKrFrr)r5rrs  csZeZdZdZdddddZfddZedd Zed d Zdd dZ ddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. N)r%cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNTF) r,rrr*r;r(r<r=rr r>)rr@r6rrrrKEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rK)rZ predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)rnidxr@rrrnotifyys  zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rQr2r()rrrr notify_allszCondition.notify_all)N)r) rrrrrr0r rKrNrQrRrFrr)r5rr!s  &  csTeZdZdZdddddZfddZd d Zd d Zed dZ ddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rN)r%cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r r+)rvaluer%rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r(popleftrDrE)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrrs    zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rGrU)rrrrrszSemaphore.release)r) rrrrrr0rUr,r rrrFrr)r5rrs   cs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rN)r%cs||_tj||ddS)N)r%) _bound_valuer/r)rrSr%)r5rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrrs zBoundedSemaphore.release)r)rrrrrrrFrr)r5rrs)r__all__r&rr r Z coroutinesr r rrrrrrrrrrs    .ByM__pycache__/sslproto.cpython-36.pyc000064400000047571152343301150013302 0ustar003 \e @sddlZddlZy ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d d Z d Z d ZdZdZGdddeZGdddejejZGdddejZdS)N) base_events)compat) protocols) transports)loggercCsj|r tdttdr*tj}|sfd|_n|j dkrtj |_ |j tj tj tjfkrЂ|j tj k|_WYdd}~XnX|jjr |j|jj|t|ks|jrdPqdW||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. rNFZPROTOCOL_IS_SHUTDOWN)r/r0rr memoryviewr rr9r r=reasonr@r8rArBrrCr<r:)r#rDoffsetr2ZviewrFrrr feed_appdatas4         z_SSLPipe.feed_appdatai)N)N)N)F)r)__name__ __module__ __qualname____doc__r;r%propertyr$r&r'r)r4r6r7r.rJrrrrr0s       Jrc@seZdZddZdddZddZdd Zd d Zd d Ze j rHddZ ddZ ddZ dddZddZddZddZddZdS) _SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)r#loopZ ssl_protocolrrrr%)sz_SSLProtocolTransport.__init__NcCs|jj||S)z#Get optional transport information.)rR_get_extra_info)r#namedefaultrrrget_extra_info/sz$_SSLProtocolTransport.get_extra_infocCs ||j_dS)N)rR _app_protocol)r#protocolrrr set_protocol3sz"_SSLProtocolTransport.set_protocolcCs|jjS)N)rRrY)r#rrr get_protocol6sz"_SSLProtocolTransport.get_protocolcCs|jS)N)rS)r#rrr is_closing9sz _SSLProtocolTransport.is_closingcCsd|_|jjdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rSrR_start_shutdown)r#rrrclose<sz_SSLProtocolTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rSwarningswarnResourceWarningr_)r#rrr__del__Ks z_SSLProtocolTransport.__del__cCs|jjjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rR _transport pause_reading)r#rrrrfQsz#_SSLProtocolTransport.pause_readingcCs|jjjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rRreresume_reading)r#rrrrgYsz$_SSLProtocolTransport.resume_readingcCs|jjj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rRreset_write_buffer_limits)r#ZhighZlowrrrrhasz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjjS)z,Return the current size of the write buffer.)rRreget_write_buffer_size)r#rrrrivsz+_SSLProtocolTransport.get_write_buffer_sizecCs<t|tttfs$tdjt|j|s,dS|jj |dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z/data: expecting a bytes-like instance, got {!r}N) isinstancebytes bytearrayrG TypeErrorformattyperKrR_write_appdata)r#rDrrrr9zs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr)r#rrr can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jjdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)rR_abort)r#rrrabortsz_SSLProtocolTransport.abort)N)NN)rKrLrMr%rXr[r\r]r_rZPY34rdrfrgrhrir9rqrsrrrrrP&s   rPc@seZdZdZd(ddZd)ddZd d Zd d Zd dZddZ ddZ ddZ d*ddZ ddZ ddZddZddZdd Zd+d"d#Zd$d%Zd&d'ZdS), SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTcCstdkrtd|st||}||_|r6| r6||_nd|_||_t|d|_tj |_ d|_ ||_ ||_ ||_t|j ||_d|_d|_d|_d|_d|_||_dS)Nzstdlib ssl module not available)rrF)r r,rrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrQrYrP_app_transport_sslpipe_session_established _in_handshake _in_shutdownre_call_connection_made)r#rTZ app_protocolrZwaiterrrZcall_connection_maderrrr%s,    zSSLProtocol.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)r|Z cancelledZ set_exceptionZ set_result)r#rFrrr_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|jdS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rerrurrr~_start_handshake)r# transportrrrconnection_mades  zSSLProtocol.connection_madecCs8|jrd|_|jj|jj|d|_d|_|j|dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FN)rrQ call_soonrYconnection_lostrer}r)r#rFrrrrs zSSLProtocol.connection_lostcCs|jjdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rY pause_writing)r#rrrrszSSLProtocol.pause_writingcCs|jjdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rYresume_writing)r#rrrrszSSLProtocol.resume_writingcCs|jdkrdSy|jj|\}}WnHtjk rj}z*|jjrTtjd||j|j |j dSd}~XnXx|D]}|j j |qrWx(|D] }|r|j j|q|jPqWdS)zXCalled when some SSL data is received. The argument is a bytes object. Nz%r: SSL error %s (reason %s))r~r.r r=rQ get_debugrwarningr8rHrrrer9rY data_receivedr^)r#rDr2r3erErrrrs"    zSSLProtocol.data_receivedc CsTzB|jjrtjd||jt|js@|jj}|r@tj dWd|j j XdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rQrrdebugrConnectionResetErrorrrY eof_receivedrrer_)r#Z keep_openrrrr s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|jj||S|SdS)N)rwrerX)r#rVrWrrrrU!s    zSSLProtocol._get_extra_infocCs.|jr dS|jr|jnd|_|jddS)NTr*)rrrrrp)r#rrrr^)s  zSSLProtocol._start_shutdowncCs.|jj|df|jt|7_|jdS)Nr)rzr<r{r/_process_write_backlog)r#rDrrrrp2szSSLProtocol._write_appdatacCsH|jjr$tjd||jj|_nd|_d|_|jjd|j dS)Nz%r starts SSL handshakeTr*r)r*r) rQrrrtime_handshake_start_timerrzr<r)r#rrrr7s   zSSLProtocol._start_handshakecCsTd|_|jj}yF|dk r||j}t|jdsR|jrR|jjtj krRtj ||jWn~t k r}zb|j j rt|tjrtjd|ddntjd|dd|jjt|tr|j|dSWYdd}~XnX|j j r|j j|j}tjd||d|jj||j|j|d |jr4|jj|j |jd|_!|j j"|j#dS) NFr z5%r: SSL handshake failed on verifying the certificateT)exc_infoz%r: SSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr&)$rr~r&Z getpeercertr rurr r Z CERT_NONEZmatch_hostname BaseExceptionrQrrjr>rrrer_ ExceptionrrrrrwupdaterrrrYrr}rrr)r#Z handshake_excZsslobjrrFZdtrrr_on_handshake_completeCsD         z"SSLProtocol._on_handshake_completecCsJ|jdks|jdkrdSyxtt|jD]}|jd\}}|rT|jj||\}}n*|rl|jj|j}d}n|jj|j }d}x|D]}|jj |qW|t|kr||f|jd<|jj st |jj r|jjP|jd=|jt|8_q*WWnRtk rD}z4|jr|j|n |j|dt|ts4WYdd}~XnXdS)NrrzFatal error on SSL transport)rer~ranger/rzrJr4rr6 _finalizer9r'r0Z_pausedrgr{rr _fatal_errorrjr)r#irDrIr2rErFrrrrws:       z"SSLProtocol._process_write_backlogFatal error on transportcCsXt|tjr*|jjrBtjd||ddn|jj|||j|d|jrT|jj |dS)Nz%r: %sT)r)messageZ exceptionrrZ) rjrZ_FATAL_ERROR_IGNORErQrrrZcall_exception_handlerreZ _force_close)r#rFrrrrrs   zSSLProtocol._fatal_errorcCsd|_|jdk r|jjdS)N)r~rer_)r#rrrrs zSSLProtocol._finalizec Cs(z|jdk r|jjWd|jXdS)N)rersr)r#rrrrrs zSSLProtocol._abort)FNT)N)N)r)rKrLrMrNr%rrrrrrrrUr^rprrrrrrrrrrrrts& "     4, rt)rxrar ImportErrorrrrrlogrrrrr-r(r5objectrZ_FlowControlMixinZ TransportrPZProtocolrtrrrrs*       wn__pycache__/base_tasks.cpython-36.pyc000064400000003507152343301150013523 0ustar003 \@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror */usr/lib64/python3.6/asyncio/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   __pycache__/unix_events.cpython-36.pyc000064400000073535152343301150013763 0ustar003 \ @s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkredddZy ejZWnek r,ddZYnXGdddejZ e!edrVddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%rej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr+/usr/lib64/python3.6/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZdZd"fdd ZddZfddZd d Zd d Zd dZ ddZ ddZ d#ddZ d$ddZ ed%ddZddZeddddddZed&ddddd d!ZZS)'_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)rrrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)rsig)r!rrr%>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)rdatarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)rr.callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4rKeyErrorr5SIGINTdefault_int_handlerSIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr3r@r5NSIGr8)rr.rrrr4s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)rpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)rrOrPrQrRrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rQrR) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)rrPrBshellstdinstdoutstderrbufsizerRkwargswatcherrQtransprCerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)rpid returncoderbrrrrYsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|dkst|tst|r,|dkr|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rrv)rKboolr3r8_fspathr"rkrlstatS_ISSOCKosst_moderemoveFileNotFoundErrorr9rerrorZbindr%r>Z EADDRINUSEr@rnrrorpZServerZlistenrmZ_start_serving) rrqrrhrurgrcrCmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname____doc__rr#r%r1rEr/r)r4rSrUr rdrYrsr __classcell__rr)r!rr1s, -      %r set_blockingcCstj|ddS)NF)r{r)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLr{ O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rNiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrOFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper7_fileno _protocol_closingr{fstatr|ryS_ISFIFOrzS_ISCHRr8r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rlooprOrPrQrRmode)r!rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r!rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)rr=r rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)r{readrmax_sizeBlockingIOErrorInterruptedErrorr9 _fatal_errorrZ data_receivedr get_debugrr=r_remove_readerrZ eof_received_call_connection_lost)rr0rCrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)rrrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)rrrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)rrPrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)rrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)rrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)rrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrrrP) rKr9r>ZEIOrrrdebugcall_exception_handlerrr)rrCrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)rrCrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)rrCrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr%rPY34rrrrrrr)r!rrNMs rNcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rTNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrOrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr7rr bytearray_buffer _conn_lostrr{rr|ryrrrzr8rrrrr&platform startswithrrr r) rrrOrPrQrRrZis_charZis_fifoZ is_socket)r!rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r!rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)rr=r rr_rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)rrrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr=rrBrokenPipeError)rrrrrs   z#_UnixWritePipeTransport._read_readycCs0t|tttfstt|t|tr.t|}|s6dS|jsB|jrj|jtj krXt j d|jd7_dS|j syt j|j|}WnTttfk rd}Yn:tk r}z|jd7_|j|ddSd}~XnX|t|krdS|dkrt||d}|jj|j|j|j |7_ |jdS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rrz#Fatal write error on pipe transport)rKbytesr memoryviewrjreprrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESrwarningrr{writerrrrZrrrZ _add_writer _write_readyZ_maybe_pause_protocol)rr0nrCrrrrs4       z_UnixWritePipeTransport.writecCs|jstdytj|j|j}Wnjttfk r:Yntk r}z8|jj|j d7_ |j j |j|j |dWYdd}~XnfX|t |jkr|jj|j j |j|j|jr|j j|j|jddS|dkr|jd|=dS)NzData should not be emptyrz#Fatal write error on pipe transportr)rrjr{rrrrrZr-rr_remove_writerrrZ_maybe_resume_protocolrrr)rrrCrrrr>s(   z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCsB|jr dS|jstd|_|js>|jj|j|jj|jddS)NT) rrrjrrrrrr)rrrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)rrPrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)rrrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)rrrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)rrrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrrrP) rKrZ_FATAL_ERROR_IGNORErrrrrrr)rrCrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr-rrr)rrCrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)rrCrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr%rrrrrrrrrr)r!rrTs$% !   rTset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rWc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r[r\r]r^Zuniversal_newlinesr_wb) buffering) subprocessPIPErr#rr7Popen_procr%rdetachr\) rrBr[r\r]r^r_r`Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrWsrWc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)rrerArBrrrrXs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)rrerrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)rrrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)rrrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)rrrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)rabcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrrXrrr%rrrrrrrs  c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)rrrrrszBaseChildWatcher.__init__cCs|jddS)N)r)rrrrr%szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)rrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs~|dkst|tjst|jdk r<|dkr<|jr %dr2)r{rrrrrrrrGrrrrrrr)rrerrfrArBrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrrr%rrrXrrrrr)r!rrs   csHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r)r!rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrKrcurrent_thread _MainThreadr_localr)rrrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrKrrrr)rr)r!rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)rrrrrV&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|tst|jdk r*|jj||_dS)z$Set the watcher for child processes.N)rKrrjrr%)rrarrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrrrVrrrr)r!rrs   r)5rr>r{r5r"ryrr&rr*rrrrrrr r r r r logr__all__r ImportErrorrfspathrxAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrNZ_FlowControlMixinZWriteTransportrTrrZBaseSubprocessTransportrWrrrrZBaseDefaultEventLoopPolicyrrrrrrrsn                O  F=On2__pycache__/events.cpython-36.pyc000064400000061374152343301150012716 0ustar003 \[@sdZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddZddZd3ddZddZd4ddZGdddZGd ddeZGd!ddZGd"ddZGd#ddZGd$d%d%eZdae jZGd&d'd'e jZeZd(dZd)d Z d*d+Z!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'd2d Z(dS)5z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder &/usr/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s<eZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3__doc__ __slots__rSrYr[r\rer r r r!rbs   csxeZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZZS)rz7Object returned by timed callback registration methods. _scheduled_whencs:|dk s ttj||||jr*|jd=||_d|_dS)NrFrT)AssertionErrorsuperrSrLrjri)rPwhenrQr/rR)rUr r!rSs  zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rlrYrJinsertrj)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashrj)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)rj)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)rj__eq__)rPrsr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)rj)rPrsr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rjru)rPrsr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJNotImplemented)rPrsr r r!rus      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rury)rPrsZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrlr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrhrSrYrrrtrvrwrxrurzr\ __classcell__r r )rUr!rs  c@s eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)ry)rPr r r!closeszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)ry)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3rgr}r~r r r r!rsc @seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d$d$d$d%d&d'Zdhd(d)Zdid*d$d$d$d*d*d*d+d,d-Zdjejejd*d.d*d*d*d/d0d1Zd*d*d*d2d3d4Zd*d.d*d5d6d7Zdkd$d$d$d*d*d*d*d8d9d:Zd;d<Zd=d>Z e!j"e!j"e!j"d?d@dAZ#e!j"e!j"e!j"d?dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4dddeZ5dfdgZ6d*S)lrzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)r)rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)r)rPr r r!stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.N)r)rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.N)r)rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)r)rPr r r!r}s zAbstractEventLoop.closecCstdS)z,Shutdown all active asynchronous generators.N)r)rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.N)r)rPr^r r r!r{sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r)rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r)rPrmrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r)rPr r r!time"szAbstractEventLoop.timecCstdS)N)r)rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r)rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r)rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r)rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r)rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r)rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r)rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)r) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r)rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)r)rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)r) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)r)rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)r)rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r)rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r)rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r)rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r)rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r)rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r)rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r)rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r)rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r)rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r)rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r)rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r)rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r)rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r)rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r)rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r)rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r)rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r)rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r)rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r)rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgrrrrrr}rr{rrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rst   '!   c@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)r)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.N)r)rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)r)rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.N)r)rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.N)r)rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN) r4rfr3rgrr r r r r r r r!rs  c@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|tst||j_dS)zSet the event loop.TN)rrrrrkrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rgrrlocalrrSrr r r r r r!r9s rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr r r r!rscCs|dkst|tst|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)rrrkr)Zpolicyr r r!rscCst}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr r r!rs cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rRr r r!r scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r r r r!r scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r r r r!r scCs tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr r r!r s)r2)NN))rg__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sZ    >8 5"7   __pycache__/selector_events.cpython-36.opt-2.pyc000064400000066420152343301150015553 0ustar003 \ @s8dgZddlZddlZddlZddlZddlZddlZy ddlZWnek rZdZYnXddl m Z ddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd lmZdd lmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)BaseSelectorEventLoopN) base_events)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.6/asyncio/selector_events.py_test_selector_event s rcsneZdZdNfdd ZdOdddddZdPdddddd d Zdddddd d ZdQd dZfddZddZ ddZ ddZ ddZ ddZ ddZdRddZdSd d!ZedTd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z d@dAZ!dBdCZ"dDdEZ#dFdGZ$dHdIZ%dJdKZ&dLdMZ'Z(S)UrNcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)NFT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)N)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)N)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)N)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)N)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)Nrzthe socket must be non-blocking)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)Nrzthe socket must be non-blocking)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)Nrzthe socket must be non-blockingAF_UNIX)familyprotoloop)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)Nrzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN))r __module__ __qualname__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sR      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jr dSy|jj|j}Wn\ttfk r4Yntk rx}z*|jj|j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj|j |j r|jdn|jr|jjtjdS)Nz%Fatal write error on socket transport)rrrHrrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs&   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0)__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsB             ii__pycache__/events.cpython-36.opt-2.pyc000064400000042371152343301150013652 0ustar003 \[@s|dddddddddd d d d d gZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddZ ddZd2ddZddZd3ddZGdddZGdddeZGd ddZGd!ddZGd"ddZGd#d$d$eZdaejZGd%d&d&ejZeZd'd Zd(d Zd)d*Z d+dZ!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'dS)4AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder &/usr/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)Ncss|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s8eZdZdZdd Zd d Zd d ZddZddZdS)r _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3 __slots__rSrYr[r\rer r r r!rbs   csteZdZddgZfddZfddZddZd d Zd d Zd dZ ddZ ddZ ddZ fddZ ZS)r _scheduled_whencs.tj||||jr|jd=||_d|_dS)NrFrT)superrSrLrirh)rPwhenrQr/rR)rUr r!rSs zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rjrYrJinsertri)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashri)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)ri)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)ri__eq__)rPrqr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)ri)rPrqr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rirs)rPrqr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrirHrIrJNotImplemented)rPrqr r r!rss      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rsrw)rPrqZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrjr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrSrYrprrrtrurvrsrxr\ __classcell__r r )rUr!rs  c@seZdZddZddZdS)rcCstS)N)rw)rPr r r!closeszAbstractServer.closecCstS)N)rw)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3r{r|r r r r!rsc @seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d#d#d#d$d%d&Zdgd'd(Zdhd)d#d#d#d)d)d)d*d+d,Zdiejejd)d-d)d)d)d.d/d0Zd)d)d)d1d2d3Zd)d-d)d4d5d6Zdjd#d#d#d)d)d)d)d7d8d9Zd:d;Zdd?d@Z"e j!e j!e j!d>dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWdXZ.dYdZZ/d[d\Z0d]d^Z1d_d`Z2dadbZ3dcddZ4dedfZ5d)S)krcCstdS)N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)N)r})rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)N)r})rPr r r!stopszAbstractEventLoop.stopcCstdS)N)r})rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)N)r})rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)N)r})rPr r r!r{s zAbstractEventLoop.closecCstdS)N)r})rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)N)r})rPr^r r r!rysz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r})rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r})rPrkrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r})rPr r r!time"szAbstractEventLoop.timecCstdS)N)r})rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r})rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r})rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r})rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r})rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r})rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r})rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r}) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)N)r}) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r})rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)N)r})rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)N)r}) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)N)r})rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)N)r})rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r})rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r})rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r})rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r})rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r})rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r})rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r})rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r})rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r})rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r})rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r})rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r})rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r})rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r})rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r})rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r})rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r})rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r})rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r})rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r})rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)6r4rfr3r~rrrrr{rryrrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rsr   '!   c@s4eZdZddZddZddZddZd d Zd S) rcCstdS)N)r})rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)N)r})rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)N)r})rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)N)r})rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)N)r})rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN)r4rfr3rr r r r r r r r!rs  c@sBeZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)NT)rrrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)N) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rrlocalrrSrr r r r r r!r9s  rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)N)rrr r r r!rscCs|adS)N)r)Zpolicyr r r!rscCst}|dk r|StjS)N)rrr)Z current_loopr r r!rs cCstj|dS)N)rr )rRr r r!r scCs tjS)N)rr r r r r!r scCs tjS)N)rr r r r r!r scCs tj|S)N)rr )rr r r!r s)r2)NN)(__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sX    >8 5"7   __pycache__/windows_events.cpython-36.opt-1.pyc000064400000051770152343301150015426 0ustar003 \l@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/ __classcell__rr)rrr's   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr7Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr7r=r8)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r9r8r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rCrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rCrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rCrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws   r6csFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. N)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr;r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rE)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rE)rr$)rrrr.s  z_WaitCancelFuture.set_exception) r1r2r3r4rr'r/r.r5rr)rrrDs  rDcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr:r;proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rJr< CloseHandlerKrI _unregisterrrr@)rr?)rrrr@s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r ZUnregisterWaitExrJr(rArBrr)r*rI _wait_cancelr@rK)rr;r+r,rrrrCs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrHs rHc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs      zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs     zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs  rPc@seZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd fdd ZddZeddZed d Zedd d Z Z S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt}tj|dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstjS)N)r rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)exc_infor)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterri) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerikwargsrzZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3r4rrgr rpryrr5rr)rrr/s /c@seZdZdZd1ddZddZddZd2d d Zd d Zd3ddZ d4ddZ ddZ ddZ ddZ eddZd5ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd6d)d*Zd+d,Zd-d.Zd/d0Zd S)7rz#Proactor implementation using IOCP.cCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr9 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr=)rtimeoutrXrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)r{r/)rvaluer?rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(rAr ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(rAr rrr~)rorrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrurb)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(rAerrnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rorr)rarrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrs s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(rAZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr:r+rrrrjs  zIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr:rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrE)rrFZ done_callbackr?rrrrO7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r=)rorr)rmrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r<INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rDr)rHrr)rr:rZ _is_cancelmsrr;rr)rmrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r9r]r rrtr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrhs zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr>)rrrrrrNszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr<rMrr'doner(r.rr>r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr=sJ         zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrDr'r(r)rr*r=r debugrrr<rM)rr r?rrrr+r,rrrrbs,     "   zIocpProactor.closecCs |jdS)N)rb)rrrrrdszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr=rrbrdrrrrrs.          7 c@seZdZddZdS)r|c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)rrrrrcsjj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr7rv) rr~rrrrrrrrmr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|sr|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr)-r4r<rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr6rDrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsL          0J4;]k__pycache__/queues.cpython-36.opt-1.pyc000064400000020326152343301150013650 0ustar003 \@sdZdddddgZddlZddlZdd lmZdd lmZdd lmZdd lm Z Gd dde Z Gddde Z GdddZ Gddde ZGddde Zejse ZejddS)ZQueuesQueue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@seZdZdZdS)rz]Exception raised when Queue.get_nowait() is called on a Queue object which is empty. N)__name__ __module__ __qualname____doc__rr&/usr/lib64/python3.6/asyncio/queues.pyrsc@seZdZdZdS)rzgException raised when the Queue.put_nowait() method is called on a Queue object which is full. N)r r rrrrrrrsc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZeddZdd Zed!d"Zd#d$Zd%d&Zed'd(ZdS)*ra A queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "yield from put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)r popleft)rrrr_get=sz Queue._getcCs|jj|dS)N)r append)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r!doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r)r*r r,)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}r z _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r)rgetattrlistr rlenrr)rresultrrrr,Ts  z Queue._formatcCs t|jS)zNumber of items in the queue.)r1r )rrrrqsize`sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)r)rrrrrdsz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.)r )rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr3)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. This method is a coroutine. N) r5r create_futurerr#cancel cancelledr( put_nowait)rr$Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)r5rr%rrclearr(r)rr$rrrr9s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)zRemove and return an item from the queue. If queue is empty, wait until an item is available. This method is a coroutine. N) r4rr6rr#r7remove ValueErrorr8r( get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )r4rr"r(r)rr$rrrr>s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rr=rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwait)rrrrjoins z Queue.join)r)r r rrrrr"r%r(r-r.r,r3propertyrr4r5r r:r9r@r>rArCrrrrrs&      c@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dS)N)r )rrrrrrszPriorityQueue._initcCs||j|dS)N)r )rr$heappushrrrr%szPriorityQueue._putcCs ||jS)N)r )rheappoprrrr"szPriorityQueue._getN) r r rrrheapqrEr%rFr"rrrrrsc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dS)N)r )rrrrrrszLifoQueue._initcCs|jj|dS)N)r r#)rr$rrrr%szLifoQueue._putcCs |jjS)N)r pop)rrrrr"szLifoQueue._getN)r r rrrr%r"rrrrrs JoinableQueue)r__all__rrGrr r Z coroutinesr ExceptionrrrrrZPY35rIr#rrrrs     H __pycache__/base_futures.cpython-36.opt-2.pyc000064400000003251152343301150015027 0ustar003 \@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@s eZdZdS)InvalidStateErrorN)__name__ __module__ __qualname__rr,/usr/lib64/python3.6/asyncio/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)N_asyncio_future_blocking)hasattr __class__r )objrrr isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) NcSs tj|fS)N)rZ_format_callback_source)callbackrrr format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerrrr _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframerrr _future_repr_info6s     r!)__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr!rrrr s   __pycache__/__init__.cpython-36.opt-1.pyc000064400000001414152343301150014075 0ustar003 \@sBdZddlZyddlmZWnek r8ddlZYnXejdkrryddlmZWnek rpddlZYnXddlTddlTddl Tddl Tddl Tddl Tddl TddlTddlTddlTddlTejeje je je je je jejejejejZejdkr,ddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N) selectorsZwin32) _overlapped)*)__doc__sysr ImportErrorplatformrZ base_eventsZ coroutinesZeventsZfuturesZlocksZ protocolsZqueuesZstreams subprocessZtasksZ transports__all__Zwindows_eventsZ unix_eventsr r (/usr/lib64/python3.6/asyncio/__init__.pys8  :  __pycache__/proactor_events.cpython-36.opt-1.pyc000064400000040377152343301150015566 0ustar003 \O@sdZdgZddlZddlZddlmZddlmZddlmZddlmZdd lm Z dd lm Z dd l m Z Gd d d e j e jZGdddee jZGdddee jZGdddeZGdddeee jZGdddeee jZGdddejZdS)zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. BaseProactorEventLoopN) base_events)compat) constants)futures)sslproto) transports)loggercseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j rXddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncstj|||j|||_||_||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rh|jj |jj|jj||dk r|jjtj|ddS)NrF)super__init__ _set_extra_sock _protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attach_loop call_soonZconnection_maderZ_set_result_unless_cancelled)selfloopsockprotocolwaiterextraserver) __class__//usr/lib64/python3.6/asyncio/proactor_events.pyr s$    z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jdk rN|jd|jj|jdk rh|jd|j|jdk r|jd|j|jrt |j}|jd||j r|jddd j |S) Nclosedclosingzfd=%szread=%szwrite=%rzwrite_bufsize=%sz EOF writtenz<%s> ) r"__name__rappendrfilenorrrlenrjoin)rinfobufsizer#r#r$__repr__/s"         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)_extra)rrr#r#r$rBsz%_ProactorBasePipeTransport._set_extracCs ||_dS)N)r)rrr#r#r$ set_protocolEsz'_ProactorBasePipeTransport.set_protocolcCs|jS)N)r)rr#r#r$ get_protocolHsz'_ProactorBasePipeTransport.get_protocolcCs|jS)N)r)rr#r#r$ is_closingKsz%_ProactorBasePipeTransport.is_closingcCs^|jr dSd|_|jd7_|j r@|jdkr@|jj|jd|jdk rZ|jjd|_dS)NTr) rrrrrr_call_connection_lostrcancel)rr#r#r$closeNs  z _ProactorBasePipeTransport.closecCs*|jdk r&tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr7)rr#r#r$__del__]s  z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)exc_info)message exceptionZ transportr) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr debugcall_exception_handlerr _force_close)rexcr?r#r#r$ _fatal_errorcs   z'_ProactorBasePipeTransport._fatal_errorcCsj|jr dSd|_|jd7_|jr4|jjd|_|jrJ|jjd|_d|_d|_|jj|j |dS)NTrr) rrrr6rrrrrr5)rrFr#r#r$rEps  z'_ProactorBasePipeTransport._force_closec Cs^z|jj|Wdt|jdr,|jjtj|jjd|_|j}|dk rX|j d|_XdS)Nshutdown) rZconnection_losthasattrrrHsocketZ SHUT_RDWRr7rZ_detach)rrFr!r#r#r$r5s  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|S)N)rrr+)rsizer#r#r$get_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)r=)r( __module__ __qualname____doc__r r/rr2r3r4r7rZPY34r<rGrEr5rL __classcell__r#r#)r"r$r s r cs<eZdZdZd fdd ZddZddZd d d ZZS) _ProactorReadPipeTransportzTransport for read pipes.Ncs4tj||||||d|_d|_|jj|jdS)NF)r r _paused_reschedule_on_resumerr _loop_reading)rrrrrr r!)r"r#r$r sz#_ProactorReadPipeTransport.__init__cCs0|js |jrdSd|_|jjr,tjd|dS)NTz%r pauses reading)rrRrrBr rC)rr#r#r$ pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsP|js|j rdSd|_|jr6|jj|j|jd|_|jjrLtj d|dS)NFz%r resumes reading) rrRrSrrrTrrBr rC)rr#r#r$resume_readings z)_ProactorReadPipeTransport.resume_readingcCs|jrd|_dSd}z"yH|dk r0d|_|j}|jr>d}dS|dkrJdS|jjj|jd|_Wnt k r}z2|js|j |dn|jj rt j dddWYdd}~Xntk r}z|j|WYdd}~Xn^tk r}z|j |dWYdd}~Xn0tjk r&|js"YnX|jj|jWd|rN|jj|n:|dk r|jj rpt j d||jj}|s|jXdS)NTiz"Fatal read error on pipe transportz*Read error on pipe transport while closing)r>z%r received EOF)rRrSrresultrr _proactorrecvrConnectionAbortedErrorrGrBr rCConnectionResetErrorrEOSErrorrCancelledErroradd_done_callbackrTrZ data_receivedZ eof_receivedr7)rfutdatarFZ keep_openr#r#r$rTsH     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r(rMrNrOr rUrVrTrPr#r#)r"r$rQs  rQc@s:eZdZdZddZd ddZddZd d Zd d ZdS)_ProactorBaseWritePipeTransportzTransport for write pipes.cCst|tttfs&dt|j}t||jr4td|speernamezgetpeername() failed on %r) r1Z getsocknamerJerrorAttributeErrorrrBr riZ getpeername)rrr#r#r$rfs    z#_ProactorSocketTransport._set_extracCsdS)NTr#)rr#r#r$rsvsz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jjtjdS)NT)rrrrrHrJro)rr#r#r$rtys   z"_ProactorSocketTransport.write_eof)NNN) r(rMrNrOr rrsrtrPr#r#)r"r$r~\s r~cseZdZfddZd-ddZd.ddddddd Zd/d d Zd0d d Zd1ddZfddZ ddZ ddZ ddZ ddZ ddZddZddZd2d d!Zd"d#Zd3d%d&Zd'd(Zd)d*Zd+d,ZZS)4rcsHtjtjd|jj||_||_d|_i|_ |j ||j dS)NzUsing proactor: %s) r r r rCr"r(rY _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe)rZproactor)r"r#r$r s  zBaseProactorEventLoop.__init__NcCst||||||S)N)r~)rrrrr r!r#r#r$_make_socket_transports z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer r!c Cs<tjstdtj||||||} t||| ||d| jS)NzOProactor event loop requires Python 3.5 or newer (ssl.MemoryBIO) to support SSL)r r!)rZ_is_sslproto_availabler}Z SSLProtocolr~Z_app_transport) rZrawsockr sslcontextrrrr r!Z ssl_protocolr#r#r$_make_ssl_transports  z)BaseProactorEventLoop._make_ssl_transportcCst|||||S)N)r|)rrrrr r#r#r$_make_duplex_pipe_transportsz1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||S)N)rQ)rrrrr r#r#r$_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||S)N)rv)rrrrr r#r#r$_make_write_pipe_transportsz0BaseProactorEventLoop._make_write_pipe_transportcsP|jrtd|jrdS|j|j|jjd|_d|_tjdS)Nz!Cannot close a running event loop) Z is_runningrh is_closed_stop_accept_futures_close_self_piperYr7rr )r)r"r#r$r7s zBaseProactorEventLoop.closecCs|jj||S)N)rYrZ)rrnr#r#r$ sock_recvszBaseProactorEventLoop.sock_recvcCs|jj||S)N)rYrp)rrrar#r#r$ sock_sendallsz"BaseProactorEventLoop.sock_sendallcCs|jj||S)N)rYZconnect)rrZaddressr#r#r$ sock_connectsz"BaseProactorEventLoop.sock_connectcCs |jj|S)N)rYaccept)rrr#r#r$ sock_acceptsz!BaseProactorEventLoop.sock_acceptcCstdS)N)r})rr#r#r$ _socketpairsz!BaseProactorEventLoop._socketpaircCsL|jdk r|jjd|_|jjd|_|jjd|_|jd8_dS)Nr)rr6_ssockr7_csock _internal_fds)rr#r#r$rs    z&BaseProactorEventLoop._close_self_pipecCsF|j\|_|_|jjd|jjd|jd7_|j|jdS)NFr)rrrZ setblockingrr_loop_self_reading)rr#r#r$rs   z%BaseProactorEventLoop._make_self_pipecCsy$|dk r|j|jj|jd}WnHtjk r:dStk rl}z|jd||dWYdd}~XnX||_|j |j dS)Niz.Error on reading from the event loop self pipe)r?r@r) rXrYrZrrr^ ExceptionrDrr_r)rrrrFr#r#r$rsz(BaseProactorEventLoop._loop_self_readingcCs|jjddS)N)rrp)rr#r#r$_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs&dfdd jdS)Ncs"y|dk rl|j\}}jr,tjd||}dk rVj||dd|idnj||d|idjrxdSjj}Wn~t k r}zDj d krj d|dj njrtjd dd WYdd}~Xn8t jk rj YnX|jj <|jdS) Nz#%r got a new connection from %r: %rTr)rr r!)r r!rzAccept failed on a socket)r?r@rJzAccept failed on socket %r)r>)rXZ_debugr rCrrrrYrr]r*rDr7rr^rr_)rrZconnZaddrrrF)rprotocol_factoryrr!rrr#r$rs>     z2BaseProactorEventLoop._start_serving..loop)N)r)rrrrr!Zbacklogr#)rrrr!rrr$_start_servings$z$BaseProactorEventLoop._start_servingcCsdS)Nr#)rZ event_listr#r#r$_process_events sz%BaseProactorEventLoop._process_eventscCs*x|jjD] }|jq W|jjdS)N)rvaluesr6clear)rZfuturer#r#r$r$s z*BaseProactorEventLoop._stop_accept_futurescCs |j|jj||jdS)N)rrY _stop_servingr7)rrr#r#r$r)s z#BaseProactorEventLoop._stop_serving)NNN)N)NN)NN)NN)N)NNr)r(rMrNr rrrrrr7rrrrrrrrrrrrrrPr#r#)r"r$rs4          ()rO__all__rJr9rrrrrr logr Z_FlowControlMixinZ BaseTransportr Z ReadTransportrQZWriteTransportrbrvZ Transportr|r~Z BaseEventLooprr#r#r#r$s2        M T  #__pycache__/selector_events.cpython-36.pyc000064400000071601152343301150014610 0ustar003 \ @s<dZdgZddlZddlZddlZddlZddlZddlZy ddlZWne k r^dZYnXddl m Z ddl m Z ddl m Z ddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddlmZddZGddde jZGdddejejZGdddeZGdddeZGdddeZdS)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)compat) constants)events)futures) selectors) transports)sslproto) coroutine)loggerc Cs6y|j|}Wntk r"dSXt|j|@SdS)NF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.6/asyncio/selector_events.py_test_selector_event s rcsreZdZdZdOfdd ZdPdddddZdQddddd d d Zddddd d d ZdRddZfddZ ddZ ddZ ddZ ddZ ddZddZdSdd ZdTd!d"ZedUd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Zd=d>Z ed?d@Z!dAdBZ"dCdDZ#dEdFZ$dGdHZ%dIdJZ&dKdLZ'dMdNZ(Z)S)VrzJSelector event loop. See events.EventLoop for API specification. NcsFtj|dkrtj}tjd|jj||_|j t j |_ dS)NzUsing selector: %s) super__init__r ZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefWeakValueDictionary _transports)selfr)rrrr1s zBaseSelectorEventLoop.__init__)extraservercCst||||||S)N)_SelectorSocketTransport)r!sockprotocolwaiterr"r#rrr_make_socket_transport;s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer"r#c CsNtjs"|j||||||||dStj||||||} t||| ||d| jS)N)r)r*r"r#)r"r#)r Z_is_sslproto_available_make_legacy_ssl_transportZ SSLProtocolr$Z_app_transport) r!rawsockr& sslcontextr'r)r*r"r#Z ssl_protocolrrr_make_ssl_transport@s   z)BaseSelectorEventLoop._make_ssl_transportc Cst||||||||| S)N)_SelectorSslTransport) r!r,r&r-r'r)r*r"r#rrrr+Os z0BaseSelectorEventLoop._make_legacy_ssl_transportcCst||||||S)N)_SelectorDatagramTransport)r!r%r&addressr'r"rrr_make_datagram_transportYsz.BaseSelectorEventLoop._make_datagram_transportcsL|jrtd|jrdS|jtj|jdk rH|jjd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser)r!)rrrr6^s   zBaseSelectorEventLoop.closecCstdS)N)NotImplementedError)r!rrr _socketpairisz!BaseSelectorEventLoop._socketpaircCsB|j|jj|jjd|_|jjd|_|jd8_dS)Nr)_remove_reader_ssockfilenor6_csock _internal_fds)r!rrrr5ls   z&BaseSelectorEventLoop._close_self_pipecCsN|j\|_|_|jjd|jjd|jd7_|j|jj|jdS)NFr)r8r:r< setblockingr= _add_readerr;_read_from_self)r!rrrrts   z%BaseSelectorEventLoop._make_self_pipecCsdS)Nr)r!datarrr_process_self_data|sz(BaseSelectorEventLoop._process_self_datac CsVxPy |jjd}|sP|j|Wqtk r8wYqtk rLPYqXqWdS)Ni)r:recvrBInterruptedErrorBlockingIOError)r!rArrrr@s z%BaseSelectorEventLoop._read_from_selfc CsJ|j}|dk rFy|jdWn(tk rD|jr@tjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketT)exc_info)r<sendOSError_debugr r)r!Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdcCs |j|j|j|||||dS)N)r?r;_accept_connection)r!protocol_factoryr%r-r#backlogrrr_start_servingsz$BaseSelectorEventLoop._start_servingc Csxt|D]}y0|j\}}|jr2tjd||||jdWntttfk rXdSt k r} z^| j t j t j t j t jfkr|jd| |d|j|j|jtj|j|||||nWYdd} ~ Xq Xd|i} |j||| ||} |j| q WdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionsocketpeername)rangeacceptrJr rr>rErDConnectionAbortedErrorrIerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr9r;Z call_laterrZACCEPT_RETRY_DELAYrP_accept_connection2Z create_task) r!rNr%r-r#rO_connaddrexcr"rVrrrrMs4     z(BaseSelectorEventLoop._accept_connectionc csd}d}yj|}|j}|r6|j||||d||d}n|j|||||d}y|EdHWn|jYnXWn\tk r} z@|jrd| d} |dk r|| d<|dk r|| d<|j| WYdd} ~ XnXdS)NT)r'r)r"r#)r'r"r#z3Error on transport creation for incoming connection)rQrRr& transport) create_futurer.r(r6 ExceptionrJrY) r!rNr\r"r-r#r&r_r'r^contextrrrrZs4 z)BaseSelectorEventLoop._accept_connection2c Cs@y|j|}Wntk r"YnX|jsX|j|j }\}}|jj ||tjB||f|dk r|j dS)N) _check_closedrHandlerrrregisterr EVENT_READrAmodifycancel) r!rcallbackargshandlermaskreaderwriterrrrr?s  z!BaseSelectorEventLoop._add_readerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj ||d|f|dk r|j dSdSdS)NFT) r4rrrrrAr ri unregisterrjrk)r!rrrorprqrrrr9s z$BaseSelectorEventLoop._remove_readerc Gs|jtj|||}y|jj|}Wn*tk rP|jj|tjd|fYn>X|j|j }\}}|jj ||tjB||f|dk r|j dS)N) rfrrgrrrrhr EVENT_WRITErArjrk) r!rrlrmrnrrorprqrrr _add_writers  z!BaseSelectorEventLoop._add_writerc Cs|jr dSy|jj|}Wntk r0dSX|j|j}\}}|tjM}|sb|jj|n|jj |||df|dk r|j dSdSdS)zRemove a writer callback.FNT) r4rrrrrAr rsrrrjrk)r!rrrorprqrrr_remove_writer,s z$BaseSelectorEventLoop._remove_writercGs|j||j||f|S)zAdd a reader callback.)rer?)r!rrlrmrrr add_readerCs z BaseSelectorEventLoop.add_readercCs|j||j|S)zRemove a reader callback.)rer9)r!rrrr remove_readerHs z#BaseSelectorEventLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rert)r!rrlrmrrr add_writerMs z BaseSelectorEventLoop.add_writercCs|j||j|S)zRemove a writer callback.)reru)r!rrrr remove_writerRs z#BaseSelectorEventLoop.remove_writercCs6|jr|jdkrtd|j}|j|d|||S)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. This method is a coroutine. rzthe socket must be non-blockingN)rJ gettimeout ValueErrorr` _sock_recv)r!r%nfutrrr sock_recvWs zBaseSelectorEventLoop.sock_recvcCs|dk r|j||jrdSy|j|}Wn`ttfk rb|j}|j||j||||Yn6tk r}z|j |WYdd}~Xn X|j |dS)N) rw cancelledrCrErDr;rvr|ra set_exception set_result)r!r~ registered_fdr%r}rArr^rrrr|fs z BaseSelectorEventLoop._sock_recvcCsF|jr|jdkrtd|j}|r8|j|d||n |jd|S)aSend 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. This method is a coroutine. rzthe socket must be non-blockingN)rJrzr{r` _sock_sendallr)r!r%rAr~rrr sock_sendall{s  z"BaseSelectorEventLoop.sock_sendallcCs|dk r|j||jrdSy|j|}WnDttfk rHd}Yn*tk rp}z|j|dSd}~XnX|t|kr|jdn.|r||d}|j }|j ||j ||||dS)Nr) ryrrHrErDrarlenrr;rxr)r!r~rr%rAr}r^rrrrrs"     z#BaseSelectorEventLoop._sock_sendallccs|jr|jdkrtdttd s2|jtjkrptj||j|j |d}|j sZ|EdH|j d\}}}}}|j }|j ||||EdHS)zTConnect to a remote socket at address. This method is a coroutine. rzthe socket must be non-blockingAF_UNIX)familyprotoloopN)rJrzr{hasattrrSrrrZ_ensure_resolvedrdoneresultr` _sock_connect)r!r%r1Zresolvedr[r~rrr sock_connects z"BaseSelectorEventLoop.sock_connectcCs|j}y|j|Wnjttfk rV|jtj|j||j||j |||Yn6t k r}z|j |WYdd}~Xn X|j ddS)N) r;ZconnectrErDZadd_done_callback functoolspartial_sock_connect_donerx_sock_connect_cbrarr)r!r~r%r1rr^rrrrsz#BaseSelectorEventLoop._sock_connectcCs|j|dS)N)ry)r!rr~rrrrsz(BaseSelectorEventLoop._sock_connect_donecCs|jr dSy,|jtjtj}|dkr6t|d|fWnBttfk rPYn6tk rz}z|j |WYdd}~Xn X|j ddS)NrzConnect call failed %s) rZ getsockoptrSZ SOL_SOCKETZSO_ERRORrIrErDrarr)r!r~r%r1errr^rrrrsz&BaseSelectorEventLoop._sock_connect_cbcCs4|jr|jdkrtd|j}|j|d||S)a|Accept 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. This method is a coroutine. rzthe socket must be non-blockingF)rJrzr{r` _sock_accept)r!r%r~rrr sock_accepts z!BaseSelectorEventLoop.sock_acceptcCs|j}|r|j||jr"dSy|j\}}|jdWnVttfk rh|j||j|d|Yn:t k r}z|j |WYdd}~XnX|j ||fdS)NFT) r;rwrrVr>rErDrvrrarr)r!r~Z registeredr%rr\r1r^rrrrs  z"BaseSelectorEventLoop._sock_acceptcCsx~|D]v\}}|j|j}\}}|tj@rN|dk rN|jrD|j|n |j||tj@r|dk r|jrr|j|q|j|qWdS)N) fileobjrAr riZ _cancelledr9Z _add_callbackrsru)r!Z event_listrrorrprqrrr_process_eventss   z%BaseSelectorEventLoop._process_eventscCs|j|j|jdS)N)r9r;r6)r!r%rrr _stop_serving sz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)NNrL)NNrL)NN)*r __module__ __qualname____doc__rr(r.r+r2r6r8r5rrBr@rKrPrMr rZrer?r9rtrurvrwrxryrr|rrrrrrrrrr __classcell__rr)rrr+sT      ( #  cseZdZdZeZdZd fdd ZddZdd Z d d Z d d Z ddZ ddZ ejr`ddZd!ddZddZddZddZddZZS)"_SelectorTransportiNc stj||||jd<|j|jd<d|jkrdy|j|jd<Wn tjk rbd|jd<YnX||_|j|_ ||_ d|_ ||_ |j |_d|_d|_|j dk r|j j||j|j <dS)NrSZsocknamerTTrF)rr_extraZ getsocknameZ getpeernamerSerror_sockr;_sock_fd _protocol_protocol_connected_server_buffer_factory_buffer _conn_lost_closingZ_attachr )r!rr%r&r"r#)rrrrs&      z_SelectorTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|j|jdk r|jj rt|jj |jt j }|rz|jdn |jdt|jj |jt j }|rd}nd}|j }|jd||fd d j|S) Nclosedclosingzfd=%sz read=pollingz read=idlepollingZidlezwrite=<%s, bufsize=%s>z<%s> )rrrappendrr_loopr4rrr rirsget_write_buffer_sizejoin)r!inforstatebufsizerrr__repr__2s*       z_SelectorTransport.__repr__cCs|jddS)N) _force_close)r!rrrabortNsz_SelectorTransport.abortcCs ||_dS)N)r)r!r&rrr set_protocolQsz_SelectorTransport.set_protocolcCs|jS)N)r)r!rrr get_protocolTsz_SelectorTransport.get_protocolcCs|jS)N)r)r!rrrrcWsz_SelectorTransport.is_closingcCsT|jr dSd|_|jj|j|jsP|jd7_|jj|j|jj|jddS)NTr) rrr9rrrru call_soon_call_connection_lost)r!rrrr6Zsz_SelectorTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr6)r!rrr__del__hs  z_SelectorTransport.__del__Fatal error on transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)rG)rQrRr_r&) isinstancerZ_FATAL_ERROR_IGNOREr get_debugr rrYrr)r!r^rQrrr _fatal_errorns   z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|jj|jj|j|jsBd|_|jj|j|jd7_|jj|j |dS)NTr) rrclearrrurrr9rr)r!r^rrrr|s z_SelectorTransport._force_closec CsVz|jr|jj|Wd|jjd|_d|_d|_|j}|dk rP|jd|_XdS)N)rrZconnection_lostrr6rrZ_detach)r!r^r#rrrrs z(_SelectorTransport._call_connection_lostcCs t|jS)N)rr)r!rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dS)N)rrr?)r!rrlrmrrrr?sz_SelectorTransport._add_readeri)NN)r)rrrmax_size bytearrayrrrrrrrrcr6rZPY34rrrrrr?rrr)rrrs"   rcsVeZdZdfdd ZddZddZdd Zd d Zd d ZddZ ddZ Z S)r$Ncsrtj|||||d|_d|_tj|j|jj|j j ||jj|j |j |j |dk rn|jjtj|ddS)NF)rr_eof_pausedrZ _set_nodelayrrrrconnection_mader?r _read_readyr_set_result_unless_cancelled)r!rr%r&r'r"r#)rrrrs    z!_SelectorSocketTransport.__init__cCs>|js |jrdSd|_|jj|j|jjr:tjd|dS)NTz%r pauses reading)rrrr9rrr r)r!rrr pause_readings   z&_SelectorSocketTransport.pause_readingcCsB|js|j rdSd|_|j|j|j|jjr>tjd|dS)NFz%r resumes reading) rrr?rrrrr r)r!rrrresume_readings  z'_SelectorSocketTransport.resume_readingcCs|jr dSy|jj|j}WnDttfk r4Yn|tk r`}z|j|dWYdd}~XnPX|rt|jj |n<|j j rt j d||jj}|r|j j|jn|jdS)Nz$Fatal read error on socket transportz%r received EOF)rrrCrrErDrarr data_receivedrrr r eof_receivedr9rr6)r!rAr^ keep_openrrrrs    z$_SelectorSocketTransport._read_readycCst|tttfs"tdt|j|jr0td|s8dS|j rf|j t j krTt j d|j d7_ dS|jsy|jj|}WnBttfk rYn@tk r}z|j|ddSd}~XnX||d}|sdS|jj|j|j|jj||jdS)Nz1data argument must be a bytes-like object, not %rz%Cannot call write() after write_eof()zsocket.send() raised exception.rz%Fatal write error on socket transport)rbytesr memoryview TypeErrortyperrr3rr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrHrErDrarrrtr _write_readyextend_maybe_pause_protocol)r!rAr}r^rrrwrites4     z_SelectorSocketTransport.writecCs|jstd|jrdSy|jj|j}Wn\ttfk rBYntk r}z*|jj |j |jj |j |dWYdd}~XnTX|r|jd|=|j |js|jj |j |jr|jdn|jr|jjtjdS)NzData should not be emptyz%Fatal write error on socket transport)rAssertionErrorrrrHrErDrarrurrr_maybe_resume_protocolrrrshutdownrSSHUT_WR)r!r}r^rrrrs(   z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jjtjdS)NT)rrrrrrSr)r!rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdS)NTr)r!rrr can_write_eof sz&_SelectorSocketTransport.can_write_eof)NNN) rrrrrrrrrrrrrr)rrr$s#r$csdeZdZeZdfdd ZdddZddZd d Zd d Z d dZ ddZ ddZ ddZ ZS)r/NFc stdkrtd|s tj||}|dd} |r<| r<|| d<|j|f| } tj|| ||| d|_||_||_ ||_ d|_ |j j |d|jjrtjd||jj} nd} |j| dS)Nzstdlib ssl module not availableF)r)Zdo_handshake_on_connectr*)r-z%r starts SSL handshake)sslr3r Z_create_transport_contextZ wrap_socketrrr_server_hostname_waiter _sslcontextrrupdaterrr rtime _on_handshake) r!rr,r&r-r'r)r*r"r#Z wrap_kwargsZsslsock start_time)rrrr(s*     z_SelectorSslTransport.__init__cCsD|jdkrdS|jjs:|dk r.|jj|n |jjdd|_dS)N)rrrr)r!r^rrr_wakeup_waiterLs   z$_SelectorSslTransport._wakeup_waiterc"Cs$y|jjWntjk r8|jj|j|j|dStjk r`|jj |j|j|dSt k r}z`|jj rt j d|dd|jj|j|jj|j|jj|j|t|trdSWYdd}~XnX|jj|j|jj|j|jj}t|jds|jr|jjtjkrytj||jWnRtk r}z4|jj rjt j d|dd|jj|j|dSd}~XnX|jj||jj|jj|jdd|_d|_ |jj|j|j!d|_"|jj#|j$j%||jj#|j|jj r |jj&|}t j'd||d dS) Nz%r: SSL handshake failedT)rGZcheck_hostnamez1%r: SSL handshake failed on matching the hostname)peercertcipher compressionZ ssl_objectFz%r: SSL handshake took %.1f msg@@)(rZ do_handshakerSSLWantReadErrorrr?rrSSLWantWriteErrorrt BaseExceptionrr rr9rur6rrraZ getpeercertrrrZ verify_modeZ CERT_NONEZmatch_hostnamerrrr_read_wants_write_write_wants_readrrrrrrr)r!rr^rZdtrrrrVsb                z#_SelectorSslTransport._on_handshakecCsJ|jrtd|jrtdd|_|jj|j|jjrFtjd|dS)Nz#Cannot pause_reading() when closingzAlready pausedTz%r pauses reading) rr3rrr9rrr r)r!rrrrs z#_SelectorSslTransport.pause_readingcCsJ|jstdd|_|jrdS|jj|j|j|jjrFtj d|dS)Nz Not pausedFz%r resumes reading) rr3rrr?rrrr r)r!rrrrs z$_SelectorSslTransport.resume_readingcCs"|jr dS|jr6d|_|j|jr6|jj|j|jy|jj|j }Wnt t t j fk rdYnt jk rd|_|jj|j|jj|j|jYntk r}z|j|dWYdd}~XnTX|r|jj|n@z4|jjrtjd||jj}|rtjdWd|jXdS)NFTz!Fatal read error on SSL transportz%r received EOFz?returning true from eof_received() has no effect when using ssl)rrrrrrtrrrCrrErDrrrrr9rarrrrr rrrr6)r!rAr^rrrrrs4   z!_SelectorSslTransport._read_readycCs(|jr dS|jrszC_SelectorDatagramTransport.get_write_buffer_size..)sumr)r!rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizecCs|jr dSy|jj|j\}}Wnpttfk r8Ynhtk rd}z|jj|WYdd}~Xn<t k r}z|j |dWYdd}~XnX|jj ||dS)Nz&Fatal read error on datagram transport) rrZrecvfromrrErDrIrerror_receivedrarZdatagram_received)r!rAr]r^rrrr sz&_SelectorDatagramTransport._read_readycCsTt|tttfs"tdt|j|s*dS|jrN|d|jfkrNtd|jf|j r|jr|j t j krpt j d|j d7_ dS|js4y&|jr|jj|n|jj||dSttfk r|jj|j|jYnZtk r}z|jj|dSd}~Xn.tk r2}z|j|ddSd}~XnX|jjt||f|jdS)Nz1data argument must be a bytes-like object, not %rz#Invalid address: must be None or %szsocket.send() raised exception.rz'Fatal write error on datagram transport)rrrrrrrrr{rrrr rrrrHsendtorErDrrtr _sendto_readyrIrrrarrr)r!rAr]r^rrrr.s<     z!_SelectorDatagramTransport.sendtocCsx|jr|jj\}}y&|jr,|jj|n|jj||Wqttfk rf|jj||fPYqt k r}z|j j |dSd}~Xqt k r}z|j |ddSd}~XqXqW|j|js|jj|j|jr|jddS)Nz'Fatal write error on datagram transport)rpopleftrrrHrrErD appendleftrIrrrarrrrurrr)r!rAr]r^rrrrUs* z(_SelectorDatagramTransport._sendto_ready)NNN)N) rrr collectionsdequerrrrrrrrr)rrr0 s  'r0) r__all__rrXrrSrrr ImportErrorrrrrrr r r Z coroutinesr logr rZ BaseEventLooprZ_FlowControlMixinZ Transportrr$r/r0rrrrsD             ii__pycache__/windows_utils.cpython-36.pyc000064400000012410152343301150014307 0ustar003 \@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddddd gZ d Z e jZe jZejZeedrejZnejejdfd dZd de dddZGdd d ZGddde jZdS)z* Various Windows specific bits and pieces NZwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd \}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) zA socket pair usable as a self-pipe, for Windows. Origin: https://gist.github.com/4325783, by Geert Jansen. Public domain. z 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedNFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-%d-%d-)prefixrrNT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@s\eZdZdZddZddZeddZdd Ze j d d d Z d dZ ddZ ddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r" __class____name__)r#r$rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r"r )r#rrrfilenos zPipeHandle.fileno)r cCs|jdk r||jd|_dS)N)r")r#r rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r"warningswarnResourceWarningr)r#rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r#rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r#tvtbrrr__exit__szPipeHandle.__exit__N)r( __module__ __qualname____doc__r%r)propertyr$r*rr rr/r0r4rrrrrs cs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|jd st|jdddks$td}}}d} } } |tkrdtd dd\} } tj| tj}n|}|tkrtd d\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy t j |f|||d|Wn8x(| | | fD]}|dk rt j |qWYn>X| dk r6t | |_| dk rJt | |_| dk r^t | |_Wd|tkrvtj||tkrtj||tkrtj|XdS) NZuniversal_newlinesrrFT)rr)r)stdinstdoutstderr)FT)TF)TF)getAssertionErrorrrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr%rr rr9r:r;r)r#argsr9r:r;kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r'rrr%sL             zPopen.__init__)NNN)r(r5r6r7r% __classcell__rr)r'rrs)TT)r7sysplatform ImportErrorr itertoolsr>rr subprocessrr,__all__ZBUFSIZErr@countrhasattrrr r rrrrrrrs,  .0-__pycache__/protocols.cpython-36.opt-2.pyc000064400000004256152343301150014372 0ustar003 \@sNddddgZGdddZGdddeZGdddeZGdddeZdS) BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s,eZdZddZddZddZddZd S) rcCsdS)N)selfZ transportrr)/usr/lib64/python3.6/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname__rr r r rrrrrs c@seZdZddZddZdS)rcCsdS)Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrr>sc@seZdZddZddZdS)rcCsdS)Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrgsc@s$eZdZddZddZddZdS)rcCsdS)Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrtsN)__all__rrrrrrrrs 7) __pycache__/test_utils.cpython-36.opt-1.pyc000064400000042155152343301150014544 0ustar003 \: @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrHddl%m&Z&n ddlm&Z&ddZ'e'dZ(e'dZ)ddZ*ddZ+dRddZ,ddZ-Gdd d eZ.Gd!d"d"eZ/Gd#d$d$Z0Gd%d&d&e0e/Z1d'd(d)d*Z2e3ed+rZGd,d-d-ej4eZ5Gd.d/d/e5eZ6Gd0d1d1e6Z7Gd2d3d3e0e7Z8d4d5Z9ej:d6d7Z;ej:d'd(d8d9Zd?Z>Gd@dAdAej?Z@GdBdCdCejAZBdDdEZCGdFdGdGeDZEdHdIZFGdJdKdKe jGZGej:dLdMZHejIejJejKfdNdOZLdPdQZMdS)SzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportZwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer*/usr/lib64/python3.6/asyncio/test_utils.py data_file-s   rz ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr"c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr#gentrrr run_brieflyCs  r)cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r&)timer TimeoutErrorr$r Zsleep)r&ZpredtimeoutZdeadlinerrr run_untilRs  r.cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)r&rrrrun_once\s r0c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r5r8rrrrr1gsr1cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r4request client_addr) __class__rrr?ts zSilentWSGIServer.get_requestcCsdS)Nr)r4rBclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF __classcell__rr)rDrr<ps r<c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr r!Zload_cert_chainZ wrap_socketZRequestHandlerClassr%OSError)r4rBrEZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@s eZdZdS) SSLWSGIServerN)r9r:r;rrrrrNsrNF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rPrQr)environZstart_responseZstatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r1Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rWrO server_clsserver_ssl_clsrSZ server_classZ server_threadr)rTr_run_test_servers    r]ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r4rrrrbs zUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^sr^cs(eZdZdZddZfddZZS)UnixWSGIServerr=cCstj||jdS)N)r^rbZ setup_environ)r4rrrrbs zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rdre)r>r?r@rA)r4rBrC)rDrrr?s zUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrcsrcc@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrFsz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrfsrfc@s eZdZdS)UnixSSLWSGIServerN)r9r:r;rrrrrgsrgc Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rkccs<t}z |VWdytj|Wntk r4YnXXdS)N)rkrunlinkrK)rrrrunix_socket_paths rmc cs,t}t||ttdEdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrrrun_test_unix_serversrnz 127.0.0.1)hostportrOccst||f|ttdEdHdS)N)rWrOr[r\)r]r<rN)rorprOrrrrun_test_servers rqcCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrirrrmake_test_protocols r{c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r4rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr})r4fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)r}pop)r4rrrr unregister szTestSelector.unregistercCsgS)Nr)r4r-rrrselectszTestSelector.selectcCs|jS)N)r})r4rrrget_mapszTestSelector.get_map)N)r9r:r;r~rrrrrrrrr|s  r|cseZdZdZd-fdd ZddZddZfd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zfd%d&Zfd'd(Zd)d*Zd+d,ZZS).TestLoopaLoop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. Ncsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr',szTestLoop.__init__..genFTrg& .>)r>r~_check_on_close_gennext_timeZ_clock_resolution_timersr|Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r4r')rDrrr~(s  zTestLoop.__init__cCs|jS)N)r)r4rrrr+?sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r4advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r>r%rrsend StopIterationAssertionError)r4)rDrrr%Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r4fdcallbackr7rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r4rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rrZ _callbackZ_args)r4rrr7handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r4rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r4rrr7rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r4rrrr_remove_writerns  zTestLoop._remove_writercGs|j|}dS)N)r)r4rrr7rrrr assert_writervs zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr6)r4rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)zAdd a reader callback.)rr)r4rrr7rrr add_readers zTestLoop.add_readercCs|j||j|S)zRemove a reader callback.)rr)r4rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rr)r4rrr7rrr add_writers zTestLoop.add_writercCs|j||j|S)zRemove a writer callback.)rr)r4rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r4rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r> _run_oncerrrr)r4whenr)rDrrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr>call_at)r4rrr7)rDrrrs zTestLoop.call_atcCsdS)Nr)r4Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r4rrr_write_to_selfszTestLoop._write_to_self)N)r9r:r;__doc__r~r+rr%rrrrrrrrrrrrrrrrrrGrr)rDrrs,     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrwsrwc@seZdZdZddZdS) MockPatternzA regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) cCsttjt||tjS)N)boolresearchstrS)r4otherrrr__eq__szMockPattern.__eq__N)r9r:r;rrrrrrrsrcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorrZr%)r&Zexecutorrrr close_loops zTestCase.close_loopT)cleanupcCs tjd|r|j|j|dS)N)r set_event_loopZ addCleanupr)r4r&rrrrrs zTestCase.set_event_loopNcCst|}|j||S)N)rr)r4r'r&rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r4rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrUsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r4rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r4rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r4rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r4excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r9r:r;rrrrrrEmptyCMsrr)r4r7rrrrrsubTestszTestCase.subTest)N) r9r:r; staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorxfamilyZ gettimeoutrs)rrxrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrrforce_legacy_ssl_supportsr)r*)Nrr contextlibr2rrrrr`rrhrXr+ZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrerrr r r r Z coroutinesr logrrrplatformZ windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrkcontextmanagerrmrnrqr{Z BaseSelectorr|Z BaseEventLooprrwrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 __pycache__/locks.cpython-36.opt-2.pyc000064400000021320152343301150013450 0ustar003 \<@sdddddgZddlZddlmZdd lmZdd lmZdd lmZGd d d ZGdddZ Gddde Z GdddZ Gddde Z Gddde Z Gddde ZdS)LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s$eZdZddZddZddZdS)_ContextManagercCs ||_dS)N)_lock)selflockr%/usr/lib64/python3.6/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname__rrrrrrrr sr c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rrr#rrrrr+s  rcsNeZdZddddZfddZddZed d Zd d Zd dZ Z S)rN)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr$rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r(r'formatlen)rresextra) __class__rrr/s  z Lock.__repr__cCs|jS)N)r()rrrrr+sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)Ncss|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..T) r(allr'r) create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)NFzLock is not acquired.)r(r>r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)NT)nextiterr' StopIterationdone set_result)rr?rrrr>s zLock._wake_up_first) rrrrr/r+r rrr> __classcell__rr)r4rrYs 6  csNeZdZddddZfddZddZd d Zd d Zed dZ Z S)rN)r$cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r%r&r'_valuer)r r*)rr$rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr-)r.r/rFr'r0r1)rr2r3)r4rrr/s  zEvent.__repr__cCs|jS)N)rF)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)NT)rFr'rCrD)rr?rrrrGs  z Event.setcCs d|_dS)NF)rF)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)NT)rFr)r:r'r;r<)rr?rrrwait s   z Event.wait) rrrrr/rHrGrIr rJrErr)r4rrs    csVeZdZdddddZfddZeddZed d Zdd d ZddZ Z S)rN)r$cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r$z"loop argument must agree with lock) r)r r*r ValueErrorr r+rrr%r&r')rrr$rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr+r,z {},waiters:{}z <{} [{}]>rr-)r.r/r+r'r0r1)rr2r3)r4rrr/>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)Nzcannot wait on un-acquired lockTF) r+rrr)r:r'r;r<rr r=)rr?r5rrrrJEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)N)rJ)rZ predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)Nz!cannot notify on un-acquired lockrrF)r+rr'rCrD)rnidxr?rrrnotifyys  zCondition.notifycCs|jt|jdS)N)rPr1r')rrrr notify_allszCondition.notify_all)N)r) rrrrr/r rJrMrPrQrErr)r4rr!s    &  csPeZdZdddddZfddZdd Zd d Zed d ZddZ Z S)rrN)r$cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rKrFr%r&r'r)r r*)rvaluer$rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr+zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr-)r.r/r+r0rFr'r1)rr2r3)r4rrr/s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r'popleftrCrD)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)Nr)rF)rrrrr+szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)NrrT)rFr)r:r'r;Zcancelr5rT)rr?rrrrs    zSemaphore.acquirecCs|jd7_|jdS)Nr)rFrT)rrrrrszSemaphore.release)r) rrrrr/rTr+r rrrErr)r4rrs   cs0eZdZdddfdd ZfddZZS) rrN)r$cs||_tj||ddS)N)r$) _bound_valuer.r)rrRr$)r4rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rFrUrKr.r)r)r4rrrs zBoundedSemaphore.release)r)rrrrrrErr)r4rrs)__all__r%rr r Z coroutinesr r rrrrrrrrrrs    .ByM__pycache__/futures.cpython-36.pyc000064400000032665152343301150013110 0ustar003 \> @s dZddddddgZddlZddlZddlZddlZd d lmZd d lm Z d d lm Z ej Z ej Z ej Z ejZejZejZejZejd ZGd ddZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s4eZdZdZdZddZdd Zd d Zd d ZdS)_TracebackLoggera Helper to log a traceback upon destruction if not cleared. This solves a nasty problem with Futures and Tasks that have an exception set: if nobody asks for the exception, the exception is never logged. This violates the Zen of Python: 'Errors should never pass silently. Unless explicitly silenced.' However, we don't want to log the exception as soon as set_exception() is called: if the calling code is written properly, it will get the exception and handle it properly. But we *do* want to log it if result() or exception() was never called -- otherwise developers waste a lot of time wondering why their buggy code fails silently. An earlier attempt added a __del__() method to the Future class itself, but this backfired because the presence of __del__() prevents garbage collection from breaking cycles. A way out of this catch-22 is to avoid having a __del__() method on the Future class itself, but instead to have a reference to a helper object with a __del__() method that logs the traceback, where we ensure that the helper object doesn't participate in cycles, and only the Future has a reference to it. The helper object is added when set_exception() is called. When the Future is collected, and the helper is present, the helper object is also collected, and its __del__() method will log the traceback. When the Future's result() or exception() method is called (and a helper object is present), it removes the helper object, after calling its clear() method to prevent it from logging. One downside is that we do a fair amount of work to extract the traceback from the exception, even when it is never logged. It would seem cheaper to just store the exception object, but that references the traceback, which references stack frames, which may reference the Future, which references the _TracebackLogger, and then the _TracebackLogger would be included in a cycle, which is what we're trying to avoid! As an optimization, we don't immediately format the exception; we only do the work when activate() is called, which call is delayed until after all the Future's callbacks have run. Since usually a Future has at least one callback (typically set by 'yield from') and usually that callback extracts the callback, thereby removing the need to format the exception. PS. I don't claim credit for this solution. I first heard of it in a discussion about closing files when they are collected. loopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr'/usr/lib64/python3.6/asyncio/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr) __name__ __module__ __qualname____doc__ __slots__rrrr&rrrrr s 0r c@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZejrRd d Zd d Zd dZddZddZddZddZddZddZddZddZdd ZejreZ dS)!ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r5_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. N)r-r call_soon)rZ callbackscallbackrrrr;s  zFuture._schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r8r:)rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r8r9)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN)r8r:r _FINISHEDrr5r6_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r8r:rrArr5r6)rrrrr4s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. N)r8r9rr=r-append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. csg|]}|kr|qSrr).0f)rErr sz/Future.remove_done_callback..N)r-len)rrEZfiltered_callbacksZ removed_countr)rErremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}N)r8r9rformatrBrAr;)rrCrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. z{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureTN)r8r9rrL isinstancetype StopIteration TypeErrorr6rAr;r PY34r5r Z _tb_loggerrr=r)rr4rrr set_exception,s    zFuture.set_exceptionccs,|jsd|_|V|js$td|jS)NTz"yield from wasn't used with future)r@_asyncio_future_blockingAssertionErrorrC)rrrr__iter__Ds zFuture.__iter__)!r'r(r)r*r9r8rBr6rrrTr5rr Z_future_repr_infor2r3r rRr&r<r;r?r@rCr4rFrKrMrSrVZPY35 __await__rrrrrns4   cCs|jr dS|j|dS)z?Helper setting the result only if the future was not cancelled.N)r?rM)ZfutrCrrr_set_result_unless_cancelledSsrXcCsZ|js t|jr|j|js(dS|j}|dk rD|j|n|j}|j|dS)z8Copy state from a future to a concurrent.futures.Future.N) r@rUr?r<Zset_running_or_notify_cancelr4rSrCrM) concurrentsourcer4rCrrr_set_concurrent_future_stateZs  r[cCsj|js t|jrdS|j s&t|jr8|jn.|j}|dk rT|j|n|j}|j|dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r@rUr?r<r4rSrCrM)rZdestr4rCrrr_copy_future_stateis   r]cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd }j|j|dS) aChain two futures so that when one completes, so does the other. The result (or exception) of source will be copied to destination. If destination is cancelled, source gets cancelled too. Compatible with both asyncio.Future and concurrent.futures.Future. z(A future is required for source argumentz-A future is required for destination argumentNcSs"t|rt||n t||dS)N)rr]r[)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r?r<call_soon_threadsafe) destination) dest_looprZ source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r?Z is_closedr`)rZ)r_rbrarcrr_call_set_states  z&_chain_future.._call_set_state)rrNrYfuturesrrQrrF)rZrardrer)r_rbrarZrcr _chain_future}s   rg)r cCsNt|r |St|tjjs(tdj||dkr8tj}|j }t |||S)z&Wrap concurrent.futures.Future object.z/concurrent.futures.Future is expected, got {!r}N) rrNrYrfrrUrLr r,Z create_futurerg)rr Z new_futurerrrrs  )r*__all__Zconcurrent.futuresrYZloggingr/rrr r r rrrrr9r:rADEBUGZ STACK_DEBUGr rZ _PyFuturerXr[r]rgrZ_asyncio ImportErrorZ_CFuturerrrrs>     Pc*  __pycache__/test_utils.cpython-36.pyc000064400000042423152343301150013603 0ustar003 \: @sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddl m!Z!ddl"m#Z#e j$dkrHddl%m&Z&n ddlm&Z&ddZ'e'dZ(e'dZ)ddZ*ddZ+dRddZ,ddZ-Gdd d eZ.Gd!d"d"eZ/Gd#d$d$Z0Gd%d&d&e0e/Z1d'd(d)d*Z2e3ed+rZGd,d-d-ej4eZ5Gd.d/d/e5eZ6Gd0d1d1e6Z7Gd2d3d3e0e7Z8d4d5Z9ej:d6d7Z;ej:d'd(d8d9Zd?Z>Gd@dAdAej?Z@GdBdCdCejAZBdDdEZCGdFdGdGeDZEdHdIZFGdJdKdKe jGZGej:dLdMZHejIejJejKfdNdOZLdPdQZMdS)SzUtilities shared by tests.N)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportZwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer*/usr/lib64/python3.6/asyncio/test_utils.py data_file-s   rz ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr"c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr#gentrrr run_brieflyCs  r)cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r&)timer TimeoutErrorr$r Zsleep)r&ZpredtimeoutZdeadlinerrr run_untilRs  r.cCs|j|j|jdS)zLegacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. N)Z call_soonstopZ run_forever)r&rrrrun_once\s r0c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r5r8rrrrr1gsr1cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r4request client_addr) __class__rrr?ts zSilentWSGIServer.get_requestcCsdS)Nr)r4rBclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF __classcell__rr)rDrr<ps r<c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr r!Zload_cert_chainZ wrap_socketZRequestHandlerClassr%OSError)r4rBrEZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@s eZdZdS) SSLWSGIServerN)r9r:r;rrrrrNsrNF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rPrQr)environZstart_responseZstatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r1Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rWrO server_clsserver_ssl_clsrSZ server_classZ server_threadr)rTr_run_test_servers    r]ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r4rrrrbs zUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^sr^cs(eZdZdZddZfddZZS)UnixWSGIServerr=cCstj||jdS)N)r^rbZ setup_environ)r4rrrrbs zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rdre)r>r?r@rA)r4rBrC)rDrrr?s zUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrcsrcc@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrFsz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrfsrfc@s eZdZdS)UnixSSLWSGIServerN)r9r:r;rrrrrgsrgc Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rkccs<t}z |VWdytj|Wntk r4YnXXdS)N)rkrunlinkrK)rrrrunix_socket_paths rmc cs,t}t||ttdEdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrrrun_test_unix_serversrnz 127.0.0.1)hostportrOccst||f|ttdEdHdS)N)rWrOr[r\)r]r<rN)rorprOrrrrun_test_servers rqcCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrirrrmake_test_protocols r{c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r4rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr})r4fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)r}pop)r4rrrr unregister szTestSelector.unregistercCsgS)Nr)r4r-rrrselectszTestSelector.selectcCs|jS)N)r})r4rrrget_mapszTestSelector.get_map)N)r9r:r;r~rrrrrrrrr|s  r|cseZdZdZd-fdd ZddZddZfd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zfd%d&Zfd'd(Zd)d*Zd+d,ZZS).TestLoopaLoop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. Ncsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr',szTestLoop.__init__..genFTrg& .>)r>r~_check_on_close_gennext_timeZ_clock_resolution_timersr|Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r4r')rDrrr~(s  zTestLoop.__init__cCs|jS)N)r)r4rrrr+?sz TestLoop.timecCs|r|j|7_dS)zMove test time forward.N)r)r4advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r>r%rrsend StopIterationAssertionError)r4)rDrrr%Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r4fdcallbackr7rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r4rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rr _callback_args)r4rrr7handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r4rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r4rrr7rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r4rrrr_remove_writerns  zTestLoop._remove_writercGs^||jkstdj||j|}|j|ks>tdj|j||j|ksZtdj|j|dS)Nzfd {} is not registeredz {!r} != {!r})rrr6rr)r4rrr7rrrr assert_writervs   zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr6)r4rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)zAdd a reader callback.)rr)r4rrr7rrr add_readers zTestLoop.add_readercCs|j||j|S)zRemove a reader callback.)rr)r4rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)zAdd a writer callback..)rr)r4rrr7rrr add_writers zTestLoop.add_writercCs|j||j|S)zRemove a writer callback.)rr)r4rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r4rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r> _run_oncerrrr)r4whenr)rDrrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr>call_at)r4rrr7)rDrrrs zTestLoop.call_atcCsdS)Nr)r4Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r4rrr_write_to_selfszTestLoop._write_to_self)N)r9r:r;__doc__r~r+rr%rrrrrrrrrrrrrrrrrrGrr)rDrrs,     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrwsrwc@seZdZdZddZdS) MockPatternzA regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) cCsttjt||tjS)N)boolresearchstrS)r4otherrrr__eq__szMockPattern.__eq__N)r9r:r;rrrrrrrsrcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorrZr%)r&Zexecutorrrr close_loops zTestCase.close_loopT)cleanupcCs,|dk s ttjd|r(|j|j|dS)N)rr set_event_loopZ addCleanupr)r4r&rrrrrs  zTestCase.set_event_loopNcCst|}|j||S)N)rr)r4r'r&rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r4rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrUsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r4rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r4rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r4rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r4excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r9r:r;rrrrrrEmptyCMsrr)r4r7rrrrrsubTestszTestCase.subTest)N) r9r:r; staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)zrContext manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. rN)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)z'Create a mock of a non-blocking socket.g)rZ MagicMocksocketprotorxfamilyZ gettimeoutrs)rrxrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrrforce_legacy_ssl_supportsr)r*)Nrr contextlibr2rrrrr`rrhrXr+ZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrerrr r r r Z coroutinesr logrrrplatformZ windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrkcontextmanagerrmrnrqr{Z BaseSelectorr|Z BaseEventLooprrwrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 __pycache__/queues.cpython-36.opt-2.pyc000064400000012647152343301150013660 0ustar003 \@sdddddgZddlZddlZddlmZdd lmZdd lmZdd lmZGd dde Z Gd dde Z GdddZ Gddde Z Gddde Zejse ZejddS)Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)compat)events)locks) coroutinec@s eZdZdS)rN)__name__ __module__ __qualname__rr&/usr/lib64/python3.6/asyncio/queues.pyrsc@s eZdZdS)rN)r r rrrrrrsc@seZdZd(ddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ e ddZ ddZddZeddZddZed d!Zd"d#Zd$d%Zed&d'ZdS))rrN)loopcCsb|dkrtj|_n||_||_tj|_tj|_d|_t j |jd|_ |j j |j |dS)Nr)r)r Zget_event_loop_loop_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__(s    zQueue.__init__cCstj|_dS)N)rr_queue)rrrrrr:sz Queue._initcCs |jjS)N)rpopleft)rrrr_get=sz Queue._getcCs|jj|dS)N)rappend)ritemrrr_put@sz Queue._putcCs*x$|r$|j}|js|jdPqWdS)N)r doneZ set_result)rwaitersZwaiterrrr _wakeup_nextEs  zQueue._wakeup_nextcCsdjt|jt||jS)Nz<{} at {:#x} {}>)formattyper id_format)rrrr__repr__MszQueue.__repr__cCsdjt|j|jS)Nz<{} {}>)r(r)r r+)rrrr__str__Qsz Queue.__str__cCszdj|j}t|ddr,|djt|j7}|jrF|djt|j7}|jr`|djt|j7}|jrv|dj|j7}|S)Nz maxsize={!r}rz _queue={!r}z _getters[{}]z _putters[{}]z tasks={}) r(rgetattrlistrrlenrr)rresultrrrr+Ts  z Queue._formatcCs t|jS)N)r0r)rrrrqsize`sz Queue.qsizecCs|jS)N)r)rrrrrdsz Queue.maxsizecCs|j S)N)r)rrrremptyisz Queue.emptycCs |jdkrdS|j|jkSdS)NrF)rr2)rrrrfullms z Queue.fullc cstxh|jrh|jj}|jj|y|EdHWq|j|j r^|j r^|j|jYqXqW|j|S)N) r4r create_futurerr"cancel cancelledr' put_nowait)rr#Zputterrrrputxs     z Queue.putcCs>|jr t|j||jd7_|jj|j|jdS)Nr)r4rr$rrclearr'r)rr#rrrr8s   zQueue.put_nowaitccsx|jr|jj}|jj|y|EdHWq|jy|jj|Wntk rbYnX|j r|j r|j |jYqXqW|j S)N) r3rr5rr"r6remove ValueErrorr7r' get_nowait)rgetterrrrgets     z Queue.getcCs$|jr t|j}|j|j|S)N)r3rr!r'r)rr#rrrr=s  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jjdS)Nrz!task_done() called too many timesr)rr<rr)rrrr task_dones   zQueue.task_doneccs|jdkr|jjEdHdS)Nr)rrwait)rrrrjoins z Queue.join)r)r r rrrr!r$r'r,r-r+r2propertyrr3r4r r9r8r?r=r@rBrrrrrs$      c@s0eZdZddZejfddZejfddZdS)rcCs g|_dS)N)r)rrrrrrszPriorityQueue._initcCs||j|dS)N)r)rr#heappushrrrr$szPriorityQueue._putcCs ||jS)N)r)rheappoprrrr!szPriorityQueue._getN) r r rrheapqrDr$rEr!rrrrrsc@s$eZdZddZddZddZdS)rcCs g|_dS)N)r)rrrrrrszLifoQueue._initcCs|jj|dS)N)rr")rr#rrrr$szLifoQueue._putcCs |jjS)N)rpop)rrrrr!szLifoQueue._getN)r r rrr$r!rrrrrs JoinableQueue)__all__rrFrr r Z coroutinesr ExceptionrrrrrZPY35rHr"rrrrs    H __pycache__/log.cpython-36.opt-2.pyc000064400000000265152343301150013123 0ustar003 \|@sddlZejeZdS)N)ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.6/asyncio/log.pys__pycache__/base_tasks.cpython-36.opt-2.pyc000064400000003507152343301150014463 0ustar003 \@sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsTtj|}|jrd|d<tj|j}|jdd||jdk rP|jdd|j|S)NZ cancellingrrz coro=<%s>z wait_for=%r)rZ_future_repr_infoZ _must_cancelrZ_format_coroutine_coroinsertZ _fut_waiter)taskinfocoror */usr/lib64/python3.6/asyncio/base_tasks.py_task_repr_infos   r c Csg}y |jj}Wntk r,|jj}YnX|dk rxx6|dk rl|dk rZ|dkrRP|d8}|j||j}q8W|jnL|jdk r|jj}x8|dk r|dk r|dkrP|d8}|j|j |j }qW|S)Nrr) rcr_frameAttributeErrorgi_frameappendf_backreverse _exception __traceback__tb_frametb_next)rlimitZframesftbr r r _task_get_stacks0         rc Csg}t}xj|j|dD]Z}|j}|j}|j}|j} ||krP|j|tj|tj |||j } |j ||| | fqW|j } |st d||dn*| dk rt d||dnt d||dtj||d| dk rx$tj| j| D]} t | |ddqWdS)N)rzNo stack for %r)filez)Traceback for %r (most recent call last):z%Stack for %r (most recent call last):)rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) rrrextracted_listZcheckedrlinenocofilenamenamelineexcr r r _task_print_stack3s0   r5)r%r*rrrr rr5r r r r s   __pycache__/constants.cpython-36.opt-2.pyc000064400000000342152343301150014352 0ustar003 \s@sdZdZdZdS) N)Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr)/usr/lib64/python3.6/asyncio/constants.pys__pycache__/transports.cpython-36.opt-2.pyc000064400000014417152343301150014565 0ustar003 \R'@sddlmZddddddgZGdddZGd ddeZGd ddeZGd ddeeZGd ddeZGd ddeZGdddeZ dS))compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@s@eZdZdddZdddZddZdd Zd d Zd d ZdS)rNcCs|dkr i}||_dS)N)_extra)selfextrar */usr/lib64/python3.6/asyncio/transports.py__init__ szBaseTransport.__init__cCs|jj||S)N)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)N)r)r r r r closeszBaseTransport.closecCstdS)N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname__rrrrrrr r r r r s    c@seZdZddZddZdS)rcCstdS)N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrr r r r r-sc@sFeZdZdddZddZddZdd Zd d Zd d ZddZ dS)rNcCstdS)N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)N)rZflatten_list_bytesr#)r Z list_of_datar"r r r writelineses zWriteTransport.writelinescCstdS)N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)N)r)r r r r abort{szWriteTransport.abort)NN) rrrr r!r#r$r%r&r'r r r r rAs   c@s eZdZdS)rN)rrrr r r r rsc@seZdZdddZddZdS)rNcCstdS)N)r)r r"Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)N)r)r r r r r'szDatagramTransport.abort)N)rrrr(r'r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)N)r)r r r r kills zSubprocessTransport.killN) rrrr)r*r,r.r/r0r r r r rs csReZdZdfdd ZddZddZdd Zdd d Zdd d ZddZ Z S)_FlowControlMixinNcs$tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r! _high_waterr4 _protocolZ pause_writing Exceptionr3call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r7r8r9r)r4r! _low_waterr;Zresume_writingr<r3r=)r r?r r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rAr:)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr:rA)r rrr r r r5s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr)r5r@)r rrr r r r -sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r!1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrr@rBrCr5r r! __classcell__r r )r6r r1s  r1N) Zasyncior__all__rrrrrrr1r r r r s  #D4__pycache__/tasks.cpython-36.opt-1.pyc000064400000044745152343301150013501 0ustar003 \a @sdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ddl mZGddde jZeZy ddlZWnek rYn XejZZej jZej jZej jZeddedddZddZeddddZeddZddd d!dZed/ddd"dZddd#d$Zeed <d e_ [ddd%d Z!ed&d'Z"Gd(d)d)e jZ#dd*d+d,d Z$ddd-d Z%d.d Z&dS)0z0Support for tasks, coroutines and the scheduler.TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZdZejZiZdZe dddZ e dddZ ddfd d Z e jrXd d Zd dZddddZdddddZddZdfdd ZddZZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj}|jj|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. N)rget_event_loop_current_tasksget)clsloopr%/usr/lib64/python3.6/asyncio/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsNtj|d|jr|jd=||_d|_d|_|jj|j|j j j |dS)N)rrF) super__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r-rrr&Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr'rZcall_exception_handlerFuture__del__)r/contextrrrr5Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r/rrr _repr_info^szTask._repr_info)limitcCs tj||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)r/r8rrr get_stackaszTask.get_stack)r8filecCstj|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)r/r8r:rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner)cancelr*)r/rrrr=s  z Task.cancelcsf|jr t|tjstj}d|_|j}d|_||jj|j<zy"|dkrT|j d}n |j |}Wnt k r}z.|jrd|_|j tjn |j |jWYdd}~Xntjk rtjYn|tk r}z|j |WYdd}~XnPtk r(}z|j |WYdd}~Xn Xt|dd}|dk r|j|jk rl|jj|jtdj||n||r||kr|jj|jtdj|n2d|_|j|j||_|jr|jjrd|_n|jj|jtdj||n^|dkr|jj|jnDtj|r.|jj|jtdj||n|jj|jtdj|Wd|jjj|jd}XdS)NF_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r})r* isinstancerCancelledErrorr(r)r-rrsendthrow StopIteration set_exception set_resultvaluer%r= Exception BaseExceptiongetattrr+r, RuntimeErrorformatr>add_done_callback_wakeupinspectZ isgeneratorpop)r/excr0resultZblocking)r-rrr,s~           z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rQrGr,)r/futurerPrrrrMs  z Task._wakeup)N)N)N)__name__ __module__ __qualname____doc__weakrefWeakSetr"rr3 classmethodrr#r&rZPY34r5r7r9r;r=r,rM __classcell__rr)r-rrs"     !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)aWait for the Futures and coroutines given by fs to complete. The sequence futures must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = yield from asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturer iscoroutine TypeErrortyperS ValueErrorrrrrKrrset_wait)fsrr[r\r)rrrscGs|js|jddS)N)r<rE)waiterargsrrr_release_waiter<srh)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. N)r)rr create_future call_laterrh functoolspartialr rLrr@remove_done_callbackr=r<rQ TimeoutError)futr[rrftimeout_handlecbrrrrAs,       c #s|jd|dk r"|j|tt|fdd}x|D]}|j|qBWzEdHWddk rtjXtt}}x4|D],}|j||jr|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr=r<rE)r])counterr\rprfrr_on_completion|s z_wait.._on_completion) rirjrhlenrLr=rcrmr<r.)rer[r\rrur]r<pendingr)rtr\rprfrrdos&     rd)rr[c#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcsh|]}t|dqS))r)r )rr])rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)rm put_nowaitclear)r])rur<todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)removeryr=)r])r<rpr{rrrus   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrnrQ)r])r<rr _wait_for_onesz#as_completed.._wait_for_one)rr^rr_r`rarSrrrcZqueuesrxrrLrjrangerv)rerr[rxr|r~r]_r)rur<rrpr{rrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrirrjrZ_set_result_unless_cancelledr=)ZdelayrQrrRhrrrrs cCstjdtddt||dS)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rr^rrbrr_rrZ create_taskr'rZPY35rNZ isawaitabler _wrap_awaitabler`)rrr1rrrr s   ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. N)rcstj|d||_d|_dS)N)rF)r%r& _children_cancel_requested)r/childrenr)r-rrr&$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r<rr=r)r/ZretZchildrrrr=)s z_GatheringFuture.cancel)rSrTrUrVr&r=rZrr)r-rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd }x&t |D]\}}|jtj||qWS) a7Return a future aggregating results from the given coroutines or futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r<rrrsrr@rDZ _exceptionZ_resultrrE)irores) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrirErcrr^r rr3rbrvr enumeraterLrkrl)rrZcoros_or_futuresrrorrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None )rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rrrsr=rDrErQ)innerrP)rrrrs  zshield.._done_callback)r r<rrirL)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rGZset_running_or_notify_cancelrD)rP)r0rRrrrcallbacks  z*run_coroutine_threadsafe..callback)rr_r` concurrentrr4Zcall_soon_threadsafe)r0rrr)r0rRrrr s    )N)'rV__all__Zconcurrent.futuresrrkrNrrWrrrrrrr4rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrhrrdrrrglobalsrSr rrr r r rrrrsZ        s  - -8  W5__pycache__/windows_events.cpython-36.pyc000064400000051770152343301150014467 0ustar003 \l@sdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZdd lmZddddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdd d e Z!Gd!d"d"e j"Z#Gd#dde j$Z%Gd$ddZ&Gd%d&d&e j'Z(e#Z)Gd'd(d(ej*Z+e+Z,dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. N)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rrr-r'r.r/ __classcell__rr)rrr's   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.N)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr7Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr7r=r8)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r9r8r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r@)rr;r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rCrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rCrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rCrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3r4rr=rr@rCr'r.r/r5rr)rrr6Ws   r6csFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. N)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr;r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rE)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rE)rr$)rrrr.s  z_WaitCancelFuture.set_exception) r1r2r3r4rr'r/r.r5rr)rrrDs  rDcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr:r;proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rJr< CloseHandlerKrI _unregisterrrr@)rr?)rrrr@s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r9r8r ZUnregisterWaitExrJr(rArBrr)r*rI _wait_cancelr@rK)rr;r+r,rrrrCs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr@rCr5rr)rrrHs rHc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rUrW)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr<ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperQZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerTadd)rfirstflagshpiperrrrWs      zPipeServer._server_pipe_handlecCs |jdkS)N)rQ)rrrrrZszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rVr'rQrTcloserUclear)rrarrrrbs     zPipeServer.closeN) r1r2r3r4rrYrWrZrb__del__rrrrrPs  rPc@seZdZdZddZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.cCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3r4rgrrrrre(srecsPeZdZdZd fdd ZddZeddZed d Zedd d Z Z S)rz2Windows version of proactor event loop using IOCP.Ncs|dkrt}tj|dS)N)rrr)rrL)rrrr2szProactorEventLoop.__init__cCstjS)N)r rf)rrrrrg7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rI connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fraprotocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrh)rirzPipe accept failed)r#r$razAccept pipe failed on pipe %rT)exc_infor)r0rTdiscardrZrbrkrYrI accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrVadd_done_callback)rmrarnr+)r loop_accept_piperlrserverrrrwGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rPZ call_soon)rrlr r)r rwrlrrxrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterri) create_future_WindowsSubprocessTransport ExceptionrbZ_wait)rrnargsshellstdinstdoutstderrbufsizerikwargsrzZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3r4rrgr rpryrr5rr)rrr/s /c@seZdZdZd1ddZddZddZd2d d Zd d Zd3ddZ d4ddZ ddZ ddZ ddZ eddZd5ddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd6d)d*Zd+d,Zd-d.Zd/d0Zd S)7rz#Proactor implementation using IOCP.cCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUEr[_iocp_cacherRrSr9 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr=)rtimeoutrXrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)r{r/)rvaluer?rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(rAr ERROR_NETNAME_DELETEDConnectionResetErrorr~)rokeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr Overlappedr[ isinstancesocketZWSARecvrtZReadFileBrokenPipeErrorr _register)rconnnbytesr_rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(rAr rrr~)rorrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rr[rrZWSASendrtZ WriteFiler)rrbufr_rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrt setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rorrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrurb)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rr[ZAcceptExrtr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rorr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrtrr(rAerrnoZ WSAEINVALZ getsocknamerr[Z ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rorr)rarrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rr[ZConnectNamedPipertrr)rrarZ connectedrr)rarrs s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(rAZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r\)rr Zdelayr:r+rrrrjs  zIocpProactor.connect_pipecCs|j||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rr:rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrE)rrFZ done_callbackr?rrrrO7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r=)rorr)rmrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r<INFINITEmathceilr rr[ZRegisterWaitWithQueuerr rDr)rHrr)rr:rZ _is_cancelmsrr;rr)rmrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r9r]r rrtr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrmrrrrrrhs zIocpProactor._registercCs|jj|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rr>)rrrrrrNszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr<rMrr'doner(r.rr>r/rr rc)rrrrrZ transferredrr rmrrrrrrrrr=sJ         zIocpProactor._pollcCs|jj|dS)N)rr])rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrDr'r(r)rr*r=r debugrrr<rM)rr r?rrrr+r,rrrrbs,     "   zIocpProactor.closecCs |jdS)N)rb)rrrrrdszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3r4rrrrrrrrrrsr rjrrOrrrrNrr=rrbrdrrrrrs.          7 c@seZdZddZdS)r|c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)rrrrrcsjj}j|dS)N)_procZpollZ_process_exited)rm returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rIrintr7rv) rr~rrrrrrrrmr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr|sr|c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr)-r4r<rrrrrRrrrrrrr r Z coroutinesr logr __all__r[rZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr6rDrHobjectrPZBaseSelectorEventLoopreZBaseProactorEventLooprrZBaseSubprocessTransportr|r ZBaseDefaultEventLoopPolicyrrrrrrsL          0J4;]k__pycache__/subprocess.cpython-36.pyc000064400000015252152343301150013574 0ustar003 \@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__*/usr/lib64/python3.6/asyncio/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr=szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr?szProcess.terminatecCs|jjdS)N)rkill)rrrrr@sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrCr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|dks(t|j}|jjrV|dkrDdnd}tjd|||j EdH}|jjr|dkrzdnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rAssertionErrorrr&rAr rCreadr-)rr*r(streamnameoutputrrr _read_streams    zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rGrHrrNrrZgatherr&r<)rrFrrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr;r r<r=r?r@rGrHrNrOrrrrr9ks      r9c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr9) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrQsz(create_subprocess_exec..)rrr)rrRZsubprocess_execr9) Zprogramrrrr rargsrTrUr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r9Z_DEFAULT_LIMITrrrrrrs(      X] __pycache__/log.cpython-36.opt-1.pyc000064400000000334152343301150013117 0ustar003 \|@sdZddlZejeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.6/asyncio/log.pys__pycache__/windows_events.cpython-36.opt-2.pyc000064400000047640152343301150015430 0ustar003 \l@sddlZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddlm Z ddlm Z dd lm Z dd lmZdd lmZdd lmZd dddgZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGdddeZ Gd d!d!e j!Z"Gd"dde j#Z$Gd#ddZ%Gd$d%d%ej&Z'e"Z(Gd&d'd'ej)Z*e*Z+dS)(N)events)base_subprocess)futures)proactor_events)selector_events)tasks) windows_utils) _overlapped) coroutine)loggerSelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyliigMbP?g?csZeZdZddfdd ZfddZddZfd d Zfd d Zfd dZZ S)_OverlappedFutureN)loopcs&tj|d|jr|jd=||_dS)N)rr)super__init___source_traceback_ov)selfovr) __class__./usr/lib64/python3.6/asyncio/windows_events.pyr-sz_OverlappedFuture.__init__cs@tj}|jdk r<|jjr dnd}|jdd||jjf|S)NpendingZ completedrzoverlapped=<%s, %#x>)r _repr_inforrinsertaddress)rinfostate)rrrr3s   z_OverlappedFuture._repr_infocCsr|jdkrdSy|jjWnJtk rf}z.d||d}|jrJ|j|d<|jj|WYdd}~XnXd|_dS)Nz&Cancelling an overlapped future failed)message exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextrrr_cancel_overlapped:s  z$_OverlappedFuture._cancel_overlappedcs|jtjS)N)r-rr')r)rrrr'Jsz_OverlappedFuture.cancelcstj||jdS)N)r set_exceptionr-)rr$)rrrr.Ns z_OverlappedFuture.set_exceptioncstj|d|_dS)N)r set_resultr)rresult)rrrr/Rs z_OverlappedFuture.set_result) __name__ __module__ __qualname__rrr-r'r.r/ __classcell__rr)rrr's    rcsjeZdZddfdd ZddZfddZd d Zd d Zfd dZfddZ fddZ Z S)_BaseWaitHandleFutureN)rcs8tj|d|jr|jd=||_||_||_d|_dS)N)rrTr)rrrr_handle _wait_handle _registered)rrhandle wait_handler)rrrrZsz_BaseWaitHandleFuture.__init__cCstj|jdtjkS)Nr)_winapiZWaitForSingleObjectr6Z WAIT_OBJECT_0)rrrr_pollhs z_BaseWaitHandleFuture._pollcs\tj}|jd|j|jdk r>|jr0dnd}|j||jdk rX|jd|j|S)Nz handle=%#xZsignaledZwaitingzwait_handle=%#x)rrappendr6r<r7)rr!r")rrrrms    z _BaseWaitHandleFuture._repr_infocCs d|_dS)N)r)rfutrrr_unregister_wait_cbwsz)_BaseWaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj|WnZtk r}z>|jtjkrtd||d}|jrd|j|d<|jj |dSWYdd}~XnX|j ddS)NFz$Failed to unregister the wait handle)r#r$r%r&) r8r7r ZUnregisterWaitr(winerrorERROR_IO_PENDINGrr)r*r?)rr:r+r,rrr_unregister_wait|s"   z&_BaseWaitHandleFuture._unregister_waitcs|jtjS)N)rBrr')r)rrrr'sz_BaseWaitHandleFuture.cancelcs|jtj|dS)N)rBrr.)rr$)rrrr.sz#_BaseWaitHandleFuture.set_exceptioncs|jtj|dS)N)rBrr/)rr0)rrrr/sz _BaseWaitHandleFuture.set_result) r1r2r3rr<rr?rBr'r.r/r4rr)rrr5Ws   r5csBeZdZddfdd ZddZfddZfd d ZZS) _WaitCancelFutureN)rcstj||||dd|_dS)N)r)rr_done_callback)rreventr:r)rrrrsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeError)rrrrr'sz_WaitCancelFuture.cancelcs$tj||jdk r |j|dS)N)rr/rD)rr0)rrrr/s  z_WaitCancelFuture.set_resultcs$tj||jdk r |j|dS)N)rr.rD)rr$)rrrr.s  z_WaitCancelFuture.set_exception)r1r2r3rr'r/r.r4rr)rrrCs rCcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureN)rcs<tj||||d||_d|_tjdddd|_d|_dS)N)rTF)rr _proactorZ_unregister_proactorr Z CreateEvent_event _event_fut)rrr9r:proactorr)rrrrs z_WaitHandleFuture.__init__csF|jdk r"tj|jd|_d|_|jj|jd|_tj|dS)N) rIr; CloseHandlerJrH _unregisterrrr?)rr>)rrrr?s   z%_WaitHandleFuture._unregister_wait_cbcCs|js dSd|_|j}d|_ytj||jWnZtk r}z>|jtjkrxd||d}|jrh|j|d<|j j |dSWYdd}~XnX|j j |j|j |_dS)NFz$Failed to unregister the wait handle)r#r$r%r&)r8r7r ZUnregisterWaitExrIr(r@rArr)r*rH _wait_cancelr?rJ)rr:r+r,rrrrBs$    z"_WaitHandleFuture._unregister_wait)r1r2r3rr?rBr4rr)rrrGs rGc@s8eZdZddZddZddZddZd d ZeZd S) PipeServercCs,||_tj|_d|_d|_|jd|_dS)NT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr rrrrs  zPipeServer.__init__cCs|j|jd}|_|S)NF)rTrV)rtmprrr_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|jr dStjtjB}|r&|tjO}tj|j|tjtjBtj Btj t j t j tj tj}t j|}|jj||S)N)closedr;ZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperPZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerSadd)rfirstflagshpiperrrrVs      zPipeServer._server_pipe_handlecCs |jdkS)N)rP)rrrrrYszPipeServer.closedcCsV|jdk r|jjd|_|jdk rRx|jD] }|jq,Wd|_d|_|jjdS)N)rUr'rPrScloserTclear)rr`rrrras     zPipeServer.closeN) r1r2r3rrXrVrYra__del__rrrrrOs   rOc@seZdZddZdS)_WindowsSelectorEventLoopcCstjS)N)r socketpair)rrrr _socketpair+sz%_WindowsSelectorEventLoop._socketpairN)r1r2r3rfrrrrrd(srdcsLeZdZd fdd ZddZeddZedd Zed d d ZZ S)rNcs|dkrt}tj|dS)N)rrr)rrK)rrrr2szProactorEventLoop.__init__cCstjS)N)r re)rrrrrf7szProactorEventLoop._socketpairccs8|jj|}|EdH}|}|j||d|id}||fS)Naddr)extra)rH connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr fr`protocoltransrrrcreate_pipe_connection:s    z(ProactorEventLoop.create_pipe_connectioncs.tdfdd jgS)Ncsd}yj|rL|j}jj|jr2|jdS}j||didj}|dkr`dSjj|}Wnt k r}zH|r|j d krj d||d|jnj rt jd|ddWYdd}~Xn2tjk r|r|jYnX|_|jdS) Nrg)rhrzPipe accept failed)r#r$r`zAccept pipe failed on pipe %rT)exc_infor)r0rSdiscardrYrarjrXrH accept_piper(filenor*Z_debugr ZwarningrCancelledErrorrUadd_done_callback)rlr`rmr+)r loop_accept_piperkrserverrrrvGs<   z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rOZ call_soon)rrkr r)r rvrkrrwrstart_serving_pipeCs( z$ProactorEventLoop.start_serving_pipec ks|j} t||||||||f| |d| } y| EdHWn&tk r`} z | } WYdd} ~ XnXd} | dk r| j| jEdH| | S)N)waiterrh) create_future_WindowsSubprocessTransport ExceptionraZ_wait)rrmargsshellstdinstdoutstderrbufsizerhkwargsryZtranspr+errrrr_make_subprocess_transportrs  z,ProactorEventLoop._make_subprocess_transport)N)N) r1r2r3rrfr rorxrr4rr)rrr/s  /c@seZdZd0ddZddZddZd1d d Zd d Zd2ddZd3ddZ ddZ ddZ ddZ e ddZd4ddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd5d(d)Zd*d+Zd,d-Zd.d/ZdS)6rcCsDd|_g|_tjtjtd||_i|_tj |_ g|_ tj |_ dS)Nr) r)_resultsr CreateIoCompletionPortINVALID_HANDLE_VALUErZ_iocp_cacherQrRr8 _unregistered_stopped_serving)rZ concurrencyrrrrs zIocpProactor.__init__cCsd|jjt|jt|jfS)Nz<%s overlapped#=%s result#=%s>)rr1lenrr)rrrr__repr__szIocpProactor.__repr__cCs ||_dS)N)r))rrrrrset_loopszIocpProactor.set_loopNcCs |js|j||j}g|_|S)N)rr<)rtimeoutrWrrrselects  zIocpProactor.selectcCs|jj}|j||S)N)r)rzr/)rvaluer>rrr_results  zIocpProactor._resultrc Csz|j|tjt}y4t|tjr6|j|j||n|j|j|Wnt k rb|j dSXdd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N) getresultr(r@r ERROR_NETNAME_DELETEDConnectionResetErrorr})rnkeyrr+rrr finish_recvs   z&IocpProactor.recv..finish_recv) _register_with_iocpr OverlappedrZ isinstancesocketZWSARecvrsZReadFileBrokenPipeErrorr _register)rconnnbytesr^rrrrrrecvs     zIocpProactor.recvcCsZ|j|tjt}t|tjr4|j|j||n|j|j|dd}|j |||S)NcSsJy|jStk rD}z |jtjkr2t|jnWYdd}~XnXdS)N)rr(r@r rrr})rnrrr+rrr finish_sends   z&IocpProactor.send..finish_send) rr rrZrrZWSASendrsZ WriteFiler)rrbufr^rrrrrsends    zIocpProactor.sendcsz|j|jjtjt}|jjjfdd}tdd}|j ||}||}t j ||j d|S)NcsD|jtjdj}jtjtj|j j j fS)Nz@P) rstructZpackrs setsockoptr SOL_SOCKETr ZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rnrrr)rlistenerrr finish_accepts  z*IocpProactor.accept..finish_acceptc ss4y|EdHWn tjk r.|jYnXdS)N)rrtra)r%rrrr accept_coros z(IocpProactor.accept..accept_coro)r) r_get_accept_socketfamilyr rrZZAcceptExrsr rrZ ensure_futurer))rrrrrr%coror)rrraccepts     zIocpProactor.acceptcs|jytjjjWnBtk rb}z&|jtjkr@j ddkrRWYdd}~XnXtj t }|j j|fdd}|j ||S)Nrrcs|jjtjtjdS)Nr)rrrrr ZSO_UPDATE_CONNECT_CONTEXT)rnrr)rrrfinish_connects z,IocpProactor.connect..finish_connect)rr Z BindLocalrsrr(r@errnoZ WSAEINVALZ getsocknamerrZZ ConnectExr)rrr errr)rrconnects    zIocpProactor.connectcsJ|jtjt}|jj}|r0|jSfdd}|j||S)Ncs |jS)N)r)rnrr)r`rrfinish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rr rrZZConnectNamedPipersrr)rr`rZ connectedrr)r`rrr s    zIocpProactor.accept_pipeccszt}xjytj|}PWn0tk rF}z|jtjkr6WYdd}~XnXt|dt}tj ||j dEdHqWt j |S)N)r) CONNECT_PIPE_INIT_DELAYr Z ConnectPiper(r@ZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYrZsleepr)r r[)rr Zdelayr9r+rrrris  zIocpProactor.connect_pipecCs|j||dS)NF)_wait_for_handle)rr9rrrrwait_for_handle/szIocpProactor.wait_for_handlecCs|j|dd}||_|S)NT)rrD)rrEZ done_callbackr>rrrrN7szIocpProactor._wait_cancelcs|dkrtj}ntj|d}tjt}tj||j|j |}|rTt ||||j dnt |||||j dj rvj d=fdd}|d|f|j|j <S)Ng@@)rrcsjS)N)r<)rnrr)rlrrfinish_wait_for_handleRsz=IocpProactor._wait_for_handle..finish_wait_for_handlerr)r;INFINITEmathceilr rrZZRegisterWaitWithQueuerr rCr)rGrr)rr9rZ _is_cancelmsrr:rr)rlrr>s    zIocpProactor._wait_for_handlecCs0||jkr,|jj|tj|j|jdddS)Nr)r8r\r rrsr)robjrrrr^s  z IocpProactor._register_with_iocpcCst||jd}|jr|jd=|jsjy|dd|}Wn,tk r^}z|j|WYdd}~Xn X|j|||||f|j|j<|S)N)rrr) rr)rrr(r.r/rr )rrrcallbackrlrrrrrrhs zIocpProactor._registercCs|jj|dS)N)rr=)rrrrrrMszIocpProactor._unregistercCstj|}|jd|S)Nr)rr)rrsrrrrs  zIocpProactor._get_accept_socketcCs|dkrt}n0|dkr tdntj|d}|tkr>tdxtj|j|}|dkrZPd}|\}}}}y|jj|\}} } } WnVt k r|j j r|j j dd||||fd|dtj fkrtj|wBYnX| |jkr|jqB|jsBy| ||| } Wn:tk r@} z|j| |jj|WYdd} ~ XqBX|j| |jj|qBWx |jD]} |jj| jdqdW|jjdS)Nrznegative timeoutg@@ztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r#status)r ValueErrorrrr ZGetQueuedCompletionStatusrrpopKeyErrorr)Z get_debugr*rr;rLrr'doner(r.rr=r/rr rb)rrrrrZ transferredrr rlrrrrrrrrr<sJ         zIocpProactor._pollcCs|jj|dS)N)rr\)rrrrr _stop_servingszIocpProactor._stop_servingcCsxt|jjD]\}\}}}}|jr*qt|tr6qy |jWqtk r}z8|jdk rd||d}|j rz|j |d<|jj |WYdd}~XqXqWx|jr|j dst j dqWg|_|jdk rtj|jd|_dS)NzCancelling a future failed)r#r$r%r&rz"taking long time to close proactor)listritemsZ cancelledrrCr'r(r)rr*r<r debugrrr;rL)rr r>rrrr+r,rrrras,     "   zIocpProactor.closecCs |jdS)N)ra)rrrrrcszIocpProactor.__del__)r)N)r)r)N)N)r1r2r3rrrrrrrrrrrr rirrNrrrrMrr<rrarcrrrrrs,          7 c@seZdZddZdS)r{c  sPtj|f|||||d|_fdd}jjjtjj} | j|dS)N)r~rrrrcsjj}j|dS)N)_procZpollZ_process_exited)rl returncode)rrrrs z4_WindowsSubprocessTransport._start..callback) r Popenrr)rHrintr6ru) rr}r~rrrrrrrlr)rr_starts   z"_WindowsSubprocessTransport._startN)r1r2r3rrrrrr{sr{c@seZdZeZdS)_WindowsDefaultEventLoopPolicyN)r1r2r3r Z _loop_factoryrrrrrsr),r;rrrrrQrrrrrrr r Z coroutinesr logr __all__rZrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerr5rCrGobjectrOZBaseSelectorEventLooprdZBaseProactorEventLooprrZBaseSubprocessTransportr{r ZBaseDefaultEventLoopPolicyrrrrrrsJ          0J4;]k__pycache__/streams.cpython-36.pyc000064400000046715152343301150013072 0ustar003 \_@sLdZdddddddgZdd lZeed r6ejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d"Z GdddeZGdddeZe d#d e dddZe d$d e dddZeed re d%d e ddd Ze d&d e ddd ZGddde jZGdddee jZGd ddZGd!ddZd S)'zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname____doc__rr __classcell__rr)rrrs cs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager$)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N)r(r')r'csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr'r(kwdsreader transport_writerr)r)rr8s   c+s8dkrtjfdd}j|||f|EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncstd}t|d}|S)N)r(r')r')rr)r/r))client_connected_cbr(r'rrfactoryqs zstart_server..factory)rr+Z create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'csS)Nrr)r)rrr*sz&open_unix_connection..)rr+rrZcreate_unix_connectionr)pathr'r(r.r/r0r1r2r)r)rr }s  c+s6dkrtjfdd}j||f|EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncstd}t|d}|S)N)r(r')r')rr)r/r))r3r(r'rrr4s z"start_unix_server..factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr sc@s>eZdZdZd ddZddZddZd d Zed d Z dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr+_loop_paused _drain_waiter_connection_lost)rr'rrrrs  zFlowControlMixin.__init__cCs,|j s td|_|jjr(tjd|dS)NTz%r pauses writing)r8AssertionErrorr7 get_debugrdebug)rrrr pause_writings  zFlowControlMixin.pause_writingcCsP|js td|_|jjr&tjd||j}|dk rLd|_|jsL|jddS)NFz%r resumes writing) r8r;r7r<rr=r9done set_result)rwaiterrrrresume_writings   zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r:r8r9r?r@ set_exception)rexcrArrrconnection_losts z FlowControlMixin.connection_lostccsP|jrtd|jsdS|j}|dks2|js2t|jj}||_|EdHdS)NzConnection lost)r:ConnectionResetErrorr8r9 cancelledr;r7 create_future)rrArrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!r"rr>rBrErrIrrrrr6s   r6csFeZdZdZd fdd ZddZfddZd d Zd d ZZ S)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs*tj|d||_d|_||_d|_dS)N)r'F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr3r')rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rJ set_transportget_extra_inforMrLrr7rKr Z iscoroutineZ create_task)rr0resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rJfeed_eofrCrrErK)rrD)rrrrEs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rJ feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rJrRrM)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!r"rrQrErUrVr#rr)rrrs  c@sjeZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs2||_||_|dks"t|ts"t||_||_dS)N) _transport _protocol isinstancerr;_readerr7)rr0r)r/r'rrrrs zStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrWrZappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rW)rrrrr0'szStreamWriter.transportcCs|jj|dS)N)rWwrite)rrTrrrr`+szStreamWriter.writecCs|jj|dS)N)rW writelines)rrTrrrra.szStreamWriter.writelinescCs |jjS)N)rW write_eof)rrrrrb1szStreamWriter.write_eofcCs |jjS)N)rW can_write_eof)rrrrrc4szStreamWriter.can_write_eofcCs |jjS)N)rWclose)rrrrrd7szStreamWriter.closeNcCs|jj||S)N)rWrO)rnamedefaultrrrrO:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rZ exceptionrWZ is_closingrXrI)rrDrrrdrain=s    zStreamWriter.drain)N)rr r!r"rr_propertyr0r`rarbrcrdrOrrhrrrrrs  c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr+r7 bytearray_buffer_eof_waiter _exceptionrWr8)rr(r'rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>r[) rmr\rrnrk_DEFAULT_LIMITrorprWr8r])rr^rrrr_ks    zStreamReader.__repr__cCs|jS)N)rp)rrrrrg}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rprorGrC)rrDrArrrrCs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rorGr@)rrArrr_wakeup_waiters zStreamReader._wakeup_waitercCs|jdkstd||_dS)NzTransport already set)rWr;)rr0rrrrNszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r8rrmrkrWresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rnrs)rrrrrRszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rnrm)rrrrat_eofszStreamReader.at_eofc Cs|j std|sdS|jj||j|jdk r|j rt|jd|jkry|jj Wnt k rzd|_YnXd|_dS)Nzfeed_data after feed_eofrT) rnr;rmextendrsrWr8rrkZ pause_readingNotImplementedError)rrTrrrrSs   zStreamReader.feed_datac csf|jdk rtd||j s&td|jrsB       "  B3G__pycache__/transports.cpython-36.opt-1.pyc000064400000027400152343301150014560 0ustar003 \R'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkr i}||_dS)N)_extra)selfextrar */usr/lib64/python3.6/asyncio/transports.py__init__ szBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCstdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s eZdZdZddZddZdS)rz#Interface for read-only transports.cCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-sc@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineses zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort)NN) rrrrr!r"r$r%r&r'r(r r r r rAs   c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rsc@s"eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)N)rrrrr)r(r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs csVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. Ncs$tj|||_d|_|jdS)NF)superr_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r" _high_waterr5 _protocolZ pause_writing Exceptionr4call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r8r9r:r)r5r" _low_waterr<Zresume_writingr=r4r>)r r@r r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rBr;)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr;rB)r rr r r r r6s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr )r6rA)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrArCrDr6r!r" __classcell__r r )r7r r2s  r2N) rZasyncior__all__rrrrrrr2r r r r s  #D4__pycache__/locks.cpython-36.pyc000064400000036132152343301150012517 0ustar003 \<@sdZdddddgZddlZdd lmZdd lmZdd lmZdd lmZGd ddZ GdddZ Gddde Z GdddZ Gddde Z Gddde ZGdddeZdS)zSynchronization primitives.LockEvent Condition SemaphoreBoundedSemaphoreN)compat)events)futures) coroutinec@s(eZdZdZddZddZddZdS) _ContextManageraContext manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: cCs ||_dS)N)_lock)selflockr%/usr/lib64/python3.6/asyncio/locks.py__init__sz_ContextManager.__init__cCsdS)Nr)rrrr __enter__sz_ContextManager.__enter__c Gsz|jjWdd|_XdS)N)r release)rargsrrr__exit__$sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr s r c@sNeZdZddZddZeddZejrJddZ ed d Z ed d Z d S)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeError)rrrrr,sz_ContextManagerMixin.__enter__cGsdS)Nr)rrrrrr0sz_ContextManagerMixin.__exit__ccs|jEdHt|S)N)acquirer )rrrr__iter__5sz_ContextManagerMixin.__iter__ccs|jEdHt|S)N)rr )rrrr __await__Hsz_ContextManagerMixin.__await__ccs|jEdHdS)N)r)rrrr __aenter__Msz_ContextManagerMixin.__aenter__cCs |jdS)N)r)rexc_typeexctbrrr __aexit__Tsz_ContextManagerMixin.__aexit__N) rrrrrr rrZPY35rr r$rrrrr+s  rcsReZdZdZddddZfddZdd Zed d Zd d Z ddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'yield from'. Locks also support the context management protocol. '(yield from lock)' should be used as the context manager expression. Usage: lock = Lock() ... yield from lock try: ... finally: lock.release() Context manager usage: lock = Lock() ... with (yield from lock): ... Lock objects can be tested for locking state: if not lock.locked(): yield from lock else: # lock is acquired ... N)loopcCs.tj|_d|_|dk r ||_n tj|_dS)NF) collectionsdeque_waiters_locked_loopr get_event_loop)rr%rrrrs  z Lock.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)Nlockedunlockedz {},waiters:{}z <{} [{}]>r)super__repr__r)r(formatlen)rresextra) __class__rrr0s  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r))rrrrr,sz Lock.lockedccs|j r&tdd|jDr&d|_dS|jj}|jj|y"z|EdHWd|jj|XWn&tjk r|js~|j YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. css|]}|jVqdS)N) cancelled).0wrrr szLock.acquire..TN) r)allr(r* create_futureappendremover CancelledError_wake_up_first)rfutrrrrs  z Lock.acquirecCs"|jrd|_|jntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r)r?r)rrrrrs  z Lock.releasec Cs>ytt|j}Wntk r&dSX|js:|jddS)z*Wake up the first waiter if it isn't done.NT)nextiterr( StopIterationdone set_result)rr@rrrr?s zLock._wake_up_first) rrrrrr0r,r rrr? __classcell__rr)r5rrYs4  csReZdZdZddddZfddZdd Zd d Zd d Ze ddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. N)r%cCs.tj|_d|_|dk r ||_n tj|_dS)NF)r&r'r(_valuer*r r+)rr%rrrrs  zEvent.__init__csDtj}|jrdnd}|jr0dj|t|j}dj|dd|S)NsetZunsetz {},waiters:{}z <{} [{}]>rr.)r/r0rGr(r1r2)rr3r4)r5rrr0s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.)rG)rrrris_setsz Event.is_setcCs2|js.d|_x |jD]}|js|jdqWdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)rGr(rDrE)rr@rrrrHs  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FN)rG)rrrrclearsz Event.clearc csB|jr dS|jj}|jj|z|EdHdS|jj|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)rGr*r;r(r<r=)rr@rrrwait s   z Event.wait) rrrrrr0rIrHrJr rKrFrr)r5rrs  csZeZdZdZdddddZfddZedd Zed d Zdd dZ ddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. N)r%cCsp|dk r||_n tj|_|dkr0t|jd}n|j|jk rDtd||_|j|_|j|_|j|_t j |_ dS)N)r%z"loop argument must agree with lock) r*r r+r ValueErrorr r,rrr&r'r()rrr%rrrr+s  zCondition.__init__csFtj}|jrdnd}|jr2dj|t|j}dj|dd|S)Nr,r-z {},waiters:{}z <{} [{}]>rr.)r/r0r,r(r1r2)rr3r4)r5rrr0>s  zCondition.__repr__ccs|jstd|jz8|jj}|jj|z|EdHdS|jj|XWdd}x4y|jEdHPWqXt j k rd}YqXXqXW|rt j XdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockNTF) r,rrr*r;r(r<r=rr r>)rr@r6rrrrKEs&    zCondition.waitccs(|}x|s"|jEdH|}qW|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)rK)rZ predicateresultrrrwait_forks  zCondition.wait_forrcCsL|jstdd}x2|jD](}||kr*P|js|d7}|jdqWdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r,rr(rDrE)rnidxr@rrrnotifyys  zCondition.notifycCs|jt|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rQr2r()rrrr notify_allszCondition.notify_all)N)r) rrrrrr0r rKrNrQrRrFrr)r5rr!s  &  csTeZdZdZdddddZfddZd d Zd d Zed dZ ddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rN)r%cCs>|dkrtd||_tj|_|dk r0||_n tj|_dS)Nrz$Semaphore initial value must be >= 0)rLrGr&r'r(r*r r+)rvaluer%rrrrs zSemaphore.__init__csNtj}|jrdn dj|j}|jr:dj|t|j}dj|dd|S)Nr,zunlocked,value:{}z {},waiters:{}z <{} [{}]>rr.)r/r0r,r1rGr(r2)rr3r4)r5rrr0s  zSemaphore.__repr__cCs0x*|jr*|jj}|js|jddSqWdS)N)r(popleftrDrE)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.r)rG)rrrrr,szSemaphore.lockedc cszxf|jdkrf|jj}|jj|y|EdHWq|j|jdkr\|j r\|jYqXqW|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)rGr*r;r(r<Zcancelr6rU)rr@rrrrs    zSemaphore.acquirecCs|jd7_|jdS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)rGrU)rrrrrszSemaphore.release)r) rrrrrr0rUr,r rrrFrr)r5rrs   cs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rN)r%cs||_tj||ddS)N)r%) _bound_valuer/r)rrSr%)r5rrrszBoundedSemaphore.__init__cs"|j|jkrtdtjdS)Nz(BoundedSemaphore released too many times)rGrVrLr/r)r)r5rrrs zBoundedSemaphore.release)r)rrrrrrrFrr)r5rrs)r__all__r&rr r Z coroutinesr r rrrrrrrrrrs    .ByM__pycache__/futures.cpython-36.opt-2.pyc000064400000016722152343301150014044 0ustar003 \> @sddddddgZddlZddlZddlZddlZdd lmZdd lmZdd lm Z ej Z ej Z ej Z ej Z ejZejZejZejdZGd d d ZGdddZeZddZddZddZddZddddZy ddlZWnek rYn XejZZdS)CancelledError TimeoutErrorInvalidStateErrorFuture wrap_futureisfutureN) base_futures)compat)eventsc@s0eZdZdZddZddZd d Zd d Zd S)_TracebackLoggerloopsource_tracebackexctbcCs |j|_|j|_||_d|_dS)N)_loopr _source_tracebackrrr)selffuturerr'/usr/lib64/python3.6/asyncio/futures.py__init__Rsz_TracebackLogger.__init__cCs,|j}|dk r(d|_tj|j||j|_dS)N)r tracebackformat_exception __class__ __traceback__r)rrrrractivateXs  z_TracebackLogger.activatecCsd|_d|_dS)N)rr)rrrrclear_sz_TracebackLogger.clearcCsb|jr^d}|jr:djtj|j}|d7}|d|j7}|dj|jj7}|jjd|idS)Nz*Future/Task exception was never retrieved z0Future/Task created at (most recent call last): z%s message)rrjoinr format_listrstripr call_exception_handler)rmsgsrcrrr__del__csz_TracebackLogger.__del__N)r rrr)__name__ __module__ __qualname__ __slots__rrrr&rrrrr s 2r c@seZdZeZdZdZdZdZdZ dZ ddddZ e j ZddZejrNdd Zd d Zd d ZddZddZddZddZddZddZddZddZddZejreZdS) rNF)r cCs@|dkrtj|_n||_g|_|jjr )rr'r _repr_info)rrrr__repr__szFuture.__repr__cCsD|js dS|j}d|jj||d}|jr4|j|d<|jj|dS)Nz %s exception was never retrieved)r exceptionrr)_log_traceback _exceptionrr'rrr#)rrcontextrrrr&s zFuture.__del__cCs&d|_|jtkrdSt|_|jdS)NFT)r4_state_PENDING _CANCELLED_schedule_callbacks)rrrrcancels  z Future.cancelcCsD|jdd}|sdSg|jdd<x|D]}|jj||q*WdS)N)r,r call_soon)rZ callbackscallbackrrrr:s  zFuture._schedule_callbackscCs |jtkS)N)r7r9)rrrr cancelledszFuture.cancelledcCs |jtkS)N)r7r8)rrrrdonesz Future.donecCs<|jtkrt|jtkr tdd|_|jdk r6|j|jS)NzResult is not ready.F)r7r9r _FINISHEDrr4r5_result)rrrrresults   z Future.resultcCs,|jtkrt|jtkr tdd|_|jS)NzException is not set.F)r7r9rr@rr4r5)rrrrr3s   zFuture.exceptioncCs*|jtkr|jj||n |jj|dS)N)r7r8rr<r,append)rfnrrradd_done_callbacks zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)Ncsg|]}|kr|qSrr).0f)rDrr sz/Future.remove_done_callback..)r,len)rrDZfiltered_callbacksZ removed_countr)rDrremove_done_callbacks zFuture.remove_done_callbackcCs4|jtkrtdj|j|||_t|_|jdS)Nz{}: {!r})r7r8rformatrAr@r:)rrBrrr set_result s  zFuture.set_resultcCs|jtkrtdj|j|t|tr,|}t|tkr@td||_t |_|j t j rbd|_ nt|||_|jj|jjdS)Nz{}: {!r}zPStopIteration interacts badly with generators and cannot be raised into a FutureT)r7r8rrK isinstancetype StopIteration TypeErrorr5r@r:r PY34r4r Z _tb_loggerrr<r)rr3rrr set_exception,s    zFuture.set_exceptionccs|jsd|_|V|jS)NT)r?_asyncio_future_blockingrB)rrrr__iter__DszFuture.__iter__) r'r(r)r8r7rAr5rrrSr4rr Z_future_repr_infor1r2r rQr&r;r:r>r?rBr3rErJrLrRrTZPY35 __await__rrrrrns2   cCs|jr dS|j|dS)N)r>rL)ZfutrBrrr_set_result_unless_cancelledSsrVcCsN|jr|j|jsdS|j}|dk r8|j|n|j}|j|dS)N)r>r;Zset_running_or_notify_cancelr3rRrBrL) concurrentsourcer3rBrrr_set_concurrent_future_stateZs rYcCsP|jr dS|jr|jn.|j}|dk r:|j|n|j}|j|dS)N)r>r;r3rRrBrL)rXdestr3rBrrr_copy_future_stateis  r[cst r"ttjj r"tdt rDttjj rDtdtrRjndtrdjndddfdd}fdd}j|j|dS) Nz(A future is required for source argumentz-A future is required for destination argumentcSs"t|rt||n t||dS)N)rr[rY)rotherrrr _set_states z!_chain_future.._set_statecs2|jr.dkskr"jn jjdS)N)r>r;call_soon_threadsafe) destination) dest_looprX source_looprr_call_check_cancels z)_chain_future.._call_check_cancelcsJjrdk rjrdSdks,kr8|nj|dS)N)r>Z is_closedr^)rX)r]r`r_rarr_call_set_states  z&_chain_future.._call_set_state)rrMrWZfuturesrrPrrE)rXr_rbrcr)r]r`r_rXrar _chain_future}s   rd)r cCs2t|r |S|dkrtj}|j}t|||S)N)rr r+Z create_futurerd)rr Z new_futurerrrrs )__all__Zconcurrent.futuresrWZloggingr.rrr r r rrrrr8r9r@DEBUGZ STACK_DEBUGr rZ _PyFuturerVrYr[rdrZ_asyncio ImportErrorZ_CFuturerrrrs<     Pc*  __pycache__/transports.cpython-36.pyc000064400000027436152343301150013632 0ustar003 \R'@sdZddlmZddddddgZGd ddZGd ddeZGd ddeZGd ddeeZGd ddeZGdddeZ GdddeZ dS)zAbstract Transport class.)compat BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)rzBase class for transports.NcCs|dkr i}||_dS)N)_extra)selfextrar */usr/lib64/python3.6/asyncio/transports.py__init__ szBaseTransport.__init__cCs|jj||S)z#Get optional transport information.)r get)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.N)NotImplementedError)r r r r is_closingszBaseTransport.is_closingcCstdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. N)r)r r r r closeszBaseTransport.closecCstdS)zSet a new protocol.N)r)r protocolr r r set_protocol$szBaseTransport.set_protocolcCstdS)zReturn the current protocol.N)r)r r r r get_protocol(szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__rrrrrrr r r r r s   c@s eZdZdZddZddZdS)rz#Interface for read-only transports.cCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)r)r r r r pause_reading0szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)r)r r r r resume_reading8szReadTransport.resume_readingN)rrrrrrr r r r r-sc@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rz$Interface for write-only transports.NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)r)r highlowr r r set_write_buffer_limitsDsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.N)r)r r r r get_write_buffer_sizeYsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. N)r)r datar r r write]szWriteTransport.writecCstj|}|j|dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)rZflatten_list_bytesr$)r Z list_of_datar#r r r writelineses zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. N)r)r r r r write_eofnszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.N)r)r r r r can_write_eofwszWriteTransport.can_write_eofcCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r abort{szWriteTransport.abort)NN) rrrrr!r"r$r%r&r'r(r r r r rAs   c@seZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. N)rrrrr r r r rsc@s"eZdZdZdddZddZdS)rz(Interface for datagram (UDP) transports.NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. N)r)r r#Zaddrr r r sendtoszDatagramTransport.sendtocCstdS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. N)r)r r r r r(szDatagramTransport.abort)N)rrrrr)r(r r r r rs c@s<eZdZddZddZddZddZd d Zd d Zd S)rcCstdS)zGet subprocess id.N)r)r r r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode N)r)r r r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.N)r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal N)r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate N)r)r r r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill N)r)r r r r kills zSubprocessTransport.killN) rrrr*r+r-r/r0r1r r r r rs csVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. Ncs0tj||dk st||_d|_|jdS)NF)superrAssertionError_loop_protocol_paused_set_write_buffer_limits)r r Zloop) __class__r r rs   z_FlowControlMixin.__init__cCsp|j}||jkrdS|jsld|_y|jjWn:tk rj}z|jjd|||jdWYdd}~XnXdS)NTzprotocol.pause_writing() failed)message exception transportr)r" _high_waterr6 _protocolZ pause_writing Exceptionr5call_exception_handler)r sizeexcr r r _maybe_pause_protocols z'_FlowControlMixin._maybe_pause_protocolcCsh|jrd|j|jkrdd|_y|jjWn:tk rb}z|jjd|||jdWYdd}~XnXdS)NFz protocol.resume_writing() failed)r9r:r;r)r6r" _low_waterr=Zresume_writingr>r5r?)r rAr r r _maybe_resume_protocolsz(_FlowControlMixin._maybe_resume_protocolcCs |j|jfS)N)rCr<)r r r r get_write_buffer_limitssz)_FlowControlMixin.get_write_buffer_limitscCsf|dkr|dkrd}nd|}|dkr.|d}||ko@dknsVtd||f||_||_dS)N@irz*high (%r) must be >= low (%r) must be >= 0i) ValueErrorr<rC)r rr r r r r7s z*_FlowControlMixin._set_write_buffer_limitscCs|j||d|jdS)N)rr )r7rB)r rr r r r r!-sz)_FlowControlMixin.set_write_buffer_limitscCstdS)N)r)r r r r r"1sz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrBrDrEr7r!r" __classcell__r r )r8r r2s  r2N) rZasyncior__all__rrrrrrr2r r r r s  #D4__pycache__/streams.cpython-36.opt-2.pyc000064400000032056152343301150014023 0ustar003 \_@sHdddddddgZddlZeed r2ejd d gd d lmZd dlmZd dlmZd dlmZd dlm Z d dl m Z d!Z Gddde ZGdddeZe d"de dddZe d#de dddZeed re d$de ddd Ze d%de ddd ZGdddejZGdddeejZGdddZGd ddZdS)& StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs$eZdZfddZddZZS)rcs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname__rr __classcell__rr)rrrs cs$eZdZfddZddZZS)rcstj|||_dS)N)rrconsumed)rmessager#)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr#)rrrrr4szLimitOverrunError.__reduce__)rr r!rrr"rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)N)r'r&)r&csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr&r'kwdsreader transport_writerr)r(rr8s   c+s8dkrtjfdd}j|||f|EdHS)Ncstd}t|d}|S)N)r'r&)r&)rr)r.r()client_connected_cbr'r&rrfactoryqs zstart_server..factory)rr*Z create_server)r2r+r,r&r'r-r3r)r2r'r&rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)N)r'r&)r&csS)Nrr)r(rrr)sz&open_unix_connection..)rr*rrZcreate_unix_connectionr)pathr&r'r-r.r/r0r1r)r(rr }s  c+s6dkrtjfdd}j||f|EdHS)Ncstd}t|d}|S)N)r'r&)r&)rr)r.r()r2r'r&rrr3s z"start_unix_server..factory)rr*Zcreate_unix_server)r2r4r&r'r-r3r)r2r'r&rr sc@s:eZdZd ddZddZddZdd Zed d ZdS) FlowControlMixinNcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr*_loop_paused _drain_waiter_connection_lost)rr&rrrrs  zFlowControlMixin.__init__cCs d|_|jjrtjd|dS)NTz%r pauses writing)r7r6 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jjrtjd||j}|dk rBd|_|jsB|jddS)NFz%r resumes writing)r7r6r:rr;r8done set_result)rwaiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r9r7r8r=r> set_exception)rexcr?rrrconnection_losts z FlowControlMixin.connection_lostccs<|jrtd|jsdS|j}|jj}||_|EdHdS)NzConnection lost)r9ConnectionResetErrorr7r8r6 create_future)rr?rrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!rr<r@rCrrFrrrrr5s   r5csBeZdZd fdd ZddZfddZdd Zd d ZZS) rNcs*tj|d||_d|_||_d|_dS)N)r&F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr2r&)rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rG set_transportget_extra_inforJrIrr6rHr Z iscoroutineZ create_task)rr/resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rGfeed_eofrArrCrH)rrB)rrrrCs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rG feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rGrOrJ)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!rrNrCrRrSr"rr)rrrs   c@sfeZdZddZddZeddZddZd d Zd d Z d dZ ddZ dddZ e ddZdS)rcCs||_||_||_||_dS)N) _transport _protocol_readerr6)rr/r(r.r&rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrTrVappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rT)rrrrr/'szStreamWriter.transportcCs|jj|dS)N)rTwrite)rrQrrrr\+szStreamWriter.writecCs|jj|dS)N)rT writelines)rrQrrrr].szStreamWriter.writelinescCs |jjS)N)rT write_eof)rrrrr^1szStreamWriter.write_eofcCs |jjS)N)rT can_write_eof)rrrrr_4szStreamWriter.can_write_eofcCs |jjS)N)rTclose)rrrrr`7szStreamWriter.closeNcCs|jj||S)N)rTrL)rnamedefaultrrrrL:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)N)rV exceptionrTZ is_closingrUrF)rrBrrrdrain=s    zStreamWriter.drain)N)rr r!rr[propertyr/r\r]r^r_r`rLrrdrrrrrs   c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr*r6 bytearray_buffer_eof_waiter _exceptionrTr7)rr'r&rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rW) rirXrrjrg_DEFAULT_LIMITrkrlrTr7rY)rrZrrrr[ks    zStreamReader.__repr__cCs|jS)N)rl)rrrrrc}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rlrk cancelledrA)rrBr?rrrrAs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)N)rkror>)rr?rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dS)N)rT)rr/rrrrKszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r7rrirgrTresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rjrp)rrrrrOszStreamReader.feed_eofcCs|jo |j S)N)rjri)rrrrat_eofszStreamReader.at_eofc Csv|sdS|jj||j|jdk rr|j rrt|jd|jkrry|jjWntk rjd|_YnXd|_dS)NrT) riextendrprTr7rrgZ pause_readingNotImplementedError)rrQrrrrPs   zStreamReader.feed_datac csV|jdk rtd||jr,d|_|jj|jj|_z|jEdHWdd|_XdS)NzH%s() called while another coroutine is already waiting for incoming dataF)rk RuntimeErrorr7rTrqr6rE)rZ func_namerrr_wait_for_datas   zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rB}z|jSd}~Xnftk r}zJ|jj||jrv|jd|j|=n |jj|j t |j dWYdd}~XnX|S)N r) r readuntilrrrri startswithr#clearrrrfr%)rsepseplenlineerrrreadlines  zStreamReader.readlinerxccst|}|dkrtd|jdk r(|jd}xt|j}|||kr||jj||}|dkr\P|d|}||jkr|td||jrt|j}|jj t |d|j dEdHq.W||jkrtd||jd||}|jd||=|j t|S)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitryz2Separator is found, but chunk is longer than limit) rrfrlrifindrgrrjbytesr{rrwrr)rZ separatorr}offsetZbuflenZisepchunkrrrrys:         zStreamReader.readuntilr ccs|jdk r|j|dkrdS|dkrZg}x&|j|jEdH}|sBP|j|q*Wdj|S|j rz|j rz|jdEdHt|jd|}|jd|=|j |S)Nrread) rlrrgrXrYrirjrwrrr)rnZblocksblockrQrrrrPs$   zStreamReader.readccs|dkrtd|jdk r |j|dkr,dSxFt|j|krr|jr`t|j}|jjt|||jdEdHq.Wt|j|krt|j}|jjnt|jd|}|jd|=|j |S)Nrz*readexactly size can not be less than zeror readexactly) rfrlrrirjrr{rrwrr)rrZ incompleterQrrrrs&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs|jEdH}|dkrt|S)Nr)rStopAsyncIteration)rvalrrr __anext__szStreamReader.__anext__cCs|S)Nr)rrrrrs)rxr)r)rr r!rnrr[rcrArprKrrrOrsrPrrwrryrrr ZPY35rrZPY352rrrrrVs,    [ 2 *  i)NN)NN)N)N)__all__Zsockethasattrrtr r rrrlogrrnEOFErrorr Exceptionrrrr r ZProtocolr5rrrrrrrs@       "  B3G__pycache__/unix_events.cpython-36.opt-1.pyc000064400000073006152343301150014713 0ustar003 \ @s dZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZddlmZdddddgZejdkredddZy ejZWnek r,ddZYnXGdddejZ e!edrVddZ"nddl#Z#d dZ"Gd!d"d"ej$Z%Gd#d$d$ej&ej'Z(e!ed%rej)Z*nddl#Z#d&d'Z*Gd(d)d)e j+Z,Gd*ddZ-Gd+d,d,e-Z.Gd-dde.Z/Gd.dde.Z0Gd/d0d0ej1Z2e Z3e2Z4dS)1z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess)compat) constants) coroutines)events)futures)selector_events) selectors) transports) coroutine)loggerSelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr+/usr/lib64/python3.6/asyncio/unix_events.py_sighandler_noop%srcCs|S)Nr)pathrrr.srcseZdZdZd"fdd ZddZfddZd d Zd d Zd dZ ddZ ddZ d#ddZ d$ddZ ed%ddZddZeddddddZed&ddddd d!ZZS)'_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncstj|i|_dS)N)super__init___signal_handlers)selfselector) __class__rrr7s z_UnixSelectorEventLoop.__init__cCstjS)N)socketZ socketpair)rrrr _socketpair;sz"_UnixSelectorEventLoop._socketpaircs^tjtjs2xFt|jD]}|j|qWn(|jrZtjd|dt |d|jj dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removal)source) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclear)rsig)r!rrr%>s z_UnixSelectorEventLoop.closecCs"x|D]}|sq|j|qWdS)N)_handle_signal)rdatarrrr_process_self_dataLs z)_UnixSelectorEventLoop._process_self_datac+GsHtj|stj|rtd|j||jytj|jj Wn2t t fk rt}zt t |WYdd}~XnXtj|||}||j|<ytj|ttj|dWnt k rB}zz|j|=|jsytjdWn4t t fk r}ztjd|WYdd}~XnX|jtjkr0t dj|nWYdd}~XnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFrzset_wakeup_fd(-1) failed: %szsig {} cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptrinfoerrnoEINVALformat)rr.callbackargsexchandleZnexcrrradd_signal_handlerSs0     z)_UnixSelectorEventLoop.add_signal_handlercCs8|jj|}|dkrdS|jr*|j|n |j|dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr.rDrrrr/s   z%_UnixSelectorEventLoop._handle_signalc&Cs|j|y |j|=Wntk r*dSX|tjkr>tj}ntj}ytj||Wn@tk r}z$|jtj krt dj |nWYdd}~XnX|jsytj dWn2t tfk r}ztjd|WYdd}~XnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fzsig {} cannot be caughtNrzset_wakeup_fd(-1) failed: %sTr2)r4rKeyErrorr5SIGINTdefault_int_handlerSIG_DFLr9r>r?r:r@r6r8rr=)rr.ZhandlerrCrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCsHt|tstdj|d|ko,tjknsDtdj|tjdS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not {!r}rzsig {} out of range(1, {})N) isinstanceintr3r@r5NSIGr8)rr.rrrr4s  z$_UnixSelectorEventLoop._check_signalcCst|||||S)N)_UnixReadPipeTransport)rpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||S)N)_UnixWritePipeTransport)rrOrPrQrRrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc kstj} |j} t||||||||f| |d| } | j| j|j| y| EdHWn&tk r~} z | }WYdd} ~ XnXd}|dk r| j| j EdH|WdQRX| S)N)rQrR) rget_child_watcherZ create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback Exceptionr%Z_wait)rrPrBshellstdinstdoutstderrbufsizerRkwargswatcherrQtransprCerrrrr_make_subprocess_transports$     z1_UnixSelectorEventLoop._make_subprocess_transportcCs|j|j|dS)N)Zcall_soon_threadsafeZ_process_exited)rpid returncoderbrrrrYsz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamec cs|r|dkr&tdn|dk r&td|dk r|dk r>tdtjtjtjd}y |jd|j||EdHWq|jYqXnB|dkrtd|jtjkstj |j  rtdj ||jd|j ||||EdH\}}||fS)Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with sslz3path and sock can not be specified at the same timerFzno path and sock were specifiedz2A UNIX Domain Stream Socket was expected, got {!r}) r8r"AF_UNIX SOCK_STREAM setblockingZ sock_connectr%familyr_is_stream_sockettyper@Z_create_connection_transport)rprotocol_factoryrrgrhri transportrPrrrcreate_unix_connections8    z-_UnixSelectorEventLoop.create_unix_connectiond)rhbacklogrgc !Cst|trtd|dk r0|dk r,tdt|}tjtjtj}|dd kry tj t j|j rnt j |WnBt k rYn0tk r}ztjd||WYdd}~XnXy|j|Wnjtk r}z8|j|jtjkrdj|}ttj|dnWYdd}~Xn|jYnXn>|dkrBtd|jtjks`tj|j rntdj|tj||g} |j||jd |j|||| | S) Nz*ssl argument must be an SSLContext or Nonez3path and sock can not be specified at the same timerz2Unable to check or remove stale UNIX socket %r: %rzAddress {!r} is already in usez-path was not specified, and no sock specifiedz2A UNIX Domain Stream Socket was expected, got {!r}F)rru)rKboolr3r8_fspathr"rjrkstatS_ISSOCKosst_moderemoveFileNotFoundErrorr9rerrorZbindr%r>Z EADDRINUSEr@rmrrnroZServerZlistenrlZ_start_serving) rrprrhrtrgrcrCmsgZserverrrrcreate_unix_serversP         z)_UnixSelectorEventLoop.create_unix_server)N)NN)NN)N)N)__name__ __module__ __qualname____doc__rr#r%r1rEr/r)r4rSrUr rdrYrrr __classcell__rr)r!rr1s, -      %r set_blockingcCstj|ddS)NF)rzr)fdrrr_set_nonblockingBsrcCs,tj|tj}|tjB}tj|tj|dS)N)fcntlZF_GETFLrz O_NONBLOCKZF_SETFL)rflagsrrrrGs cseZdZdZd fdd ZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ e jrhddZd!ddZddZddZZS)"rNiNcstj|||jd<||_||_|j|_||_d|_t j |jj }t j |pbt j|pbt j|s~d|_d|_d|_tdt|j|jj|jj||jj|jj|j|j|dk r|jjtj|ddS)NrOFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper7_fileno _protocol_closingrzfstatr{rxS_ISFIFOryS_ISCHRr8r call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rlooprOrPrQrRmode)r!rrrQs,          z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdq|jdn |jdk r|jdn |jddd j |S) Nclosedclosingzfd=%s _selectorpollingidleopenz<%s> ) r!rrappendrrgetattrrr _test_selector_eventr Z EVENT_READjoin)rr=r rrrr__repr__ns$          z_UnixReadPipeTransport.__repr__cCsytj|j|j}WnDttfk r,Yntk rX}z|j|dWYdd}~Xn^X|rl|jj |nJ|j j rt j d|d|_|j j|j|j j|jj|j j|jddS)Nz"Fatal read error on pipe transportz%r was closed by peerT)rzreadrmax_sizeBlockingIOErrorInterruptedErrorr9 _fatal_errorrZ data_receivedr get_debugrr=r_remove_readerrZ eof_received_call_connection_lost)rr0rCrrrrs  z"_UnixReadPipeTransport._read_readycCs|jj|jdS)N)rrr)rrrr pause_readingsz$_UnixReadPipeTransport.pause_readingcCs|jj|j|jdS)N)rrrr)rrrrresume_readingsz%_UnixReadPipeTransport.resume_readingcCs ||_dS)N)r)rrPrrr set_protocolsz#_UnixReadPipeTransport.set_protocolcCs|jS)N)r)rrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jS)N)r)rrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|jddS)N)r_close)rrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrr__del__s  z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jjrLtjd||ddn|jj||||j d|j |dS)Nz%r: %sT)exc_info)message exceptionrqrP) rKr9r>ZEIOrrrdebugcall_exception_handlerrr)rrCrrrrrs  z#_UnixReadPipeTransport._fatal_errorcCs(d|_|jj|j|jj|j|dS)NT)rrrrrr)rrCrrrrsz_UnixReadPipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rconnection_lostrr%r)rrCrrrrs  z,_UnixReadPipeTransport._call_connection_losti)NN)r)rrrrrrrrrrrrr%rPY34rrrrrrr)r!rrNMs rNcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejr|ddZddZd&dd Zd'd!d"Zd#d$ZZS)(rTNc stj||||jd<||_|j|_||_t|_d|_ d|_ t j |jj }tj|}tj|}tj|} |px|px| sd|_d|_d|_tdt|j|jj|jj|| s|rtjjd r|jj|jj|j|j|dk r|jjtj|ddS)NrOrFz?Pipe transport is only for pipes, sockets and character devicesaix)rrrrr7rr bytearray_buffer _conn_lostrrzrr{rxrrryr8rrrrr&platform startswithrrr r) rrrOrPrQrRrZis_charZis_fifoZ is_socket)r!rrrs2          z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |jdn|jr0|jd|jd|jt|jdd}|jdk r|dk rtj ||jt j }|r|jdn |jd|j }|jd|n |jdk r|jdn |jdd d j |S) Nrrzfd=%srrrz bufsize=%srz<%s>r)r!rrrrrrrr rr Z EVENT_WRITEget_write_buffer_sizer)rr=r rr_rrrrs(          z _UnixWritePipeTransport.__repr__cCs t|jS)N)lenr)rrrrrsz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jjrtjd||jr*|jtn|jdS)Nz%r was closed by peer)rrrr=rrBrokenPipeError)rrrrrs   z#_UnixWritePipeTransport._read_readycCst|trt|}|sdS|js&|jrN|jtjkrs&   z$_UnixWritePipeTransport._write_readycCsdS)NTr)rrrr can_write_eofXsz%_UnixWritePipeTransport.can_write_eofcCs8|jr dSd|_|js4|jj|j|jj|jddS)NT)rrrrrrr)rrrr write_eof[s z!_UnixWritePipeTransport.write_eofcCs ||_dS)N)r)rrPrrrrdsz$_UnixWritePipeTransport.set_protocolcCs|jS)N)r)rrrrrgsz$_UnixWritePipeTransport.get_protocolcCs|jS)N)r)rrrrrjsz"_UnixWritePipeTransport.is_closingcCs|jdk r|j r|jdS)N)rrr)rrrrr%msz_UnixWritePipeTransport.closecCs,|jdk r(tjd|t|d|jjdS)Nzunclosed transport %r)r$)rr*r+r,r%)rrrrrvs  z_UnixWritePipeTransport.__del__cCs|jddS)N)r)rrrrabort|sz_UnixWritePipeTransport.abortFatal error on pipe transportcCsPt|tjr*|jjrBtjd||ddn|jj||||jd|j |dS)Nz%r: %sT)r)rrrqrP) rKrZ_FATAL_ERROR_IGNORErrrrrrr)rrCrrrrrs   z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|jj|j|jj|jj|j|jj|j|dS)NT) rrrrrr-rrr)rrCrrrrs  z_UnixWritePipeTransport._closec Cs4z|jj|Wd|jjd|_d|_d|_XdS)N)rrrr%r)rrCrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrrrrrrr%rrrrrrrrrr)r!rrTs$% !   rTset_inheritablecCsNttdd}tj|tj}|s4tj|tj||Bntj|tj||@dS)NZ FD_CLOEXECr)rrZF_GETFDZF_SETFD)rZ inheritableZ cloexec_flagoldrrr_set_inheritables  rc@seZdZddZdS)rWc Ksvd}|tjkr*|jj\}}t|jdtj|f||||d|d||_|dk rr|jt |j d|d|j_ dS)NF)r[r\r]r^Zuniversal_newlinesr_wb) buffering) subprocessPIPErr#rr7Popen_procr%rdetachr\) rrBr[r\r]r^r_r`Zstdin_wrrr_starts  z_UnixSubprocessTransport._startN)rrrrrrrrrWsrWc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. N)NotImplementedError)rrerArBrrrrXs z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.N)r)rrerrrremove_child_handlersz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. N)r)rrrrr attach_loopsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. N)r)rrrrr%szAbstractChildWatcher.closecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfN)r)rrrr __enter__szAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextN)r)rabcrrr__exit__ szAbstractChildWatcher.__exit__N) rrrrrXrrr%rrrrrrrs  c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dS)N)r _callbacks)rrrrrszBaseChildWatcher.__init__cCs|jddS)N)r)rrrrr%szBaseChildWatcher.closecCs tdS)N)r)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdS)N)r)rrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCsf|jdk r$|dkr$|jr$tjdt|jdk r<|jjtj||_|dk rb|jtj|j |j dS)NzCA loop is being detached from a child watcher with pending handlers) rrr*r+RuntimeWarningr)r5SIGCHLDrE _sig_chldr)rrrrrrs zBaseChildWatcher.attach_loopcCsFy |jWn4tk r@}z|jjd|dWYdd}~XnXdS)Nz$Unknown exception in SIGCHLD handler)rr)rrZrr)rrCrrrr1s  zBaseChildWatcher._sig_chldcCs2tj|rtj| Stj|r*tj|S|SdS)N)rz WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)rstatusrrr_compute_returncode=s     z$BaseChildWatcher._compute_returncodeN) rrrrr%rrrrrrrrrrs rcsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)rad'Safe' child watcher implementation. This implementation avoids disrupting other code spawning processes by polling explicitly each process in the SIGCHLD handler instead of calling os.waitpid(-1). This is a safe solution but it has a significant overhead when handling a big number of children (O(n) each time SIGCHLD is raised) cs|jjtjdS)N)rr-rr%)r)r!rrr%Vs zSafeChildWatcher.closecCs|S)Nr)rrrrrZszSafeChildWatcher.__enter__cCsdS)Nr)rrrrrrrr]szSafeChildWatcher.__exit__cGs.|jdkrtd||f|j|<|j|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rr)rrerArBrrrrX`s  z"SafeChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrks z%SafeChildWatcher.remove_child_handlercCs"xt|jD]}|j|q WdS)N)r(rr)rrerrrrrsz SafeChildWatcher._do_waitpid_allcCsytj|tj\}}Wn(tk r>|}d}tjd|Yn0X|dkrLdS|j|}|jjrntj d||y|j j |\}}Wn.t k r|jjrtjd|ddYnX|||f|dS)Nz8Unknown child process pid %d, will report returncode 255rz$process %s exited with returncode %sz'Child watcher got an unexpected pid: %rT)r) rzwaitpidWNOHANGChildProcessErrorrrrrrrrpoprG)rrrerrfrArBrrrrws*    zSafeChildWatcher._do_waitpid) rrrrr%rrrXrrrrrr)r!rrKs   csTeZdZdZfddZfddZddZdd Zd d Zd d Z ddZ Z S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs$tjtj|_i|_d|_dS)Nr)rr threadingZLock_lock_zombies_forks)r)r!rrrs  zFastChildWatcher.__init__cs"|jj|jjtjdS)N)rr-rrr%)r)r!rrr%s  zFastChildWatcher.closec Cs$|j|jd7_|SQRXdS)Nr)rr)rrrrrszFastChildWatcher.__enter__c CsV|j:|jd8_|js$|j r(dSt|j}|jjWdQRXtjd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)rrrr;r-rr)rrrrZcollateral_victimsrrrrs zFastChildWatcher.__exit__cGsl|jdkrtd|j:y|jj|}Wn"tk rL||f|j|<dSXWdQRX|||f|dS)NzICannot add child handler, the child watcher does not have a loop attached)rr:rrrrGr)rrerArBrfrrrrXs z"FastChildWatcher.add_child_handlerc Cs&y |j|=dStk r dSXdS)NTF)rrG)rrerrrrs z%FastChildWatcher.remove_child_handlercCsxytjdtj\}}Wntk r,dSX|dkr:dS|j|}|jvy|jj|\}}WnBtk r|j r||j |<|j j rt jd||wd}YnX|j j rt jd||WdQRX|dkrt jd||q|||f|qWdS)Nrrz,unknown process %s exited with returncode %sz$process %s exited with returncode %sz8Caught subprocess termination from unknown pid: %d -> %dr2)rzrrrrrrrrGrrrrrrr)rrerrfrArBrrrrs6      z FastChildWatcher._do_waitpid_all) rrrrrr%rrrXrrrrr)r!rrs   csHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstjd|_dS)N)rr_watcher)r)r!rrr s z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_ttjtjr:|jj|j j WdQRXdS)N) rrrrrKrcurrent_thread _MainThreadr_localr)rrrr _init_watchers  z)_UnixDefaultEventLoopPolicy._init_watchercs6tj||jdk r2ttjtjr2|jj|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprrKrrrr)rr)r!rrrs  z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr|j|jS)zzGet the watcher for child processes. If not yet set, a SafeChildWatcher object is automatically created. N)rr)rrrrrV&s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|jj||_dS)z$Set the watcher for child processes.N)rr%)rrarrrset_child_watcher0s  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrrrVrrrr)r!rrs   r)5rr>rzr5r"rxrr&rr*rrrrrrr r r r r logr__all__r ImportErrorrfspathrwAttributeErrorZBaseSelectorEventLooprhasattrrrZ ReadTransportrNZ_FlowControlMixinZWriteTransportrTrrZBaseSubprocessTransportrWrrrrZBaseDefaultEventLoopPolicyrrrrrrrsn                O  F=On2__pycache__/constants.cpython-36.opt-1.pyc000064400000000375152343301150014357 0ustar003 \s@sdZdZdZdZdS)z Constants. N)__doc__Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHrr)/usr/lib64/python3.6/asyncio/constants.pys__pycache__/tasks.cpython-36.pyc000064400000045227152343301150012536 0ustar003 \a @sdZddddddddd d d d d g ZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z ddl mZGddde jZeZy ddlZWnek rYn XejZZej jZej jZej jZeddedddZddZeddddZeddZddd d!dZed/ddd"dZddd#d$Zeed <d e_ [ddd%d Z!ed&d'Z"Gd(d)d)e jZ#dd*d+d,d Z$ddd-d Z%d.d Z&dS)0z0Support for tasks, coroutines and the scheduler.TaskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepasyncgathershield ensure_futurerun_coroutine_threadsafeN) base_tasks)compat) coroutines)events)futures) coroutinecseZdZdZejZiZdZe dddZ e dddZ ddfd d Z e jrXd d Zd dZddddZdddddZddZdfdd ZddZZS)rz A coroutine wrapped in a Future.TNcCs|dkrtj}|jj|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. N)rget_event_loop_current_tasksget)clsloopr%/usr/lib64/python3.6/asyncio/tasks.py current_task.szTask.current_taskcs$dkrtjfdd|jDS)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. Ncsh|]}|jkr|qSr)_loop).0t)rrr Bsz!Task.all_tasks..)rr _all_tasks)rrr)rr all_tasks:szTask.all_tasks)rcsdtj|stt|tj|d|jr2|jd=||_d|_d|_ |j j |j |j jj|dS)N)rrF)r iscoroutineAssertionErrorreprsuper__init___source_traceback_coro _fut_waiter _must_cancelr call_soon_step __class__r"add)selfcoror)r0rrr)Dsz Task.__init__cCsH|jtjkr8|jr8|dd}|jr,|j|d<|jj|tjj|dS)Nz%Task was destroyed but it is pending!)taskmessageZsource_traceback) Z_staterZ_PENDING_log_destroy_pendingr*rZcall_exception_handlerFuture__del__)r2contextrrrr8Ss  z Task.__del__cCs tj|S)N)rZ_task_repr_info)r2rrr _repr_info^szTask._repr_info)limitcCs tj||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)r2r;rrr get_stackaszTask.get_stack)r;filecCstj|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)r2r;r=rrr print_stackxs zTask.print_stackcCs4d|_|jrdS|jdk r*|jjr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackdoner,cancelr-)r2rrrr@s  z Task.cancelcs|j stdj|||jr:t|tjs4tj}d|_|j}d|_||j j |j <zy"|dkrn|j d}n |j |}Wntk r}z.|jrd|_|jtjn |j|jWYdd}~Xntjk rtjYn~tk r}z|j|WYdd}~XnPtk rD}z|j|WYdd}~Xn Xt|dd}|dk r|j |j k r|j j|jtdj||n||r||kr|j j|jtdj|n2d|_|j|j||_|jr|jjrd|_n|j j|jtdj||n^|dkr |j j|jnDtj|rJ|j j|jtdj||n|j j|jtdj|Wd|j j j|j d}XdS) Nz!_step(): already done: {!r}, {!r}F_asyncio_future_blockingz6Task {!r} got Future {!r} attached to a different loopz!Task cannot await on itself: {!r}z;yield was used instead of yield from in task {!r} with {!r}zIyield was used instead of yield from for generator in task {!r} with {!r}zTask got bad yield: {!r}) r?r&formatr- isinstancerCancelledErrorr+r,r0rrsendthrow StopIteration set_exception set_resultvaluer(r@ Exception BaseExceptiongetattrr.r/ RuntimeErrorrAadd_done_callback_wakeupinspectZ isgeneratorpop)r2excr3resultZblocking)r0rrr/s            z Task._stepcCsJy |jWn,tk r8}z|j|WYdd}~Xn X|jd}dS)N)rTrKr/)r2futurerSrrrrPs  z Task._wakeup)N)N)N)__name__ __module__ __qualname____doc__weakrefWeakSetr"rr6 classmethodrr#r)rZPY34r8r:r<r>r@r/rP __classcell__rr)r0rrs"     !T)rtimeout return_whenc#stj|stj|r&tdt|j|s2td|tt t fkrNtdj |dkr^t j fddt|D}t|||EdHS)aWait for the Futures and coroutines given by fs to complete. The sequence futures must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = yield from asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. z expect a list of futures, not %sz#Set of coroutines/Futures is empty.zInvalid return_when value: {}Ncsh|]}t|dqS))r)r )rf)rrrr!7szwait..)risfuturerr% TypeErrortyperV ValueErrorrrrrBrrset_wait)fsrr^r_r)rrrscGs|js|jddS)N)r?rI)waiterargsrrr_release_waiter<srj)rccs|dkrtj}|dkr"|EdHS|j}|j|t|}tjt|}t||d}|j|zhy|EdHWn*t j k r|j ||j YnX|j r|jS|j ||j t jWd|j XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. N)r)rr create_future call_laterrj functoolspartialr rOrrDremove_done_callbackr@r?rT TimeoutError)futr^rrhtimeout_handlecbrrrrAs,       c #s|s td|jd|dk r.|j|tt|fdd}x|D]}|j|qNWzEdHWddk rjXtt}}x4|D],}|j||j r|j |q|j |qW||fS)zeInternal helper for wait() and wait_for(). The fs argument must be a collection of Futures. zSet of Futures is empty.Ncs\d8dks6tks6tkrX|j rX|jdk rXdk rFjjsXjddS)Nrr)rr cancelled exceptionr@r?rI)r`)counterr_rrrhrr_on_completion|s z_wait.._on_completion) r&rkrlrjlenrOr@reror?r1)rgr^r_rrwr`r?pendingr)rvr_rrrhrrfos(      rf)rr^c#stj|stj|r&tdt|jdk r2ntjfddt |Dddl m }|ddfdd }fd d t fd d }xD]}|j qWr|dk rʈj||xttD] }|VqWdS)amReturn an iterator whose values are coroutines. When waiting for the yielded coroutines you'll get the results (or exceptions!) of the original Futures (or coroutines), in the order in which and as soon as they complete. This differs from PEP 3148; the proper way to use this is: for f in as_completed(fs): result = yield from f # The 'yield from' may raise. # Use result. If a timeout is specified, the 'yield from' will raise TimeoutError when the timeout occurs before all Futures are done. Note: The futures 'f' are not necessarily members of fs. z expect a list of futures, not %sNcsh|]}t|dqS))r)r )rr`)rrrr!szas_completed..r)Queue)rcs.x D]}|jjdqWjdS)N)ro put_nowaitclear)r`)rwr?todorr _on_timeouts  z!as_completed.._on_timeoutcs6sdSj|j| r2dk r2jdS)N)remover{r@)r`)r?rrr}rrrws   z$as_completed.._on_completionc3s$jEdH}|dkrtj|jS)N)rrrprT)r`)r?rr _wait_for_onesz#as_completed.._wait_for_one)rrarr%rbrcrVrrreZqueuesrzrrOrlrangerx)rgrr^rzr~rr`_r)rwr?rrrr}rrs      c csX|dkrdV|S|dkr"tj}|j}|jj|tj||}z |EdHS|jXdS)z9Coroutine that completes after a given time (in seconds).rN)rrrkrrlrZ_set_result_unless_cancelledr@)ZdelayrTrrUhrrrrs cCstjdtddt||dS)zWrap a coroutine in a future. If the argument is a Future, it is returned directly. This function is deprecated in 3.5. Use asyncio.ensure_future() instead. z;asyncio.async() function is deprecated, use ensure_future()) stacklevel)r)warningswarnDeprecationWarningr )coro_or_futurerrrrasync_srcCstj|r(|dk r$||jk r$td|Stj|r^|dkrBtj}|j|}|j rZ|j d=|St j r~t j |r~tt||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nz$loop argument must agree with Futurer)rz:An asyncio.Future, a coroutine or an awaitable is requiredr$)rrarrdrr%rrZ create_taskr*rZPY35rQZ isawaitabler _wrap_awaitablerb)rrr4rrrr s   ccs|jEdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitablerrrrsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. N)rcstj|d||_d|_dS)N)rF)r(r) _children_cancel_requested)r2childrenr)r0rrr)$sz_GatheringFuture.__init__cCs:|jr dSd}x|jD]}|jrd}qW|r6d|_|S)NFT)r?rr@r)r2ZretZchildrrrr@)s z_GatheringFuture.cancel)rVrWrXrYr)r@r]rr)r0rrsrF)rreturn_exceptionscs|s*|dkrtj}|jjgSixjt|D]^}tj|sht||d}|dkr`|j}d|_ n&|}|dkr||j}n|j|k rt d||<q8Wfdd|D}t |t ||dddgfdd }x&t |D]\}}|jtj||qWS) a7Return a future aggregating results from the given coroutines or futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) N)rFz)futures are tied to different event loopscsg|] }|qSrr)rarg) arg_to_futrr hszgather..rcsjr|js|jdS|jr@tj}slj|dSn,|jdk rf|j}slj|dSn|j}||<d7krjrjtjn j dS)Nr) r?rtrurrDrHZ _exceptionZ_resultrrI)irqres) nchildren nfinishedouterresultsrrr_done_callbackns*   zgather.._done_callback)rrrkrIrerrar rr6rdrxr enumeraterOrmrn)rrZcoros_or_futuresrrqrrrr)rrrrrrrr 8s8       cs@t||d}|jr|S|j}|jfdd}|j|S)a=Wait for a future, shielding it from cancellation. The statement res = yield from shield(something()) is exactly equivalent to the statement res = yield from something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = yield from shield(something()) except CancelledError: res = None )rcs\jr|js|jdS|jr.jn*|j}|dk rJj|nj|jdS)N)rtrur@rHrIrT)innerrS)rrrrs  zshield.._done_callback)r r?rrkrO)rrrrr)rrr s   cs:tjstdtjjfdd}j|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredcsTytjtdWn6tk rN}zjr<j|WYdd}~XnXdS)N)r)rZ _chain_futurer rKZset_running_or_notify_cancelrH)rS)r3rUrrrcallbacks  z*run_coroutine_threadsafe..callback)rr%rb concurrentrr7Zcall_soon_threadsafe)r3rrr)r3rUrrr s    )N)'rY__all__Zconcurrent.futuresrrmrQrrZrrrrrrr7rZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrjrrfrrrglobalsrVr rrr r r rrrrsZ        s  - -8  W5__pycache__/streams.cpython-36.opt-1.pyc000064400000046264152343301150014030 0ustar003 \_@sLdZdddddddgZdd lZeed r6ejd d gd dlmZd dlmZd dlmZd dlm Z d dlm Z d dl m Z d"Z GdddeZGdddeZe d#d e dddZe d$d e dddZeed re d%d e ddd Ze d&d e ddd ZGddde jZGdddee jZGd ddZGd!ddZd S)'zStream-related things. StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverIncompleteReadErrorLimitOverrunErrorNZAF_UNIXopen_unix_connectionstart_unix_server) coroutines)compat)events) protocols) coroutine)loggercs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs(tjdt||f||_||_dS)Nz-%d bytes read on a total of %r expected bytes)super__init__lenpartialexpected)selfrr) __class__'/usr/lib64/python3.6/asyncio/streams.pyr szIncompleteReadError.__init__cCst||j|jffS)N)typerr)rrrr __reduce__&szIncompleteReadError.__reduce__)__name__ __module__ __qualname____doc__rr __classcell__rr)rrrs cs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cstj|||_dS)N)rrconsumed)rmessager$)rrrr0s zLimitOverrunError.__init__cCst||jd|jffS)Nr)rargsr$)rrrrr4szLimitOverrunError.__reduce__)rr r!r"rrr#rr)rrr*s )looplimitc +sb|dkrtj}t||d}t||d|jfdd||f|EdH\}}t|||}||fS)aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N)r(r')r'csS)Nrr)protocolrrQsz!open_connection..)rget_event_looprrZcreate_connectionr) hostportr'r(kwdsreader transport_writerr)r)rr8s   c+s8dkrtjfdd}j|||f|EdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Ncstd}t|d}|S)N)r(r')r')rr)r/r))client_connected_cbr(r'rrfactoryqs zstart_server..factory)rr+Z create_server)r3r,r-r'r(r.r4r)r3r(r'rrVsc+s`|dkrtj}t||d}t||d|jfdd|f|EdH\}}t|||}||fS)z@Similar to `open_connection` but works with UNIX Domain Sockets.N)r(r')r'csS)Nrr)r)rrr*sz&open_unix_connection..)rr+rrZcreate_unix_connectionr)pathr'r(r.r/r0r1r2r)r)rr }s  c+s6dkrtjfdd}j||f|EdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Ncstd}t|d}|S)N)r(r')r')rr)r/r))r3r(r'rrr4s z"start_unix_server..factory)rr+Zcreate_unix_server)r3r5r'r(r.r4r)r3r(r'rr sc@s>eZdZdZd ddZddZddZd d Zed d Z dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_reading() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrtj|_n||_d|_d|_d|_dS)NF)rr+_loop_paused _drain_waiter_connection_lost)rr'rrrrs  zFlowControlMixin.__init__cCs d|_|jjrtjd|dS)NTz%r pauses writing)r8r7 get_debugrdebug)rrrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jjrtjd||j}|dk rBd|_|jsB|jddS)NFz%r resumes writing)r8r7r;rr<r9done set_result)rwaiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|jr4dS|dkrH|jdn |j|dS)NT)r:r8r9r>r? set_exception)rexcr@rrrconnection_losts z FlowControlMixin.connection_lostccs<|jrtd|jsdS|j}|jj}||_|EdHdS)NzConnection lost)r:ConnectionResetErrorr8r9r7 create_future)rr@rrr _drain_helpers zFlowControlMixin._drain_helper)N) rr r!r"rr=rArDrrGrrrrr6s   r6csFeZdZdZd fdd ZddZfddZd d Zd d ZZ S)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncs*tj|d||_d|_||_d|_dS)N)r'F)rr_stream_reader_stream_writer_client_connected_cb _over_ssl)rZ stream_readerr3r')rrrrs zStreamReaderProtocol.__init__cCsd|jj||jddk |_|jdk r`t|||j|j|_|j|j|j}tj |r`|jj |dS)NZ sslcontext) rH set_transportget_extra_inforKrJrr7rIr Z iscoroutineZ create_task)rr0resrrrconnection_mades    z$StreamReaderProtocol.connection_madecsF|jdk r*|dkr|jjn |jj|tj|d|_d|_dS)N)rHfeed_eofrBrrDrI)rrC)rrrrDs    z$StreamReaderProtocol.connection_lostcCs|jj|dS)N)rH feed_data)rdatarrr data_receivedsz"StreamReaderProtocol.data_receivedcCs|jj|jrdSdS)NFT)rHrPrK)rrrr eof_receiveds z!StreamReaderProtocol.eof_received)NN) rr r!r"rrOrDrSrTr#rr)rrrs  c@sjeZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ dddZ eddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs||_||_||_||_dS)N) _transport _protocol_readerr7)rr0r)r/r'rrrrszStreamWriter.__init__cCs:|jjd|jg}|jdk r,|jd|jddj|S)Nz transport=%rz reader=%rz<%s> )rrrUrWappendjoin)rinforrr__repr__!s zStreamWriter.__repr__cCs|jS)N)rU)rrrrr0'szStreamWriter.transportcCs|jj|dS)N)rUwrite)rrRrrrr]+szStreamWriter.writecCs|jj|dS)N)rU writelines)rrRrrrr^.szStreamWriter.writelinescCs |jjS)N)rU write_eof)rrrrr_1szStreamWriter.write_eofcCs |jjS)N)rU can_write_eof)rrrrr`4szStreamWriter.can_write_eofcCs |jjS)N)rUclose)rrrrra7szStreamWriter.closeNcCs|jj||S)N)rUrM)rnamedefaultrrrrM:szStreamWriter.get_extra_infoccsN|jdk r |jj}|dk r ||jdk r:|jjr:dV|jjEdHdS)z~Flush the write buffer. The intended use is to write w.write(data) yield from w.drain() N)rW exceptionrUZ is_closingrVrG)rrCrrrdrain=s    zStreamWriter.drain)N)rr r!r"rr\propertyr0r]r^r_r`rarMrrerrrrrs  c@seZdZedfddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ eddZeddZed'ddZed)ddZed d!Zejred"d#Zed$d%Zejrd&d#ZdS)*rNcCsZ|dkrtd||_|dkr*tj|_n||_t|_d|_d|_d|_ d|_ d|_ dS)NrzLimit cannot be <= 0F) ValueError_limitrr+r7 bytearray_buffer_eof_waiter _exceptionrUr8)rr(r'rrrrXs zStreamReader.__init__cCsdg}|jr |jdt|j|jr0|jd|jtkrJ|jd|j|jr`|jd|j|jrv|jd|j|jr|jd|j|j r|jdd d j |S) Nrz%d byteseofzl=%dzw=%rze=%rzt=%rZpausedz<%s>rX) rjrYrrkrh_DEFAULT_LIMITrlrmrUr8rZ)rr[rrrr\ks    zStreamReader.__repr__cCs|jS)N)rm)rrrrrd}szStreamReader.exceptioncCs0||_|j}|dk r,d|_|js,|j|dS)N)rmrl cancelledrB)rrCr@rrrrBs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|js&|jddS)z1Wakeup read*() functions waiting for data or EOF.N)rlrpr?)rr@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dS)N)rU)rr0rrrrLszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jjdS)NF)r8rrjrhrUresume_reading)rrrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|jdS)NT)rkrq)rrrrrPszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rkrj)rrrrat_eofszStreamReader.at_eofc Csv|sdS|jj||j|jdk rr|j rrt|jd|jkrry|jjWntk rjd|_YnXd|_dS)NrT) rjextendrqrUr8rrhZ pause_readingNotImplementedError)rrRrrrrQs   zStreamReader.feed_datac csV|jdk rtd||jr,d|_|jj|jj|_z|jEdHWdd|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzH%s() called while another coroutine is already waiting for incoming dataF)rl RuntimeErrorr8rUrrr7rF)rZ func_namerrr_wait_for_datas   zStreamReader._wait_for_dataccsd}t|}y|j|EdH}Wntk rB}z|jSd}~Xnftk r}zJ|jj||jrv|jd|j|=n |jj|j t |j dWYdd}~XnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilrrrrj startswithr$clearrsrgr&)rsepseplenlineerrrreadlines  zStreamReader.readlineryccst|}|dkrtd|jdk r(|jd}xt|j}|||kr||jj||}|dkr\P|d|}||jkr|td||jrt|j}|jj t |d|j dEdHq.W||jkrtd||jd||}|jd||=|j t|S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrzz2Separator is found, but chunk is longer than limit) rrgrmrjfindrhrrkbytesr|rrxrs)rZ separatorr~offsetZbuflenZisepchunkrrrrzs:         zStreamReader.readuntilr ccs|jdk r|j|dkrdS|dkrZg}x&|j|jEdH}|sBP|j|q*Wdj|S|j rz|j rz|jdEdHt|jd|}|jd|=|j |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrread) rmrrhrYrZrjrkrxrrs)rnZblocksblockrRrrrrPs$   zStreamReader.readccs|dkrtd|jdk r |j|dkr,dSxFt|j|krr|jr`t|j}|jjt|||jdEdHq.Wt|j|krt|j}|jjnt|jd|}|jd|=|j |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rgrmrrjrkrr|rrxrs)rrZ incompleterRrrrrs&       zStreamReader.readexactlycCs|S)Nr)rrrr __aiter__szStreamReader.__aiter__ccs|jEdH}|dkrt|S)Nr)rStopAsyncIteration)rvalrrr __anext__szStreamReader.__anext__cCs|S)Nr)rrrrrs)ryr)r)rr r!rorr\rdrBrqrLrsrPrtrQrrxrrzrrr ZPY35rrZPY352rrrrrVs,    [ 2 *  i)NN)NN)N)N)r"__all__Zsockethasattrrur r rrrlogrroEOFErrorr Exceptionrrrr r ZProtocolr6rrrrrrrsB       "  B3G__pycache__/base_futures.cpython-36.pyc000064400000004001152343301150014061 0ustar003 \@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@seZdZdZdS)InvalidStateErrorz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__r r ,/usr/lib64/python3.6/asyncio/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r )objr r r isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) z#helper function for Future.__repr__cSs tj|fS)N)rZ_format_callback_source)callbackr r r format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerr r r _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)z#helper function for Future.__repr__Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframer r r _future_repr_info6s     r")__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr"r r r r s   __pycache__/windows_utils.cpython-36.opt-2.pyc000064400000011145152343301150015253 0ustar003 \@sddlZejdkredddlZddlZddlZddlZddlZddlZddl Z ddl Z dddddgZ d Z ej Z ejZejZeedrejZnejejdfd dZd de d ddZGdddZGdddejZdS)NZwin32z win32 only socketpairpipePopenPIPE PipeHandlei c Cs|tjkrd}n|tjkr d}ntd|tjkr:td|dkrJtdtj|||}z|j|df|jd|jdd\}}tj|||}yP|jd y|j ||fWnt t fk rYnX|jd |j \}} Wn|j YnXWd|j X||fS) Nz 127.0.0.1z::1z?Only AF_INET and AF_INET6 socket address families are supportedz)Only SOCK_STREAM socket type is supportedrzOnly protocol zero is supportedFT)socketAF_INETZAF_INET6 ValueError SOCK_STREAMZbindZlistenZ getsocknameZ setblockingZconnectBlockingIOErrorInterruptedErrorZacceptclose) ZfamilytypeprotohostZlsockZaddrZportZcsockZssock_r-/usr/lib64/python3.6/asyncio/windows_utils.pyr%s8        FT)duplex overlappedbufsizec Cs"tjdtjttfd}|r>tj}tjtj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } yZtj ||tjd||tjtj} tj||dtjtj|tj} tj| dd} | jd| | fS| dk rtj| | dk rtj| YnXdS)Nz\\.\pipe\python-pipe-%d-%d-)prefixrrT)r)tempfileZmktemposgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2ZovrrrrSs@           c@sXeZdZddZddZeddZddZej d d d Z d d Z ddZ ddZ dS)rcCs ||_dS)N)_handle)selfhandlerrr__init__szPipeHandle.__init__cCs*|jdk rd|j}nd}d|jj|fS)Nz handle=%rclosedz<%s %s>)r" __class____name__)r#r$rrr__repr__s  zPipeHandle.__repr__cCs|jS)N)r")r#rrrr$szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operatioon on closed pipe)r"r )r#rrrfilenos zPipeHandle.fileno)r cCs|jdk r||jd|_dS)N)r")r#r rrrrs  zPipeHandle.closecCs*|jdk r&tjd|t|d|jdS)Nz unclosed %r)source)r"warningswarnResourceWarningr)r#rrr__del__s  zPipeHandle.__del__cCs|S)Nr)r#rrr __enter__szPipeHandle.__enter__cCs |jdS)N)r)r#tvtbrrr__exit__szPipeHandle.__exit__N)r( __module__ __qualname__r%r)propertyr$r*rr rr/r0r4rrrrrs cseZdZdfdd ZZS)rNc s|d}}}d} } } |tkr@tddd\} } tj| tj}n|}|tkrhtdd\} } tj| d}n|}|tkrtd d\} }tj|d}n|tkr|}n|}zy tj|f|||d|Wn4x$| | | fD]}|dk rt j |qWYn>X| dk rt | |_ | dk r"t | |_ | dk r6t | |_Wd|tkrNtj||tkrbtj||tkrvtj|XdS) NFT)rr)rr)stdinstdoutstderr)FT)TF)TF)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTsuperr%rr rr8r9r:r)r#argsr8r9r:kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whh)r'rrr%sH            zPopen.__init__)NNN)r(r5r6r% __classcell__rr)r'rrs)TT)sysplatform ImportErrorr itertoolsr;rr subprocessrr,__all__ZBUFSIZErr=countrhasattrrr r rrrrrrrs*  .0-__pycache__/protocols.cpython-36.opt-1.pyc000064400000013533152343301150014367 0ustar003 \@sRdZddddgZGdddZGdddeZGdddeZGdddeZd S) zAbstract Protocol class. BaseProtocolProtocolDatagramProtocolSubprocessProtocolc@s0eZdZdZddZddZddZdd Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. N)selfZ transportrr)/usr/lib64/python3.6/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nr)rexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nr)rrrr pause_writing!szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nr)rrrrresume_writing7szBaseProtocol.resume_writingN)__name__ __module__ __qualname____doc__rr r r rrrrrs c@s eZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() cCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_receivedXszProtocol.data_receivedcCsdS)zCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nr)rrrr eof_received^szProtocol.eof_receivedN)r rrrrrrrrrr>sc@s eZdZdZddZddZdS)rz Interface for datagram protocol.cCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedjsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nr)rr rrrerror_receivedmszDatagramProtocol.error_receivedN)r rrrrrrrrrrgsc@s(eZdZdZddZddZddZdS) rz,Interface for protocol for subprocess calls.cCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedwsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lost~sz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nr)rrrrprocess_exitedsz!SubprocessProtocol.process_exitedN)r rrrrrrrrrrrtsN)r__all__rrrrrrrrs 7) __pycache__/test_utils.cpython-36.opt-2.pyc000064400000037533152343301150014551 0ustar003 \: @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddl mZddlmZddlmZmZy ddlZWnek rdZYnXddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"ej#dkrDddl$m%Z%n ddlm%Z%ddZ&e&dZ'e&dZ(ddZ)ddZ*dQddZ+ddZ,GdddeZ-Gd d!d!eZ.Gd"d#d#Z/Gd$d%d%e/e.Z0d&d'd(d)Z1e2ed*rVGd+d,d,ej3eZ4Gd-d.d.e4eZ5Gd/d0d0e5Z6Gd1d2d2e/e6Z7d3d4Z8ej9d5d6Z:ej9d&d'd7d8Z;ej9d9dd&d:d;d<ZZ=Gd?d@d@ej>Z?GdAdBdBej@ZAdCdDZBGdEdFdFeCZDdGdHZEGdIdJdJe jFZFej9dKdLZGejHejIejJfdMdNZKdOdPZLdS)RN)mock) HTTPServer)WSGIRequestHandler WSGIServer) base_events)compat)events)futures) selectors)tasks) coroutine)logger)supportZwin32) socketpaircCs`ttdr*tjjtj|}tjj|r*|Stjjtjjtjd|}tjj|rT|St |dS)N TEST_HOME_DIRtest) hasattrrospathjoinrisfiledirname__file__FileNotFoundError)filenamefullnamer*/usr/lib64/python3.6/asyncio/test_utils.py data_file-s   rz ssl_cert.pemz ssl_key.pemcCstdkr dStjtjSdS)N)ssl SSLContextZPROTOCOL_SSLv23rrrrdummy_ssl_context<sr"c Cs@tdd}|}|j|}d|_z|j|Wd|jXdS)NcSsdS)NrrrrronceDszrun_briefly..onceF)r Z create_taskZ_log_destroy_pendingrun_until_completeclose)loopr#gentrrr run_brieflyCs  r)cCsTtj|}xB|sN|dk r8|tj}|dkr8tj|jtjd|dqWdS)NrgMbP?)r&)timer TimeoutErrorr$r Zsleep)r&ZpredtimeoutZdeadlinerrr run_untilRs  r.cCs|j|j|jdS)N)Z call_soonstopZ run_forever)r&rrrrun_once\s r0c@seZdZddZddZdS)SilentWSGIRequestHandlercCstjS)N)ioStringIO)selfrrr get_stderrisz#SilentWSGIRequestHandler.get_stderrcGsdS)Nr)r4formatargsrrr log_messagelsz$SilentWSGIRequestHandler.log_messageN)__name__ __module__ __qualname__r5r8rrrrr1gsr1cs(eZdZdZfddZddZZS)SilentWSGIServercs"tj\}}|j|j||fS)N)super get_request settimeoutrequest_timeout)r4request client_addr) __class__rrr?ts zSilentWSGIServer.get_requestcCsdS)Nr)r4rBclient_addressrrr handle_erroryszSilentWSGIServer.handle_error)r9r:r;rAr?rF __classcell__rr)rDrr<ps r<c@seZdZddZdS)SSLWSGIServerMixinc Cs^t}t}tj}|j|||j|dd}y|j||||jWntk rXYnXdS)NT)Z server_side) ONLYKEYONLYCERTr r!Zload_cert_chainZ wrap_socketZRequestHandlerClassr%OSError)r4rBrEZkeyfileZcertfilecontextZssockrrrfinish_requests  z!SSLWSGIServerMixin.finish_requestN)r9r:r;rMrrrrrH}srHc@s eZdZdS) SSLWSGIServerN)r9r:r;rrrrrNsrNF)use_sslc #svdd}|r|n|}||tj|j_tjfddd}|jz VWdjj|j XdS)NcSsd}dg}|||dgS)Nz200 OK Content-type text/plains Test message)rPrQr)environZstart_responseZstatusZheadersrrrapps z_run_test_server..appcs jddS)Ng?)Z poll_interval)Z serve_foreverr)httpdrrsz"_run_test_server..)target) r1Zset_appZserver_addressaddress threadingZThreadstartshutdownZ server_closer)rWrO server_clsserver_ssl_clsrSZ server_classZ server_threadr)rTr_run_test_servers    r]ZAF_UNIXc@seZdZddZdS)UnixHTTPServercCstjj|d|_d|_dS)Nz 127.0.0.1P) socketserverUnixStreamServer server_bindZ server_nameZ server_port)r4rrrrbs zUnixHTTPServer.server_bindN)r9r:r;rbrrrrr^sr^cs(eZdZdZddZfddZZS)UnixWSGIServerr=cCstj||jdS)N)r^rbZ setup_environ)r4rrrrbs zUnixWSGIServer.server_bindcs"tj\}}|j|j|dfS)N 127.0.0.1)rdre)r>r?r@rA)r4rBrC)rDrrr?s zUnixWSGIServer.get_request)r9r:r;rArbr?rGrr)rDrrcsrcc@seZdZddZdS)SilentUnixWSGIServercCsdS)Nr)r4rBrErrrrFsz!SilentUnixWSGIServer.handle_errorN)r9r:r;rFrrrrrfsrfc@s eZdZdS)UnixSSLWSGIServerN)r9r:r;rrrrrgsrgc Cstj}|jSQRXdS)N)tempfileZNamedTemporaryFilename)filerrrgen_unix_socket_paths rkccs<t}z |VWdytj|Wntk r4YnXXdS)N)rkrunlinkrK)rrrrunix_socket_paths rmc cs,t}t||ttdEdHWdQRXdS)N)rWrOr[r\)rmr]rfrg)rOrrrrrun_test_unix_serversrnz 127.0.0.1)hostportrOccst||f|ttdEdHdS)N)rWrOr[r\)r]r<rN)rorprOrrrrun_test_servers rqcCsPi}x4t|D](}|jdr(|jdr(qtdd||<qWtd|f|j|S)N__) return_valueZ TestProtocol)dir startswithendswith MockCallbacktype __bases__)baseZdctrirrrmake_test_protocols r{c@s6eZdZddZd ddZddZdd Zd d ZdS) TestSelectorcCs i|_dS)N)keys)r4rrr__init__szTestSelector.__init__NcCstj|d||}||j|<|S)Nr)r Z SelectorKeyr})r4fileobjr datakeyrrrregisters zTestSelector.registercCs |jj|S)N)r}pop)r4rrrr unregister szTestSelector.unregistercCsgS)Nr)r4r-rrrselectszTestSelector.selectcCs|jS)N)r})r4rrrget_mapszTestSelector.get_map)N)r9r:r;r~rrrrrrrrr|s  r|cseZdZd,fdd ZddZddZfdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZd d!Zd"d#Zfd$d%Zfd&d'Zd(d)Zd*d+ZZS)-TestLoopNcsvtj|dkr"dd}d|_nd|_||_t|jd|_d|_g|_t|_ i|_ i|_ |j t j|_dS)Ncss dVdS)Nrrrrrr',szTestLoop.__init__..genFTrg& .>)r>r~_check_on_close_gennext_timeZ_clock_resolution_timersr|Z _selectorreaderswritersreset_countersweakrefWeakValueDictionary _transports)r4r')rDrrr~(s  zTestLoop.__init__cCs|jS)N)r)r4rrrr+?sz TestLoop.timecCs|r|j|7_dS)N)r)r4advancerrr advance_timeBszTestLoop.advance_timec sBtj|jr>y|jjdWntk r4Yn XtddS)NrzTime generator is not finished)r>r%rrsend StopIterationAssertionError)r4)rDrrr%Gs zTestLoop.closecGstj||||j|<dS)N)r Handler)r4fdcallbackr7rrr _add_readerQszTestLoop._add_readercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_reader_countr)r4rrrr_remove_readerTs  zTestLoop._remove_readercGsh||jkrtd|d|j|}|j|krDtd|jd||j|krdtd|jd|dS)Nzfd z is not registeredzunexpected callback: z != zunexpected callback args: )rrZ _callbackZ_args)r4rrr7handlerrr assert_reader\s    zTestLoop.assert_readercCs||jkrtd|ddS)Nzfd z is registered)rr)r4rrrrassert_no_readergs zTestLoop.assert_no_readercGstj||||j|<dS)N)r rr)r4rrr7rrr _add_writerkszTestLoop._add_writercCs0|j|d7<||jkr(|j|=dSdSdS)NrTF)remove_writer_countr)r4rrrr_remove_writerns  zTestLoop._remove_writercGs|j|}dS)N)r)r4rrr7rrrr assert_writervs zTestLoop.assert_writerc Cs8y|j|}Wntk r"YnXtdj||dS)Nz.File descriptor {!r} is used by transport {!r})rKeyError RuntimeErrorr6)r4rZ transportrrr_ensure_fd_no_transport~sz TestLoop._ensure_fd_no_transportcGs|j||j||f|S)N)rr)r4rrr7rrr add_readers zTestLoop.add_readercCs|j||j|S)N)rr)r4rrrr remove_readers zTestLoop.remove_readercGs|j||j||f|S)N)rr)r4rrr7rrr add_writers zTestLoop.add_writercCs|j||j|S)N)rr)r4rrrr remove_writers zTestLoop.remove_writercCstjt|_tjt|_dS)N) collections defaultdictintrr)r4rrrrs zTestLoop.reset_counterscs:tjx$|jD]}|jj|}|j|qWg|_dS)N)r> _run_oncerrrr)r4whenr)rDrrrs    zTestLoop._run_oncecs |jj|tj||f|S)N)rappendr>call_at)r4rrr7)rDrrrs zTestLoop.call_atcCsdS)Nr)r4Z event_listrrr_process_eventsszTestLoop._process_eventscCsdS)Nr)r4rrr_write_to_selfszTestLoop._write_to_self)N)r9r:r;r~r+rr%rrrrrrrrrrrrrrrrrrGrr)rDrrs*     rcKstjfddgi|S)Nspec__call__)rZMock)kwargsrrrrwsrwc@seZdZddZdS) MockPatterncCsttjt||tjS)N)boolresearchstrS)r4otherrrr__eq__szMockPattern.__eq__N)r9r:r;rrrrrrs rcCs$tj|}|dkr td|f|S)Nzunable to get the source of %r)r Z_get_function_source ValueError)funcsourcerrrget_function_sources rc@sVeZdZeddZddddZddd Zd d Zd d ZddZ e j sRddZ dS)TestCasecCs&|j}|dk r|jdd|jdS)NT)wait)Z_default_executorrZr%)r&Zexecutorrrr close_loops zTestCase.close_loopT)cleanupcCs tjd|r|j|j|dS)N)r set_event_loopZ addCleanupr)r4r&rrrrrs zTestCase.set_event_loopNcCst|}|j||S)N)rr)r4r'r&rrr new_test_loops zTestCase.new_test_loopcCs |jt_dS)N)_get_running_loopr )r4rrrunpatch_get_running_loopsz!TestCase.unpatch_get_running_loopcCs tj|_ddt_tj|_dS)NcSsdS)NrrrrrrUsz TestCase.setUp..)r rrZthreading_setup_thread_cleanup)r4rrrsetUps zTestCase.setUpcCsB|jtjd|jtjd|jtj|j tj dS)N)NNN) rr rZ assertEqualsysexc_infoZ doCleanupsrZthreading_cleanuprZ reap_children)r4rrrtearDowns   zTestCase.tearDowncOsGddd}|S)Nc@seZdZddZddZdS)z!TestCase.subTest..EmptyCMcSsdS)Nr)r4rrr __enter__sz+TestCase.subTest..EmptyCM.__enter__cWsdS)Nr)r4excrrr__exit__sz*TestCase.subTest..EmptyCM.__exit__N)r9r:r;rrrrrrEmptyCMsrr)r4r7rrrrrsubTestszTestCase.subTest)N) r9r:r; staticmethodrrrrrrrZPY34rrrrrrs   rc cs2tj}ztjtjddVWdtj|XdS)Nr)rlevelZsetLevelloggingZCRITICAL)Z old_levelrrrdisable_loggers  rcCs*tjtj}||_||_||_d|j_|S)Ng)rZ MagicMocksocketprotorxfamilyZ gettimeoutrs)rrxrZsockrrrmock_nonblocking_socket s  rcCstjdddS)Nz'asyncio.sslproto._is_sslproto_availableF)rs)rZpatchrrrrforce_legacy_ssl_supportsr)r*)Mr contextlibr2rrrrr`rrhrXr+ZunittestrrZ http.serverrZwsgiref.simple_serverrrr ImportErrorrerrr r r r Z coroutinesr logrrrplatformZ windows_utilsrrrJrIr"r)r.r0r1r<rHrNr]rrar^rcrfrgrkcontextmanagerrmrnrqr{Z BaseSelectorr|Z BaseEventLooprrwrrrrrZ IPPROTO_TCPZ SOCK_STREAMZAF_INETrrrrrrs                        4 __pycache__/base_subprocess.cpython-36.pyc000064400000022060152343301150014561 0ustar003 \#@sddlZddlZddlZddlmZddlmZddlmZddlmZddl m Z Gdd d ej Z Gd d d ej ZGd d d eejZdS)N)compat) protocols) transports) coroutine)loggercseZdZd0fdd ZddZddZdd Zd d Zd d ZddZ e j rTddZ ddZ ddZddZddZddZddZddZed d!Zd"d#Zd$d%Zd&d'Zd(d)Zed*d+Zd,d-Zd.d/ZZS)1BaseSubprocessTransportNc  s&tj| d|_||_||_d|_d|_d|_g|_t j |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<y"|jf||||||d| Wn|jYnX|jj|_|j|jd<|jjrt|ttfr|} n|d} tjd| |j|jj|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) selfloopprotocolr r r r rrwaiterZextrakwargsZprogram) __class__//usr/lib64/python3.6/asyncio/base_subprocess.pyrs@            z BaseSubprocessTransport.__init__cCs |jjg}|jr|jd|jdk r4|jd|j|jdk rP|jd|jn |jdk rf|jdn |jd|jjd}|dk r|jd|j|jjd}|jjd }|dk r||kr|jd |jn0|dk r|jd |j|dk r|jd |jd dj |S)Nclosedzpid=%sz returncode=%sZrunningz not startedrzstdin=%srr zstdout=stderr=%sz stdout=%sz stderr=%sz<%s> ) r.__name__rappendrrrgetpipejoin)r)infor r rr/r/r0__repr__9s,          z BaseSubprocessTransport.__repr__cKstdS)N)NotImplementedError)r)r r r r rrr-r/r/r0r VszBaseSubprocessTransport._startcCs ||_dS)N)r)r)r+r/r/r0 set_protocolYsz$BaseSubprocessTransport.set_protocolcCs|jS)N)r)r)r/r/r0 get_protocol\sz$BaseSubprocessTransport.get_protocolcCs|jS)N)r)r)r/r/r0 is_closing_sz"BaseSubprocessTransport.is_closingc Cs|jr dSd|_x&|jjD]}|dkr*q|jjqW|jdk r|jdkr|jjdkr|jj rpt j d|y|jj Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr6r!rrZpollrr#rZwarningkillProcessLookupError)r)protor/r/r0r!bs     zBaseSubprocessTransport.closecCs&|js"tjd|t|d|jdS)Nzunclosed transport %r)source)rwarningswarnResourceWarningr!)r)r/r/r0__del__s zBaseSubprocessTransport.__del__cCs|jS)N)r)r)r/r/r0get_pidszBaseSubprocessTransport.get_pidcCs|jS)N)r)r)r/r/r0get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdS)N)rr6)r)fdr/r/r0get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdS)N)rr@)r)r/r/r0 _check_procs z#BaseSubprocessTransport._check_proccCs|j|jj|dS)N)rKr send_signal)r)signalr/r/r0rLsz#BaseSubprocessTransport.send_signalcCs|j|jjdS)N)rKr terminate)r)r/r/r0rNsz!BaseSubprocessTransport.terminatecCs|j|jjdS)N)rKrr?)r)r/r/r0r?szBaseSubprocessTransport.killc #s^yj}j}|jdk rB|jfdd|jEdH\}}|jd<|jdk rv|jfdd|jEdH\}}|jd<|jdk r|jfdd|jEdH\}}|jd<jdk st |j j j x"jD]\}}|j |f|qWd_WnDt k r8}z&|dk r(|j r(|j|WYdd}~Xn"X|dk rZ|j rZ|jddS)Ncs tdS)Nr)WriteSubprocessPipeProtor/)r)r/r0sz8BaseSubprocessTransport._connect_pipes..rcs tdS)Nr)ReadSubprocessPipeProtor/)r)r/r0rPsrcs tdS)Nr )rQr/)r)r/r0rPsr )rrr Zconnect_write_piperr Zconnect_read_piperrAssertionError call_soonrconnection_made Exception cancelledZ set_exception set_result) r)r,procr*_r6callbackdataexcr/)r)r0r(s8          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|jj||fn|jj|f|dS)N)rr4rrS)r)cbr[r/r/r0_calls zBaseSubprocessTransport._callcCs|j|jj|||jdS)N)r^rZpipe_connection_lost _try_finish)r)rIr\r/r/r0_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs|j|jj||dS)N)r^rZpipe_data_received)r)rIr[r/r/r0_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|dk st||jdks$t|j|jjrsz6BaseSubprocessTransport._try_finish..T)rrRrallrr>r^_call_connection_lost)r)r/r/r0r_s  z#BaseSubprocessTransport._try_finishc Cs*z|jj|Wdd|_d|_d|_XdS)N)rconnection_lostrr)r)r\r/r/r0rjs z-BaseSubprocessTransport._call_connection_lost)NN)r3 __module__ __qualname__rr9r r;r<r=r!rZPY34rFrGrHrJrKrLrNr?rr(r^r`rarcrdr_rj __classcell__r/r/)r.r0r s0) %  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rOcCs||_||_d|_d|_dS)NF)rXrIr6re)r)rXrIr/r/r0rsz!WriteSubprocessPipeProto.__init__cCs ||_dS)N)r6)r)Z transportr/r/r0rTsz(WriteSubprocessPipeProto.connection_madecCsd|jj|j|jfS)Nz<%s fd=%s pipe=%r>)r.r3rIr6)r)r/r/r0r9sz!WriteSubprocessPipeProto.__repr__cCs d|_|jj|j|d|_dS)NT)rerXr`rI)r)r\r/r/r0rksz(WriteSubprocessPipeProto.connection_lostcCs|jjjdS)N)rXr pause_writing)r)r/r/r0rosz&WriteSubprocessPipeProto.pause_writingcCs|jjjdS)N)rXrresume_writing)r)r/r/r0rpsz'WriteSubprocessPipeProto.resume_writingN) r3rlrmrrTr9rkrorpr/r/r/r0rOs rOc@seZdZddZdS)rQcCs|jj|j|dS)N)rXrarI)r)r[r/r/r0 data_received$sz%ReadSubprocessPipeProto.data_receivedN)r3rlrmrqr/r/r/r0rQ!srQ)rrrCrrrZ coroutinesrlogrZSubprocessTransportrZ BaseProtocolrOZProtocolrQr/r/r/r0s     { __pycache__/subprocess.cpython-36.opt-1.pyc000064400000015214152343301150014531 0ustar003 \@sddgZddlZddlmZddlmZddlmZddlmZdd lmZdd l m Z ej Z ej Z ej Z Gd d d ejejZGd ddZeddddejfddZeddddejdddZdS)create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks) coroutine)loggercsPeZdZdZfddZddZddZdd Zd d Zd d Z ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.cs<tj|d||_d|_|_|_d|_d|_g|_dS)N)loopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds)selflimitr ) __class__*/usr/lib64/python3.6/asyncio/subprocess.pyrs z!SubprocessStreamProtocol.__init__cCsf|jjg}|jdk r$|jd|j|jdk r>|jd|j|jdk rX|jd|jddj|S)Nzstdin=%rz stdout=%rz stderr=%rz<%s> )r__name__rappendrrjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|jd}|dk rDtj|j|jd|_|jj||jj d|jd}|dk rtj|j|jd|_ |j j||jj d|jd}|dk rtj ||d|jd|_ dS)Nr)rr r)protocolreaderr ) rget_pipe_transportr StreamReaderr_looprZ set_transportrrr StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made(s&         z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6|j|dS)Nrr!)rrZ feed_data)rfddatar#rrrpipe_data_received@sz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkr,|j}|dk r|j|j|dS|dkr<|j}n|dkrL|j}nd}|dkrt|dkrj|jn |j|||jkr|jj||j dS)Nrrr!) rcloseZconnection_lostrrZfeed_eofZ set_exceptionrremove_maybe_close_transport)rr*excpiper#rrrpipe_connection_lostJs$     z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|jdS)NT)rr/)rrrrprocess_exitedasz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jjd|_dS)Nr)lenrrrr-)rrrrr/es z/SubprocessStreamProtocol._maybe_close_transport) r __module__ __qualname____doc__rr r)r,r2r3r/ __classcell__rr)rrr s   r c@s~eZdZddZddZeddZeddZd d Z d d Z d dZ eddZ eddZ eddZedddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_|j|_dS)N)rZ _protocolr&rrrZget_pidpid)rr(r"r rrrrlszProcess.__init__cCsd|jj|jfS)Nz<%s %s>)rrr:)rrrrr uszProcess.__repr__cCs |jjS)N)rZget_returncode)rrrr returncodexszProcess.returncodeccs|jjEdHS)zdWait until the process exit and return the process return code. This method is a coroutine.N)rZ_wait)rrrrwait|sz Process.waitcCs|jj|dS)N)r send_signal)rsignalrrrr=szProcess.send_signalcCs|jjdS)N)r terminate)rrrrr?szProcess.terminatecCs|jjdS)N)rkill)rrrrr@sz Process.killccs|jj}|jj||r,tjd|t|y|jjEdHWn8tt fk rx}z|rhtjd||WYdd}~XnX|rtjd||jj dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r& get_debugrwriter debugr4ZdrainBrokenPipeErrorConnectionResetErrorr-)rinputrCr0rrr _feed_stdins     zProcess._feed_stdincCsdS)Nr)rrrr_noopsz Process._noopccs|jj|}|dkr|j}n|j}|jjrJ|dkr8dnd}tjd|||jEdH}|jjr|dkrndnd}tjd|||j |S)Nr!rrrz%r communicate: read %sz%r communicate: close %s) rr$rrr&rAr rCreadr-)rr*r(streamnameoutputrrr _read_streams   zProcess._read_streamNccs|dk r|j|}n|j}|jdk r2|jd}n|j}|jdk rP|jd}n|j}tj||||jdEdH\}}}|jEdH||fS)Nrr!)r ) rGrHrrMrrZgatherr&r<)rrFrrrrrr communicates      zProcess.communicate)N)rr5r6rr propertyr;r r<r=r?r@rGrHrMrNrrrrr9ks      r9c +sPdkrtjfdd}j||f|||d|EdH\}} t|| S)Ncs tdS)N)rr )r r)rr rrsz)create_subprocess_shell..)rrr)rget_event_loopZsubprocess_shellr9) cmdrrrr rkwdsprotocol_factoryr(r"r)rr rrs)rrrr rc /sTdkrtjfdd}j||f||||d|EdH\} } t| | S)Ncs tdS)N)rr )r r)rr rrrPsz(create_subprocess_exec..)rrr)rrQZsubprocess_execr9) Zprogramrrrr rargsrSrTr(r"r)rr rrs)__all__ subprocessrrrrZ coroutinesr logr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r9Z_DEFAULT_LIMITrrrrrrs(      X] __pycache__/base_futures.cpython-36.opt-1.pyc000064400000004001152343301150015020 0ustar003 \@srgZddlZddlZddlmZejjjZejj Z ejj Z GdddeZ dZ dZ dZd d Zd d Zd dZdS)N)eventsc@seZdZdZdS)InvalidStateErrorz+The operation is not allowed in this state.N)__name__ __module__ __qualname____doc__r r ,/usr/lib64/python3.6/asyncio/base_futures.pyr srZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r )objr r r isfutures rcCst|}|sd}dd}|dkr.||d}nP|dkrTdj||d||d}n*|dkr~dj||d|d||d }d |S) z#helper function for Future.__repr__cSs tj|fS)N)rZ_format_callback_source)callbackr r r format_cb(sz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[%s])lenformat)cbsizerr r r _format_callbacks"srcCs|jjg}|jtkrP|jdk r4|jdj|jntj|j}|jdj||j rf|jt |j |j r|j d}|jd|d|df|S)z#helper function for Future.__repr__Nzexception={!r}z result={}rzcreated at %s:%srr) Z_statelower _FINISHEDZ _exceptionappendrreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinforesultframer r r _future_repr_info6s     r")__all__Zconcurrent.futures._baseZ concurrentrrrZfuturesZ_baseErrorZCancelledError TimeoutErrorrZ_PENDINGZ _CANCELLEDrrrr"r r r r s   __pycache__/events.cpython-36.opt-1.pyc000064400000061220152343301150013643 0ustar003 \[@sdZddddddddd d d d d dgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddZddZd3ddZddZd4ddZGdddZGd ddeZGd!ddZGd"ddZGd#ddZGd$d%d%eZdae jZGd&d'd'e jZeZd(dZd)d Z d*d+Z!d,dZ"d-dZ#d.dZ$d/d Z%d0d Z&d1d Z'd2d Z(dS)5z!Event loop and event loop policy.AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loop_get_running_loopN)compat) constantscCsttjrtj|}nt|dr"|j}tj|r>|j}|j|j fSt |t j rTt |jStjrpt |t jrpt |jSdS)N __wrapped__)rZPY34inspectZunwraphasattrrZ isfunction__code__ co_filenameco_firstlineno isinstance functoolspartial_get_function_sourcefunc partialmethod)rcoder &/usr/lib64/python3.6/asyncio/events.pyrs       rcCsJg}|r|jdd|D|r8|jdd|jDddj|dS)zFormat function arguments and keyword arguments. Special case for a single parameter: ('hello',) is formatted as ('hello'). css|]}tj|VqdS)N)reprlibrepr).0argr r r! 1sz*_format_args_and_kwargs..css$|]\}}dj|tj|VqdS)z{}={}N)formatr"r#)r$kvr r r!r&3s(z, ))extenditemsjoin)argskwargsr-r r r!_format_args_and_kwargs)s r1cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) rrrr1_format_callbackrr/keywordsrr3r4r#)rr/r0suffix func_reprr r r!r58s r5cCs(t||d}t|}|r$|d|7}|S)Nz at %s:%s)r5r)rr/r8sourcer r r!_format_callback_sourceIs   r:cCsD|dkrtjj}|dkr tj}tjjtj||dd}|j |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr;stackr r r! extract_stackQs rGc@s<eZdZdZdZd d Zd d Zd dZddZddZ dS)rz1Object returned by callback registration methods. _callback_args _cancelled_loop_source_traceback_repr __weakref__cCsD||_||_||_d|_d|_|jjr:ttjd|_ nd|_ dS)NFr) rKrHrIrJrM get_debugrGr=r>rL)selfcallbackr/loopr r r!__init__hs zHandle.__init__cCsf|jjg}|jr|jd|jdk r8|jt|j|j|jrb|jd}|jd|d|df|S)NZ cancelledrzcreated at %s:%sr) __class__r4rJappendrHr:rIrL)rPinfoframer r r! _repr_infoss    zHandle._repr_infocCs&|jdk r|jS|j}ddj|S)Nz<%s> )rMrYr.)rPrWr r r!__repr__~s zHandle.__repr__cCs0|js,d|_|jjr t||_d|_d|_dS)NT)rJrKrOr#rMrHrI)rPr r r!cancels   z Handle.cancelcCs|y|j|jWnbtk rr}zFt|j|j}dj|}|||d}|jrV|j|d<|jj|WYdd}~XnXd}dS)NzException in callback {})messageZ exceptionhandleZsource_traceback)rHrI Exceptionr:r'rLrKcall_exception_handler)rPexccbmsgcontextr r r!_runs  z Handle._runN)rHrIrJrKrLrMrN) r4 __module__r3__doc__ __slots__rSrYr[r\rer r r r!rbs   csxeZdZdZddgZfddZfddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ fddZZS)rz7Object returned by timed callback registration methods. _scheduled_whencs.tj||||jr|jd=||_d|_dS)NrFrT)superrSrLrjri)rPwhenrQr/rR)rUr r!rSs zTimerHandle.__init__cs.tj}|jrdnd}|j|d|j|S)Nrzwhen=%s)rkrYrJinsertrj)rPrWpos)rUr r!rYs zTimerHandle._repr_infocCs t|jS)N)hashrj)rPr r r!__hash__szTimerHandle.__hash__cCs |j|jkS)N)rj)rPotherr r r!__lt__szTimerHandle.__lt__cCs|j|jkrdS|j|S)NT)rj__eq__)rPrrr r r!__le__s zTimerHandle.__le__cCs |j|jkS)N)rj)rPrrr r r!__gt__szTimerHandle.__gt__cCs|j|jkrdS|j|S)NT)rjrt)rPrrr r r!__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStS)N)rrrjrHrIrJNotImplemented)rPrrr r r!rts      zTimerHandle.__eq__cCs|j|}|tkrtS| S)N)rtrx)rPrrZequalr r r!__ne__s zTimerHandle.__ne__cs |js|jj|tjdS)N)rJrK_timer_handle_cancelledrkr\)rP)rUr r!r\s zTimerHandle.cancel)r4rfr3rgrhrSrYrqrsrurvrwrtryr\ __classcell__r r )rUr!rs  c@s eZdZdZddZddZdS)rz,Abstract server returned by create_server().cCstS)z5Stop serving. This leaves existing connections open.)rx)rPr r r!closeszAbstractServer.closecCstS)z*Coroutine to wait until service is closed.)rx)rPr r r! wait_closedszAbstractServer.wait_closedN)r4rfr3rgr|r}r r r r!rsc @seZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddZddZd d!Zd"d#Zd$d$d$d$d%d&d'Zdhd(d)Zdid*d$d$d$d*d*d*d+d,d-Zdjejejd*d.d*d*d*d/d0d1Zd*d*d*d2d3d4Zd*d.d*d5d6d7Zdkd$d$d$d*d*d*d*d8d9d:Zd;d<Zd=d>Z e!j"e!j"e!j"d?d@dAZ#e!j"e!j"e!j"d?dBdCZ$dDdEZ%dFdGZ&dHdIZ'dJdKZ(dLdMZ)dNdOZ*dPdQZ+dRdSZ,dTdUZ-dVdWZ.dXdYZ/dZd[Z0d\d]Z1d^d_Z2d`daZ3dbdcZ4dddeZ5dfdgZ6d*S)lrzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.N)NotImplementedError)rPr r r! run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. N)r~)rPZfuturer r r!run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. N)r~)rPr r r!stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.N)r~)rPr r r! is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.N)r~)rPr r r! is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. N)r~)rPr r r!r|s zAbstractEventLoop.closecCstdS)z,Shutdown all active asynchronous generators.N)r~)rPr r r!shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.N)r~)rPr^r r r!rzsz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_later)rPrQr/r r r! call_soonszAbstractEventLoop.call_sooncGstdS)N)r~)rPZdelayrQr/r r r!rszAbstractEventLoop.call_latercGstdS)N)r~)rPrlrQr/r r r!call_atszAbstractEventLoop.call_atcCstdS)N)r~)rPr r r!time"szAbstractEventLoop.timecCstdS)N)r~)rPr r r! create_future%szAbstractEventLoop.create_futurecCstdS)N)r~)rPcoror r r! create_task*szAbstractEventLoop.create_taskcGstdS)N)r~)rPrQr/r r r!call_soon_threadsafe/sz&AbstractEventLoop.call_soon_threadsafecGstdS)N)r~)rPexecutorrr/r r r!run_in_executor2sz!AbstractEventLoop.run_in_executorcCstdS)N)r~)rPrr r r!set_default_executor5sz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscCstdS)N)r~)rPhostportrrrrr r r! getaddrinfo:szAbstractEventLoop.getaddrinfocCstdS)N)r~)rPZsockaddrrr r r! getnameinfo=szAbstractEventLoop.getnameinfoN)sslrrrsock local_addrserver_hostnamec CstdS)N)r~) rPprotocol_factoryrrrrrrrrrr r r!create_connection@sz#AbstractEventLoop.create_connectiond)rrrbacklogr reuse_address reuse_portc CstdS)aA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. N)r~) rPrrrrrrrrrrr r r! create_serverEs'zAbstractEventLoop.create_server)rrrcCstdS)N)r~)rPrpathrrrr r r!create_unix_connectionnsz(AbstractEventLoop.create_unix_connection)rrrcCstdS)a#A coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. N)r~)rPrrrrrr r r!create_unix_serverssz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc CstdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. N)r~) rPrrZ remote_addrrrrrrrrr r r!create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcCstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.N)r~)rPrpiper r r!connect_read_pipes z#AbstractEventLoop.connect_read_pipecCstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.N)r~)rPrrr r r!connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcKstdS)N)r~)rPrcmdrrrr0r r r!subprocess_shellsz"AbstractEventLoop.subprocess_shellcOstdS)N)r~)rPrrrrr/r0r r r!subprocess_execsz!AbstractEventLoop.subprocess_execcGstdS)N)r~)rPfdrQr/r r r! add_readerszAbstractEventLoop.add_readercCstdS)N)r~)rPrr r r! remove_readerszAbstractEventLoop.remove_readercGstdS)N)r~)rPrrQr/r r r! add_writerszAbstractEventLoop.add_writercCstdS)N)r~)rPrr r r! remove_writerszAbstractEventLoop.remove_writercCstdS)N)r~)rPrnbytesr r r! sock_recvszAbstractEventLoop.sock_recvcCstdS)N)r~)rPrdatar r r! sock_sendallszAbstractEventLoop.sock_sendallcCstdS)N)r~)rPrZaddressr r r! sock_connectszAbstractEventLoop.sock_connectcCstdS)N)r~)rPrr r r! sock_acceptszAbstractEventLoop.sock_acceptcGstdS)N)r~)rPsigrQr/r r r!add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdS)N)r~)rPrr r r!remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdS)N)r~)rPfactoryr r r!set_task_factorysz"AbstractEventLoop.set_task_factorycCstdS)N)r~)rPr r r!get_task_factorysz"AbstractEventLoop.get_task_factorycCstdS)N)r~)rPr r r!get_exception_handlersz'AbstractEventLoop.get_exception_handlercCstdS)N)r~)rPZhandlerr r r!set_exception_handlersz'AbstractEventLoop.set_exception_handlercCstdS)N)r~)rPrdr r r!default_exception_handlersz+AbstractEventLoop.default_exception_handlercCstdS)N)r~)rPrdr r r!r` sz(AbstractEventLoop.call_exception_handlercCstdS)N)r~)rPr r r!rOszAbstractEventLoop.get_debugcCstdS)N)r~)rPZenabledr r r! set_debugszAbstractEventLoop.set_debug)r)NN)NN)NN)7r4rfr3rgrrrrrr|rrzrrrrrrrrrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrr subprocessPIPErrrrrrrrrrrrrrrrrr`rOrr r r r!rst   '!   c@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.N)r~)rPr r r!rsz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.N)r~)rPrRr r r!r $sz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.N)r~)rPr r r!r (sz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.N)r~)rPr r r!r 0sz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.N)r~)rPwatcherr r r!r 4sz)AbstractEventLoopPolicy.set_child_watcherN) r4rfr3rgrr r r r r r r r!rs  c@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r4rfr3rK _set_calledr r r r!_LocalHsrcCs|j|_dS)N)r_local)rPr r r!rSLsz#BaseDefaultEventLoopPolicy.__init__cCsZ|jjdkr4|jj r4ttjtjr4|j|j|jjdkrRt dtjj |jjS)zSGet the event loop. This may be None or an instance of EventLoop. Nz,There is no current event loop in thread %r.) rrKrr threadingZcurrent_threadZ _MainThreadr r RuntimeErrorname)rPr r r!rOs   z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)rrrK)rPrRr r r!r ]sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|jS)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factory)rPr r r!r csz)BaseDefaultEventLoopPolicy.new_event_loop) r4rfr3rgrrlocalrrSrr r r r r r!r9s rc@seZdZdZdS) _RunningLoopN)NN)r4rfr3loop_pidr r r r!rwsrcCs&tj\}}|dk r"|tjkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr r r!r~s cCs|tjft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrr)rRr r r!r sc Cs.t tdkr ddlm}|aWdQRXdS)Nr)DefaultEventLoopPolicy)_lock_event_loop_policyr2r)rr r r!_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr r r r!rscCs|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r)Zpolicyr r r!rscCst}|dk r|StjS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr r r!rs cCstj|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr )rRr r r!r scCs tjS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r r r r!r scCs tjS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r r r r!r scCs tj|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr r r!r s)r2)NN))rg__all__rrrr"rrr=rr@r2rrrr1r5r:rGrrrrrrrZLockrrrrrr rrrrr r r r r r r r!sZ    >8 5"7   test_utils.py000064400000035363152343301150007324 0ustar00"""Utilities shared by tests.""" import collections import contextlib import io import logging import os import re import socket import socketserver import sys import tempfile import threading import time import unittest import weakref from unittest import mock from http.server import HTTPServer from wsgiref.simple_server import WSGIRequestHandler, WSGIServer try: import ssl except ImportError: # pragma: no cover ssl = None from . import base_events from . import compat from . import events from . import futures from . import selectors from . import tasks from .coroutines import coroutine from .log import logger from test import support if sys.platform == 'win32': # pragma: no cover from .windows_utils import socketpair else: from socket import socketpair # pragma: no cover def data_file(filename): if hasattr(support, 'TEST_HOME_DIR'): fullname = os.path.join(support.TEST_HOME_DIR, filename) if os.path.isfile(fullname): return fullname fullname = os.path.join(os.path.dirname(os.__file__), 'test', filename) if os.path.isfile(fullname): return fullname raise FileNotFoundError(filename) ONLYCERT = data_file('ssl_cert.pem') ONLYKEY = data_file('ssl_key.pem') def dummy_ssl_context(): if ssl is None: return None else: return ssl.SSLContext(ssl.PROTOCOL_SSLv23) def run_briefly(loop): @coroutine def once(): pass gen = once() t = loop.create_task(gen) # Don't log a warning if the task is not done after run_until_complete(). # It occurs if the loop is stopped or if a task raises a BaseException. t._log_destroy_pending = False try: loop.run_until_complete(t) finally: gen.close() def run_until(loop, pred, timeout=30): deadline = time.time() + timeout while not pred(): if timeout is not None: timeout = deadline - time.time() if timeout <= 0: raise futures.TimeoutError() loop.run_until_complete(tasks.sleep(0.001, loop=loop)) def run_once(loop): """Legacy API to run once through the event loop. This is the recommended pattern for test code. It will poll the selector once and run all callbacks scheduled in response to I/O events. """ loop.call_soon(loop.stop) loop.run_forever() class SilentWSGIRequestHandler(WSGIRequestHandler): def get_stderr(self): return io.StringIO() def log_message(self, format, *args): pass class SilentWSGIServer(WSGIServer): request_timeout = 2 def get_request(self): request, client_addr = super().get_request() request.settimeout(self.request_timeout) return request, client_addr def handle_error(self, request, client_address): pass class SSLWSGIServerMixin: def finish_request(self, request, client_address): # The relative location of our test directory (which # contains the ssl key and certificate files) differs # between the stdlib and stand-alone asyncio. # Prefer our own if we can find it. keyfile = ONLYKEY certfile = ONLYCERT context = ssl.SSLContext() context.load_cert_chain(certfile, keyfile) ssock = context.wrap_socket(request, server_side=True) try: self.RequestHandlerClass(ssock, client_address, self) ssock.close() except OSError: # maybe socket has been closed by peer pass class SSLWSGIServer(SSLWSGIServerMixin, SilentWSGIServer): pass def _run_test_server(*, address, use_ssl=False, server_cls, server_ssl_cls): def app(environ, start_response): status = '200 OK' headers = [('Content-type', 'text/plain')] start_response(status, headers) return [b'Test message'] # Run the test WSGI server in a separate thread in order not to # interfere with event handling in the main thread server_class = server_ssl_cls if use_ssl else server_cls httpd = server_class(address, SilentWSGIRequestHandler) httpd.set_app(app) httpd.address = httpd.server_address server_thread = threading.Thread( target=lambda: httpd.serve_forever(poll_interval=0.05)) server_thread.start() try: yield httpd finally: httpd.shutdown() httpd.server_close() server_thread.join() if hasattr(socket, 'AF_UNIX'): class UnixHTTPServer(socketserver.UnixStreamServer, HTTPServer): def server_bind(self): socketserver.UnixStreamServer.server_bind(self) self.server_name = '127.0.0.1' self.server_port = 80 class UnixWSGIServer(UnixHTTPServer, WSGIServer): request_timeout = 2 def server_bind(self): UnixHTTPServer.server_bind(self) self.setup_environ() def get_request(self): request, client_addr = super().get_request() request.settimeout(self.request_timeout) # Code in the stdlib expects that get_request # will return a socket and a tuple (host, port). # However, this isn't true for UNIX sockets, # as the second return value will be a path; # hence we return some fake data sufficient # to get the tests going return request, ('127.0.0.1', '') class SilentUnixWSGIServer(UnixWSGIServer): def handle_error(self, request, client_address): pass class UnixSSLWSGIServer(SSLWSGIServerMixin, SilentUnixWSGIServer): pass def gen_unix_socket_path(): with tempfile.NamedTemporaryFile() as file: return file.name @contextlib.contextmanager def unix_socket_path(): path = gen_unix_socket_path() try: yield path finally: try: os.unlink(path) except OSError: pass @contextlib.contextmanager def run_test_unix_server(*, use_ssl=False): with unix_socket_path() as path: yield from _run_test_server(address=path, use_ssl=use_ssl, server_cls=SilentUnixWSGIServer, server_ssl_cls=UnixSSLWSGIServer) @contextlib.contextmanager def run_test_server(*, host='127.0.0.1', port=0, use_ssl=False): yield from _run_test_server(address=(host, port), use_ssl=use_ssl, server_cls=SilentWSGIServer, server_ssl_cls=SSLWSGIServer) def make_test_protocol(base): dct = {} for name in dir(base): if name.startswith('__') and name.endswith('__'): # skip magic names continue dct[name] = MockCallback(return_value=None) return type('TestProtocol', (base,) + base.__bases__, dct)() class TestSelector(selectors.BaseSelector): def __init__(self): self.keys = {} def register(self, fileobj, events, data=None): key = selectors.SelectorKey(fileobj, 0, events, data) self.keys[fileobj] = key return key def unregister(self, fileobj): return self.keys.pop(fileobj) def select(self, timeout): return [] def get_map(self): return self.keys class TestLoop(base_events.BaseEventLoop): """Loop for unittests. It manages self time directly. If something scheduled to be executed later then on next loop iteration after all ready handlers done generator passed to __init__ is calling. Generator should be like this: def gen(): ... when = yield ... ... = yield time_advance Value returned by yield is absolute time of next scheduled handler. Value passed to yield is time advance to move loop's time forward. """ def __init__(self, gen=None): super().__init__() if gen is None: def gen(): yield self._check_on_close = False else: self._check_on_close = True self._gen = gen() next(self._gen) self._time = 0 self._clock_resolution = 1e-9 self._timers = [] self._selector = TestSelector() self.readers = {} self.writers = {} self.reset_counters() self._transports = weakref.WeakValueDictionary() def time(self): return self._time def advance_time(self, advance): """Move test time forward.""" if advance: self._time += advance def close(self): super().close() if self._check_on_close: try: self._gen.send(0) except StopIteration: pass else: # pragma: no cover raise AssertionError("Time generator is not finished") def _add_reader(self, fd, callback, *args): self.readers[fd] = events.Handle(callback, args, self) def _remove_reader(self, fd): self.remove_reader_count[fd] += 1 if fd in self.readers: del self.readers[fd] return True else: return False def assert_reader(self, fd, callback, *args): if fd not in self.readers: raise AssertionError(f'fd {fd} is not registered') handle = self.readers[fd] if handle._callback != callback: raise AssertionError( f'unexpected callback: {handle._callback} != {callback}') if handle._args != args: raise AssertionError( f'unexpected callback args: {handle._args} != {args}') def assert_no_reader(self, fd): if fd in self.readers: raise AssertionError(f'fd {fd} is registered') def _add_writer(self, fd, callback, *args): self.writers[fd] = events.Handle(callback, args, self) def _remove_writer(self, fd): self.remove_writer_count[fd] += 1 if fd in self.writers: del self.writers[fd] return True else: return False def assert_writer(self, fd, callback, *args): assert fd in self.writers, 'fd {} is not registered'.format(fd) handle = self.writers[fd] assert handle._callback == callback, '{!r} != {!r}'.format( handle._callback, callback) assert handle._args == args, '{!r} != {!r}'.format( handle._args, args) def _ensure_fd_no_transport(self, fd): try: transport = self._transports[fd] except KeyError: pass else: raise RuntimeError( 'File descriptor {!r} is used by transport {!r}'.format( fd, transport)) def add_reader(self, fd, callback, *args): """Add a reader callback.""" self._ensure_fd_no_transport(fd) return self._add_reader(fd, callback, *args) def remove_reader(self, fd): """Remove a reader callback.""" self._ensure_fd_no_transport(fd) return self._remove_reader(fd) def add_writer(self, fd, callback, *args): """Add a writer callback..""" self._ensure_fd_no_transport(fd) return self._add_writer(fd, callback, *args) def remove_writer(self, fd): """Remove a writer callback.""" self._ensure_fd_no_transport(fd) return self._remove_writer(fd) def reset_counters(self): self.remove_reader_count = collections.defaultdict(int) self.remove_writer_count = collections.defaultdict(int) def _run_once(self): super()._run_once() for when in self._timers: advance = self._gen.send(when) self.advance_time(advance) self._timers = [] def call_at(self, when, callback, *args): self._timers.append(when) return super().call_at(when, callback, *args) def _process_events(self, event_list): return def _write_to_self(self): pass def MockCallback(**kwargs): return mock.Mock(spec=['__call__'], **kwargs) class MockPattern(str): """A regex based str with a fuzzy __eq__. Use this helper with 'mock.assert_called_with', or anywhere where a regex comparison between strings is needed. For instance: mock_call.assert_called_with(MockPattern('spam.*ham')) """ def __eq__(self, other): return bool(re.search(str(self), other, re.S)) def get_function_source(func): source = events._get_function_source(func) if source is None: raise ValueError("unable to get the source of %r" % (func,)) return source class TestCase(unittest.TestCase): @staticmethod def close_loop(loop): executor = loop._default_executor if executor is not None: executor.shutdown(wait=True) loop.close() def set_event_loop(self, loop, *, cleanup=True): assert loop is not None # ensure that the event loop is passed explicitly in asyncio events.set_event_loop(None) if cleanup: self.addCleanup(self.close_loop, loop) def new_test_loop(self, gen=None): loop = TestLoop(gen) self.set_event_loop(loop) return loop def unpatch_get_running_loop(self): events._get_running_loop = self._get_running_loop def setUp(self): self._get_running_loop = events._get_running_loop events._get_running_loop = lambda: None self._thread_cleanup = support.threading_setup() def tearDown(self): self.unpatch_get_running_loop() events.set_event_loop(None) # Detect CPython bug #23353: ensure that yield/yield-from is not used # in an except block of a generator self.assertEqual(sys.exc_info(), (None, None, None)) self.doCleanups() support.threading_cleanup(*self._thread_cleanup) support.reap_children() if not compat.PY34: # Python 3.3 compatibility def subTest(self, *args, **kwargs): class EmptyCM: def __enter__(self): pass def __exit__(self, *exc): pass return EmptyCM() @contextlib.contextmanager def disable_logger(): """Context manager to disable asyncio logger. For example, it can be used to ignore warnings in debug mode. """ old_level = logger.level try: logger.setLevel(logging.CRITICAL+1) yield finally: logger.setLevel(old_level) def mock_nonblocking_socket(proto=socket.IPPROTO_TCP, type=socket.SOCK_STREAM, family=socket.AF_INET): """Create a mock of a non-blocking socket.""" sock = mock.MagicMock(socket.socket) sock.proto = proto sock.type = type sock.family = family sock.gettimeout.return_value = 0.0 return sock def force_legacy_ssl_support(): return mock.patch('asyncio.sslproto._is_sslproto_available', return_value=False) compat.py000064400000001037152343301150006377 0ustar00"""Compatibility helpers for the different Python versions.""" import sys PY34 = sys.version_info >= (3, 4) PY35 = sys.version_info >= (3, 5) PY352 = sys.version_info >= (3, 5, 2) def flatten_list_bytes(list_of_data): """Concatenate a sequence of bytes-like objects.""" if not PY34: # On Python 3.3 and older, bytes.join() doesn't handle # memoryview. list_of_data = ( bytes(data) if isinstance(data, memoryview) else data for data in list_of_data) return b''.join(list_of_data) __pycache__/runners.cpython-38.opt-1.pyc000064400000003635152343727170014061 0ustar00U e5d@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr'/usr/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .__pycache__/queues.cpython-38.opt-1.pyc000064400000020277152343727170013675 0ustar00U e5d @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N__name__ __module__ __qualname____doc__rr&/usr/lib64/python3.8/asyncio/queues.pyr src@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrsrc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS)*raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer"r#rrrr!6sz Queue._initcCs |jSr%)r&popleftr"rrr_get9sz Queue._getcCs|j|dSr%r&appendr"itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr%)r(ZdoneZ set_result)r"waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr)rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr2r3r4)r5r r7r)rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r&z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr&rlenrr)r"resultrrrr7Os  z Queue._formatcCs t|jS)zNumber of items in the queue.)r=r&r)rrrqsize[sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.r&r)rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr?r)rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rBr create_futurerr,cancelremove ValueError cancelledr1 put_nowait)r"r.Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)rBrr/rrclearr1rr-rrrrHs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| S)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rArrCrr,rDrErFrGr1 get_nowait)r"getterrrrgets    z Queue.getcCs$|r t|}||j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rArr*r1rr-rrrrKs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rrFrr r)rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwaitr)rrrjoins z Queue.join)r)r r r rr$r!r*r/r1r8r9r7r?propertyr#rArBrIrHrMrKrNrPrrrrrs(      rc@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dSr%r@r'rrrr!szPriorityQueue._initcCs||j|dSr%r@)r"r.heappushrrrr/szPriorityQueue._putcCs ||jSr%r@)r"heappoprrrr*szPriorityQueue._getN) r r r rr!heapqrRr/rSr*rrrrrsrc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dSr%r@r'rrrr!szLifoQueue._initcCs|j|dSr%r+r-rrrr/szLifoQueue._putcCs |jSr%)r&popr)rrrr*szLifoQueue._getN)r r r rr!r/r*rrrrrsr) __all__rrTrrr Exceptionrrrrrrrrrs  K__pycache__/protocols.cpython-38.opt-2.pyc000064400000006435152343727170014413 0ustar00U e5d@s^dZGdddZGdddeZGdddeZGdddeZGd d d eZd d Zd S)) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s0eZdZdZddZddZddZdd Zd S) rcCsdSNr)selfZ transportrr)/usr/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdSrrrexcrrr connection_lostszBaseProtocol.connection_lostcCsdSrrrrrr pause_writing%szBaseProtocol.pause_writingcCsdSrrrrrr resume_writing;szBaseProtocol.resume_writingN)__name__ __module__ __qualname__ __slots__r r rrrrrr r s  rc@s eZdZdZddZddZdS)rrcCsdSrr)rdatarrr data_received^szProtocol.data_receivedcCsdSrrrrrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrr rBsrc@s(eZdZdZddZddZddZdS) rrcCsdSrr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdSrr)rnbytesrrr buffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrrrrr rszBufferedProtocol.eof_receivedN)rrrrrrrrrrr rms rc@s eZdZdZddZddZdS)rrcCsdSrr)rrZaddrrrr datagram_receivedsz"DatagramProtocol.datagram_receivedcCsdSrrr rrr error_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrr rsrc@s(eZdZdZddZddZddZdS) rrcCsdSrr)rfdrrrr pipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdSrr)rrr rrr pipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdSrrrrrr process_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!rrrr rsrcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr _feed_data_to_buffered_protos     r%N)__all__rrrrrr%rrrr s 9+9__pycache__/base_futures.cpython-38.pyc000064400000003554152343727170014115 0ustar00U e5d @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r)objrr,/usr/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) #helper function for Future.__repr__cSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d |S) r Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r&)__all__r _threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr&rrrr s   __pycache__/subprocess.cpython-38.opt-2.pyc000064400000016042152343727170014552 0ustar00U e5d@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsTeZdZfddZddZddZddZd d Zd d Zd dZ ddZ Z S)SubprocessStreamProtocolcsHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrAr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHSr:)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrFszProcess.send_signalcCs|jdSr:)r terminater7rrrrHszProcess.terminatecCs|jdSr:)rkillr7rrrrIsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrLr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|j}|jrJ|dkr8dnd}td|||IdH}|jr|dkrndnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rrrrJr rLreadr1)rr.r,r;nameoutputrrr _read_streams   zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rPrQrrUrrZgatherrrE)rrOrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrDrErFrHrIrPrQrUrVrrrrr@ts  r@c sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellr@) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrXr&rYcs tdSr[r\rr%rrr]sz(create_subprocess_exec..r^)rr_r`rarbZsubprocess_execr@) Zprogramrrrr rargsrdrer,r'rr%rrs( r)__all__ subprocessr`rrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr r@Z_DEFAULT_LIMITrrrrrrs.     bV __pycache__/base_tasks.cpython-38.opt-1.pyc000064400000003632152343727170014501 0ustar00U e5d @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror */usr/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #__pycache__/unix_events.cpython-38.opt-2.pyc000064400000103014152343727170014725 0ustar00U e5dۿ@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZdZe jdkredddZGdddejZGdddejZ Gdddej!ej"Z#Gdddej$Z%GdddZ&ddZ'Gdd 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.eZ/e.Z0dS)+N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdSN)signumframerr+/usr/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZd(fdd ZfddZddZdd Zd d Zd d ZddZ d)ddZ d*ddZ d+ddZ ddZ d,dddddddZd-ddddddddZd d!Zd"d#Zd$d%Zd&d'ZZS)._UnixSelectorEventLoopNcst|i|_dSr)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)Nz3coroutines cannot be used with add_signal_handler()Fset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dSr)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)NFr5r6r3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)Nzsig must be an int, not zinvalid signal number ) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |r|dkr6tdn |dk r&td|dk r6td|dk r|dk rNtdt|}ttjtjd}z |d|||IdHWq|YqXn@|dkrtd|j tjks|j tjkrtd||d|j |||||d IdH\}}||fS) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rs) r<osfspathsocketAF_UNIX SOCK_STREAM setblockingZ sock_connectr%familytypeZ_create_connection_transport) rprotocol_factorypathrprqrrrs transportrUrrrcreate_unix_connectionsR      z-_UnixSelectorEventLoop.create_unix_connectiondT)rqbacklogrprs start_servingc st|trtd|dk r&|s&td|dk rH|dk r@tdt|}ttjtj}|ddkrz t t |j rt |WnBt k rYn0tk r}ztd||W5d}~XYnXz||Wnltk r0} z8|| jtjkrd|d} ttj| dnW5d} ~ XYn|YnXn<|dkrZtd |jtjksv|jtjkrtd ||d t||g||||} |r| tjd|d IdH| S) Nz*ssl argument must be an SSLContext or Nonertrur)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)loop)rOboolr7r<rwrxryrzr{statS_ISSOCKst_moderemoveFileNotFoundErrorr=r errorZbindr%rBZ EADDRINUSEr}r~r|rZServerZ_start_servingr sleep) rrrrqrrprsrerrrFmsgZserverrrrcreate_unix_serversn           z)_UnixSelectorEventLoop.create_unix_serverc sz tjWn,tk r6}ztdW5d}~XYnXz |}Wn2ttjfk rv}ztdW5d}~XYnXzt|j }Wn,t k r}ztdW5d}~XYnX|r|n|} | sdS| } | | d||||| d| IdHS)Nzos.sendfile() is not availableznot a regular filer) rwsendfileAttributeErrorrSendfileNotAvailableErrorr;ioUnsupportedOperationfstatst_sizer=r]_sock_sendfile_native_impl) rrqfileoffsetcountrFr;rZfsize blocksizefutrrr_sock_sendfile_nativeJs2    z,_UnixSelectorEventLoop._sock_sendfile_nativec Cs,|} |dk r|||r4||||dS|rd||}|dkrd||||||dSzt| |||} WnDttfk r|dkr| ||| | |j || |||||| Ynbt k rj} z|dk r| j t jkrt| tk rtdt j} | | _| } |dkrBtd} |||||| n|||||| W5d} ~ XYnttfk rYntk r} z|||||| W5d} ~ XYnjX| dkr||||||nD|| 7}|| 7}|dkr | ||| | |j || |||||| dS)Nrzsocket is not connectedzos.sendfile call failed)r; remove_writer cancelled_sock_sendfile_update_fileposZ set_resultrwrBlockingIOErrorInterruptedError_sock_add_cancellation_callbackZ add_writerrr=rBZENOTCONNr~ConnectionError __cause__rrZ set_exceptionrarbrc)rrZ registered_fdrqr;rrr total_sentfdZsentrFnew_excrrrrras               z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt||tjdSNr)rwlseekSEEK_SET)rr;rrrrrrsz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcsfdd}||dS)Ncs&|r"}|dkr"|dS)Nr3)rr;r)rrrrqrrcbszB_UnixSelectorEventLoop._sock_add_cancellation_callback..cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sF -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrwrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rwreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrwrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc Cs4t|trt|}|sdS|js&|jrN|jtjkr|}d}td|Yn.X|dkrLdSt|}|jrlt d||z|j |\}}Wn.t k r|jrtjd|ddYnX|||f|dS)N8Unknown child process pid %d, will report returncode 255r$process %s exited with returncode %s'Child watcher got an unexpected pid: %rTr) rwwaitpidWNOHANGChildProcessErrorr rr#rrrr%poprJ)rr&rnr"rorDrErrrr's4    zSafeChildWatcher._do_waitpid) rrrr%rrr_rr(r'rrrr!rrs rcsPeZdZfddZfddZddZddZd d Zd d Zd dZ Z S)rcs$tt|_i|_d|_dSr)rr threadingZLock_lock_zombies_forksrr!rrrs  zFastChildWatcher.__init__cs"|j|jtdSr)r%r-r:rr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r9r;rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r9r;r:r?r-r r)rrrrZcollateral_victimsrrrrs  zFastChildWatcher.__exit__c Gsf|jFz|j|}Wn.tk rF||f|j|<YW5QRdSXW5QRX|||f|dSr)r9r:r7rJr%)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr-r.rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr2z8Caught subprocess termination from unknown pid: %d -> %d)rwr4r5r6r#r9r%r7rJr;r:rrr rr)rrnr"rorDrErrrr(<s@    z FastChildWatcher._do_waitpid_all) rrrrr%rrr_rr(rrrr!rrs  rc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ dS)rcCsi|_d|_dSr)r%_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r<rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r%r-r<r9 getsignalr*r+r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrrszMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr%r')rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr-r.rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..)r(rEvaluesr)rthreadsrKrrrrFsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrr>rrrrszThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rGrIrrrrL sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rErMr"r,)rrrNrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErH) rr@r8ZThreadr'nextrDrEstart)rrnrDrErrKrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCszt|d\}}Wn(tk r<|}d}td|Yn Xt|}|r\td|||rttd||n|j |||f||j |dS)Nrr0r1r2rA) rwr4r6r rr#rrrBrmrEr7)rrr&rDrErnr"rorrrr'"s& z ThreadedChildWatcher._do_waitpidN)rrrrr\r%rFrrr*r+rr_rrr'rrrrrs  rcsDeZdZeZfddZddZfddZddZd d Z Z S) _UnixDefaultEventLoopPolicycstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr9rTrrOr8current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dSr)rset_event_looprTrOr8rUrVrrr!rrrYMs   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jSr)rTrXrrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|j||_dSr)rTr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrZ _loop_factoryrrXrYr[rZrrrr!rrS=s    rS)1rBrrCrwrr9ryrr r&r8r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr#r$rrrrZBaseDefaultEventLoopPolicyrSrrrrrrs^             NO5Ji}Y3__pycache__/tasks.cpython-38.pyc000064400000057333152343727170012557 0ustar00U e5d@svdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZedjZdBd d ZdCd dZdDddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejj Z ejj!Z!ejj"Z"dde"dddZ#ddZ$ddddZ%d d!Z&d"d#Z'ddd$d%d&Z(ej)d'd(Z*dEddd)d*Z+ddd+d,Z,ej)d-d.Z-ee-_Gd/d0d0ej.Z/dd1d2d3d4Z0ddd5d6Z1d7d8Z2e 3Z4iZ5d9d:Z6d;d<Z7d=d>Z8d?d@Z9e6Z:e9Z;e7Ze9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|S)z!Return a currently executed task.N)rget_running_loop_current_tasksgetloopr!%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)z'Return a set of all tasks for the loop.Nrrcs&h|]}t|kr|s|qSr!)r _get_loopdone.0trr!r" <szall_tasks..)rrlist _all_tasks RuntimeErrorr iZtasksr!rr"r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr#csh|]}t|kr|qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat..)rget_event_loopr*r+r,r-r!rr"_all_tasks_compat@s r0cCs4|dk r0z |j}Wntk r&Yn X||dSN)set_nameAttributeError)tasknamer2r!r!r"_set_task_nameXs  r6cseZdZdZdZed%ddZed&ddZdddfd d Zfd d Z d dZ ddZ ddZ ddZ ddZddZddddZdddddZdd Zd'fd!d" Zd#d$ZZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd|dkr t}t|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevelN)warningswarnDeprecationWarningrr/rclsr r!r!r"rtszTask.current_taskcCstjdtddt|S)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"rs zTask.all_tasks)r r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)NrFza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror r5 __class__r!r"rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr!r"rXs  z Task.__del__cCs t|Sr1)rZ_task_repr_inforSr!r!r" _repr_infoszTask._repr_infocCs|jSr1)rMrYr!r!r"get_corosz Task.get_corocCs|jSr1)rIrYr!r!r"get_namesz Task.get_namecCst||_dSr1)rJrI)rSvaluer!r!r"r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr,)rSresultr!r!r" set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr!r!r" set_exceptionszTask.set_exception)limitcCs t||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)rSrcr!r!r" get_stackszTask.get_stack)rcfilecCst|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)rSrcrer!r!r" print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackr%rLcancelrKrYr!r!r"rgs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrgr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr$r,rQrRrOrhadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr!r"Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr1)r_rprR)rSfuturerur!r!r"Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname____doc__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs __classcell__r!r!rUr"rbs&     !Tr)r5cCs t}||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. )rrrr6)rTr5r r4r!r!r"rxs  r)r timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfdd t|D}t|||IdHS) aWait for the Futures and coroutines given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSrr r'frr!r"r)szwait..)risfuturerrErGtyperx ValueErrorrrrrrr:r;r<set_wait)fsr r~rr!rr"rs rcGs|s|ddSr1)r%r`)waiterargsr!r!r"_release_waitersrrc s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nrr7r8rr)rrr:r;r<r r%r__cancel_and_waitrrj TimeoutError create_future call_laterr functoolspartialrrrgremove_done_callback)futr~r rurtimeout_handlecbr!r!r"rsL              rc s|s td|d|dk r.||tt|fdd}|D]}||qLzIdHW5dk r||D]}||qXtt}}|D]"}| r| |q| |q||fS)zVInternal helper for wait(). The fs argument must be a collection of Futures. zSet of Futures is empty.NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrargr%r`rZcounterrrrr!r"_on_completions z_wait.._on_completion) AssertionErrorrrrlenrrrgrrr%add)rr~rr rrr%Zpendingr!rr"rs*     rc sF|}tt|}||z||IdHW5||XdS)z.cs*D]}|dqdSr1)r put_nowaitclearr)rr%todor!r" _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr1)removerrgr)r%rrr!r"r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr1)rrrr_r)r%r!r" _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrrxZqueuesrrr/r:r;r<rrrrranger)rr r~rrrr_r!)rr%r rrr"r7s*       rccs dVdS)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nr!r!r!r!r"__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)z9Coroutine that completes after a given time (in seconds).rNrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrg)Zdelayr_r rwhr!r!r"r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrrr$rrtZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r s    r ccs|EdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitabler!r!r"rsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. Nrcstj|d||_d|_dS)NrF)rBrC _children_cancel_requested)rSchildrenr rUr!r"rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|S)NFT)r%rrgr)rSZretZchildr!r!r"rgs z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"rsrF)r return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd |_ d 7|||<| |n||} |qdt |dS) aReturn a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r%rrarrjrbr_appendrr`)rruZresultsresrZ nfinishedZnfutsouterrr!r"_done_callbacks4    zgather.._done_callbackrrFr)rr/r:r;r<rr`r rr$rFrrrr)r rZcoros_or_futuresrZ arg_to_futargrr!rr"r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd }|S) a.Wait for a future, shielding it from cancellation. The statement res = await shield(something()) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = await shield(something()) except CancelledError: res = None Nrr7r8rcs\r|s|dS|r.n*|}|dk rJ|n|dSr1)rrargrbr`r_)innerrurr!r"_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr1)r%rr)rrr!r"_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r%rr$rrr)rr rr!)rrrr"r Ps     r cs:tstdtjfdd}|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr)rZ _chain_futurer rornrpZset_running_or_notify_cancelrb)rurTrwr r!r"callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr rr!rr"r s    r cCst|dS)z3Register a new task in asyncio as executed by loop.N)r+rr4r!r!r"rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr,r r4rr!r!r"rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr!r!r"rs rcCst|dS)zUnregister a task.N)r+discardrr!r!r"rsr)rrrrr+r)N)N)N)N)Br{__all__Zconcurrent.futuresrrNrrt itertoolstypesr:weakrefrrrrrrcount__next__rHrrr0r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr!r!r!r"s                #H,>  x?$__pycache__/proactor_events.cpython-38.pyc000064400000057123152343727170014644 0ustar00U e5d<}@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZddZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZ Gddde j!Z"dS) zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr//usr/lib64/python3.8/asyncio/proactor_events.py_set_socket_extras   rcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j fddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncst||||||_||||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rl|j |j|jj||dk r|jtj|ddS)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attachr call_soon _protocolZconnection_maderZ_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__rrr2s(     z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|jdk rP|d|j|jdk rl|d|j|jdk r|d|j|jr|dt |j|j r|dd d |S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname____doc__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s   rcsTeZdZdZdfdd ZddZddZd d Zd d Zd dZ dddZ Z S)_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rfr(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rfrrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rfr$rr*rgre_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr|jdkst||_dS|s.|dSt|jtjrzt|j|Wqt t fk rhYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.)rfreAssertionErrorrqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ data_received)r-rlrUrrrrjs$z)_ProactorReadPipeTransport._data_receivedc Csd}zrz|dk rP|j|ks0|jdkr,|js0td|_|rH|}n||jrfd}WWdS|dkrzWWdS|js|jj |j d|_Wnt k r}z0|js| |dn|jrtjdddW5d}~XYntk r}z||W5d}~XYnftk r>}z| |dW5d}~XYn8tjk r^|jsZYnX|jsv|j|jW5|dk r||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$r(rrrXresultrHrfr _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrg)r-futrlrUrrrrgsF     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_r`rrhrirmrqrjrgrcrrr3rrds rdcs^eZdZdZdZfddZddZddd Zd d Zd d Z ddZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportzTransport for write pipes.Tcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jdkst|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr%r#rr _loop_writing_maybe_pause_protocolextendrkrrrwriteKs.       z%_ProactorBaseWritePipeTransport.writeNc Csxz|dk r"|jdkr"|jr"WdS||jks0td|_d|_|rH||dkr\|j}d|_|s|jrv|j|jd|j r|j t j |n\|jj|j ||_|js|jdkstt||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk rD}z||W5d}~XYn0tk rr}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(rrr&rtr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrusendrXr;rzrrrWrYrxrPrRrV)r-frlrUrrrrqs<    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerrrrrrrrrcrrr3rr|As & )r|cs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrurvr r$rz _pipe_closedr}r3rrrsz$_ProactorWritePipeTransport.__init__cCsv|r dS|dkst|jr4|jdks0tdS||jksLt||jfd|_|jdk rj|tn|dS)Nrs) Z cancelledrtrrr(r$r%rPBrokenPipeErrorrI)r-r{rrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrcrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rg)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rl_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQrrrrrr ValueErrorr'rrr rr#r9r%rr)r-rladdrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Csz|jrWdS||jkstd|_|r.||jr@|jr\|jr\|jrV|j|j dWdS|j \}}|jdk r|jj |j ||_n|jj j|j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rrrtr#rr(rr*rGpopleftrurr rrRr+error_received ExceptionrVrzrr)r-r{rlrrUrrrrs4    z(_ProactorDatagramTransport._loop_writingc CsVd}z4z|jrWW$dS|j|ks:|jdkr6|js:td|_|dk r|}|jrdd}WWdS|jdk r|||j}}n|\}}|jrWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnNtk r}z|j|W5d}~XYn<tjk r|jsYnX|jdk r8|j|jW5|rP|j||XdSrB)r+Zdatagram_receivedr'r$r(rrrtrrrurvr max_sizeZrecvfromrRrrryrzrg)r-r{rlrresrUrrrrgsD         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrgrcrrr3rrs   !rc@s eZdZdZddZddZdS)_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`rrrrrrrEsrcsBeZdZdZejjZd fdd ZddZ ddZ d d Z Z S) _ProactorSocketTransportz Transport for connected sockets.Ncs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_r`rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrcrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8ru _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rdrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_piperurIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rurv)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)ruZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rur)r-rrlrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)ruZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)ruacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrusendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rhrirrrmZ sock_sendfiler )r-Ztransprrrrmrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rtrrurvrrryrnrorprTrz_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rtrr rSrrrrurrRr:rTr rrIrryrrz)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHru _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrcrrr3rrks\            +r)#r`__all__rrr rarrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrdZWriteTransportr|rrZ TransportrrZ BaseEventLooprrrrrsR           n  __pycache__/__main__.cpython-38.opt-1.pyc000064400000006102152343727170014075 0ustar00U e5d @sJddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrFeZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez eWn6e k r>tr6t!s6t"d aYqYqXqFqdS) N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__(/usr/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__asyncio> __builtins____spec__r$__file__ __loader__ __package__FT)#r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$Znew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsF 6      __pycache__/locks.cpython-38.opt-1.pyc000064400000037762152343727170013510 0ustar00U e5d|C@sdZdZddlZddlZddlZddlmZddlmZddlmZddlm Z Gd d d Z Gd d d Z Gd dde Z GdddZ Gddde ZGddde ZGdddeZdS)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s(eZdZdZddZddZddZdS) _ContextManagera\Context manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: Deprecated, use 'async with' statement: async with lock: cCs ||_dSN)_lock)selflockr%/usr/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r&r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%!_ContextManagerMixin__acquire_ctx __await__rrrrr)Ys z_ContextManagerMixin.__await__cs|IdHdSr )r&rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner'r Z _is_coroutiner(r)r*r.rrrrr1s rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... NloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)_waiters_lockedrget_event_loop_loopr#r$r%rr2rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r6r5lenrresZextra __class__rrrBs  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r6r5all collectionsdequer8 create_futureappendremover CancelledError_wake_up_firstrfutrrrr&s&    z Lock.acquirecCs"|jrd|_|ntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r6rSrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddS)z*Wake up the first waiter if it isn't done.NT)r5nextiter StopIterationdone set_resultrTrrrrSszLock._wake_up_first) rrrrrrBr;r&rrS __classcell__rrrFrrjs5  rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. Nr1cCs>t|_d|_|dkr$t|_n||_tjdt dddSr3) rMrNr5_valuerr7r8r#r$r%r9rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrB s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)r\r5rYrZrTrrrr]s  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)r\r8rOr5rPrQrTrrrwait(s   z Event.wait) rrrrrrBr_r]r`rar[rrrFrrs  rcsReZdZdZdddddZfddZdd Zd d Zdd dZddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr1cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r ValueErrorrr;r&rrMrNr5)rrr2rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr:)rArBr;r5rCrDrFrrrB[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockFNT) r;rrr&r rRr8rOr5rPrQ)rrHrUrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)rnidxrUrrrnotifys  zCondition.notifycCs|t|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rgrCr5rrrr notify_allszCondition.notify_all)N)r) rrrrrrBrardrgrhr[rrrFrr;s  % rcsPeZdZdZdddddZfddZd d Zd d Zd dZddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rNr1cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r4r r!) rbr\rMrNr5rr7r8r#r$r%rvaluer2rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrBs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r5popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&s    zSemaphore.acquirecCs|jd7_|dS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)r\rlrrrrrszSemaphore.release)r) rrrrrrBrlr;r&rr[rrrFrrs rcs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rNr1cs.|rtjdtdd||_tj||ddS)Nr4r r!r1)r#r$r% _bound_valuerArrirFrrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrs zBoundedSemaphore.release)r)rrrrrrr[rrrFrrs r)r__all__rMr/r#rr r r r rrrrrrrrrrs     "9DzN__pycache__/streams.cpython-38.pyc000064400000050242152343727170013100 0ustar00U e5d h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS) aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr'/usr/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS) z@Similar to `open_connection` but works with UNIX Domain Sockets.NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs*|jr td|_|jr&td|dS)NTz%r pauses writing)r5AssertionErrorr4 get_debugrdebugr8rrr pause_writings  zFlowControlMixin.pause_writingcCsP|js td|_|jr&td||j}|dk rLd|_|sL|ddS)NFz%r resumes writing) r5r:r4r;rr<r6done set_resultr8waiterrrrresume_writings   zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r?r@ set_exceptionr8excrBrrrconnection_losts z FlowControlMixin.connection_lostcsP|jrtd|jsdS|j}|dks2|s2t|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6 cancelledr:r4 create_futurerArrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname____doc__r9r>rCrHrLrPrrrrr2s   r2csfeZdZdZdZdfdd ZeddZddZfd d Z d d Z d dZ ddZ ddZ ZS)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rK_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rXr=rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)r[rYr4Zcall_exception_handlerabortr]rc set_transportget_extra_infor_r^rr\r Z iscoroutineZ create_taskrZ)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) rcfeed_eofrEr`r?r@rUrHrXr\r])r8rGr'rarrrH s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)rc feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)rcrkr_)r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r`rNrrrrP+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r`r?rJ exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rQrRrSrTrYr9propertyrcrjrHrnrorPrr __classcell__rrrarrs   rc@sveZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdddZddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCsJ||_||_|dks"t|ts"t||_||_|j|_|j ddSr) r] _protocol isinstancerr:_readerr4rKZ _complete_futr@)r8r(rr'rrrrr9@s zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )rbrQr]rwappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSr)r]r=rrrr(PszStreamWriter.transportcCs|j|dSr)r]writer8rmrrrrTszStreamWriter.writecCs|j|dSr)r] writelinesrrrrrWszStreamWriter.writelinescCs |jSr)r] write_eofr=rrrrZszStreamWriter.write_eofcCs |jSr)r] can_write_eofr=rrrr]szStreamWriter.can_write_eofcCs |jSr)r]closer=rrrr`szStreamWriter.closecCs |jSr)r] is_closingr=rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rurPr=rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)r]rg)r8namedefaultrrrrgiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)rwrpr]rrrurL)r8rGrrrdrainls   zStreamWriter.drain)N)rQrRrSrTr9rrsr(rrrrrrrrgrrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionr]r5r;r extract_stacksys _getframerY)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=rxZpausedryrz) rr{lenrr_DEFAULT_LIMITrrr]r5r|r}r~rrrrs    zStreamReader.__repr__cCs|jSr)rr=rrrrpszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrJrErFrrrrEs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddS)z1Wakeup read*() functions waiting for data or EOF.N)rrJr@rArrr_wakeup_waiters zStreamReader._wakeup_waitercCs|jdkstd||_dS)NzTransport already set)r]r:)r8r(rrrrfszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrr]resume_readingr=rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrD)rrr=rrrrkszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rrr=rrrat_eofszStreamReader.at_eofcCs|jrtd|sdS|j|||jdk r~|js~t|jd|jkr~z|j Wnt k rvd|_YnXd|_dS)Nzfeed_data after feed_eofrT) rr:rextendrr]r5rrZ pause_readingrMrrrrrls   zStreamReader.feed_datacsf|jdk rt|d|jr&td|jr         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rrrr{r}rrrrr)r8nZblocksblockrmrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrr rrr)r8rZ incompletermrrrrs&       zStreamReader.readexactlycCs|Srrr=rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rQrRrSrYrr9rrprErrfrrkrrlrrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rVhasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkP__pycache__/selector_events.cpython-38.opt-1.pyc000064400000071673152343727170015600 0ustar00U e5dT@s.dZdZddlZddlZddlZddlZddlZddlZddlZz ddl Z Wne k rddZ YnXddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddZddZGddde jZGdddejejZGdddeZGdddeZdS)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)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.8/asyncio/selector_events.py_test_selector_event s rcCs tdk rt|tjrtddS)Nz"Socket cannot be of type SSLSocket)ssl isinstanceZ SSLSocket TypeError)sockrrr_check_ssl_socket+srcseZdZdZdSfdd ZdTdddddZdUddddejd d d ZdVd d Z fddZ ddZ ddZ ddZ ddZddZdddejfddZdddejfddZddejfdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+Z,S)WrzJSelector event loop. See events.EventLoop for API specification. NcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdS)Remove a writer callback.FNT) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|S)zAdd a reader callback.)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||S)zRemove a reader callback.)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|S)zAdd a writer callback..)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||S)r)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)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-blockingN)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rrN)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHS)aSend 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. rrN)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)zTConnect to a remote socket at address. This method is a coroutine. rrAF_UNIX)familyprotoloopN) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)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. rrFN)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r! __module__ __qualname____doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s~        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)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)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs|jr dSz|j|j}Wnttfk r4Ynttfk rLYntk r}z>|j |j |j | |d|jdk r|j|W5d}~XYnnX|r|jd|=||js|j |j |jdk r|jd|jr|dn|jr|jtjdS)Nr)rrrOrrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs2       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrrr rrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)r__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsF            1o__pycache__/transports.cpython-38.opt-1.pyc000064400000027712152343727170014606 0ustar00U e5d(@s|dZdZGdddZGdddeZGdddeZGdd d eeZGd d d eZGd d d eZGdddeZdS)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sHeZdZdZdZdddZdddZdd Zd d Zd d Z ddZ dS)rzBase class for transports._extraNcCs|dkr i}||_dSNr)selfextrar */usr/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||S)z#Get optional transport information.)rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.NNotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdS)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r closeszBaseTransport.closecCstdS)zSet a new protocol.Nr)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdS)zReturn the current protocol.Nrrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__ __slots__rrrrrrr r r r r s   rc@s,eZdZdZdZddZddZddZd S) rz#Interface for read-only transports.r cCstdS)z*Return True if the transport is receiving.Nrrr r r is_reading3szReadTransport.is_readingcCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. Nrrr r r pause_reading7szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. Nrrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"r r r r r.s rc@sNeZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ dS)rz$Interface for write-only transports.r NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. Nrr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.Nrrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. Nr)r datar r r writefszWriteTransport.writecCsd|}||dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)joinr))r Z list_of_datar(r r r writelinesns zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. Nrrr r r write_eofwszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.Nrrr r r can_write_eofszWriteTransport.can_write_eofcCstdSzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r abortszWriteTransport.abort)NN) rrrrrr&r'r)r,r-r.r0r r r r rHs   rc@seZdZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r N)rrrrrr r r r rsrc@s&eZdZdZdZdddZddZdS) rz(Interface for datagram (UDP) transports.r NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. Nr)r r(Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr/rrr r r r0szDatagramTransport.abort)N)rrrrrr1r0r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdS)zGet subprocess id.Nrrr r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode Nrrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.Nr)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal Nr)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate Nrrr r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill Nrrr r r kills zSubprocessTransport.killN) rrrrr2r3r5r7r8r9r r r r rsrcsZeZdZdZdZdfdd ZddZdd Zd d Zdd d Z dddZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_waterNcs$t|||_d|_|dS)NF)superrr;r<_set_write_buffer_limits)r r Zloop __class__r r rs z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r'r=r< _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr;call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrC) r<r'r>rEZresume_writingrFrGrHr;rI)r rKr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r>r=rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr=r>r#r r r r@4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r$r%)r@rLr#r r r r&Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrrLrMrNr@r&r' __classcell__r r rAr r:s  r:N) r__all__rrrrrrr:r r r r s%F6__pycache__/futures.cpython-38.opt-2.pyc000064400000017040152343727170014056 0ustar00U e5db3@sdZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ej Z ej Z ej Z ejZejdZGdd d ZeZd d Zd d ZddZddZddZddZddddZz ddlZWnek rYn XejZZdS))Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZeZdZdZdZdZdZ dZ ddddZ e j ZddZdd Zed d Zejd d Zd dZddZddZddZddZddZddZddddZddZd d!Zd"d#Zd$d%ZeZ dS)&rNFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)NFT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dSNr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkSr()r/r1rrrr cancelledszFuture.cancelledcCs |jtkSr()r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)NzResult is not ready.F) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)NzException is not set.F)r/r1rr;r<r=r#r$rrrrr!s    zFuture.exceptionr5cCsB|jtkr|jj|||dn |dkr.t}|j||fdSr4)r/r0r r6 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)Ncs g|]\}}|kr||fqSrr).0fr8rBrr sz/Future.remove_done_callback..)rlen)rrBZfiltered_callbacksZ removed_countrrFrremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)N: )r/r0rr=r>r<r2)rr?rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)NrJzPStopIteration interacts badly with generators and cannot be raised into a FutureT) r/r0rr= isinstancetype StopIteration TypeErrorr$r<r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r:_asyncio_future_blockingr-r?rrrr __await__s zFuture.__await__)!r __module__ __qualname__r0r/r>r$r rrQr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r9r:r?r!rCrIrKrPrR__iter__rrrrrs8    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dSr()r9rK)rYr?rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rM concurrentfuturesr;rargs TimeoutErrorr=)r%Z exc_classrrr_convert_future_exc#s      r`cCsR|r||sdS|}|dk r<|t|n|}||dSr()r9r3Zset_running_or_notify_cancelr!rPr`r?rK)r\sourcer!r?rrr_set_concurrent_future_state/srbcCsT|r dS|r|n2|}|dk r>|t|n|}||dSr()r9r3r!rPr`r?rK)radestr!r?rrr_copy_future_state>s rdcststtjjstdts._set_statecs2|r.dkskr"n jdSr()r9r3call_soon_threadsafe) destination) dest_loopra source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r9Z is_closedrg)ra)rfrirhrjrr_call_set_stateos z&_chain_future.._call_set_state)rrLr\r]rrOrZrC)rarhrkrlr)rfrirhrarjr _chain_futureRs   rmr cCs2t|r |S|dkrt}|}t|||Sr()rrr Z create_futurerm)r"r Z new_futurerrrr|s r)__all__Zconcurrent.futuresr\r@Zloggingrrrrr rr0r1r<DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rbrdrmrZ_asyncio ImportErrorZ_CFuturerrrrs8     q  *  __pycache__/log.cpython-38.pyc000064400000000344152343727170012201 0ustar00U e5d|@sdZddlZeeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.8/asyncio/log.pys__pycache__/subprocess.cpython-38.opt-1.pyc000064400000016242152343727170014553 0ustar00U e5d@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsXeZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname____doc__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrBr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrGszProcess.send_signalcCs|jdSr:)r terminater7rrrrIszProcess.terminatecCs|jdSr:)rkillr7rrrrJsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrMr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|j}|jrJ|dkr8dnd}td|||IdH}|jr|dkrndnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rrrrKr rMreadr1)rr.r,r;nameoutputrrr _read_streams   zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rQrRrrVrrZgatherrrF)rrPrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrErFrGrIrJrQrRrVrWrrrrrAts  rAc sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellrA) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrYr&rZcs tdSr\r]rr%rrr^sz(create_subprocess_exec..r_)rr`rarbrcZsubprocess_execrA) Zprogramrrrr rargsrerfr,r'rr%rrs( r)__all__ subprocessrarrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr rAZ_DEFAULT_LIMITrrrrrrs.     bV __pycache__/__init__.cpython-38.opt-2.pyc000064400000001270152343727170014116 0ustar00U e5d@sddlZddlTddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl Tddl mZejejejejejejejeje je je je je jZejdkrddlTeej7ZnddlTeej7ZdS)N)*)_all_tasks_compatZwin32)sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r (/usr/lib64/python3.8/asyncio/__init__.pysX       __pycache__/__main__.cpython-38.opt-2.pyc000064400000006102152343727170014076 0ustar00U e5d @sJddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrFeZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez eWn6e k r>tr6t!s6t"d aYqYqXqFqdS) N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__(/usr/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__asyncio> __builtins____spec__r$__file__ __loader__ __package__FT)#r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$Znew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsF 6      __pycache__/transports.cpython-38.pyc000064400000027750152343727170013651 0ustar00U e5d(@s|dZdZGdddZGdddeZGdddeZGdd d eeZGd d d eZGd d d eZGdddeZdS)zAbstract Transport class.) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sHeZdZdZdZdddZdddZdd Zd d Zd d Z ddZ dS)rzBase class for transports._extraNcCs|dkr i}||_dSNr)selfextrar */usr/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||S)z#Get optional transport information.)rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdS)z2Return True if the transport is closing or closed.NNotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdS)aClose the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r closeszBaseTransport.closecCstdS)zSet a new protocol.Nr)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdS)zReturn the current protocol.Nrrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname____doc__ __slots__rrrrrrr r r r r s   rc@s,eZdZdZdZddZddZddZd S) rz#Interface for read-only transports.r cCstdS)z*Return True if the transport is receiving.Nrrr r r is_reading3szReadTransport.is_readingcCstdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. Nrrr r r pause_reading7szReadTransport.pause_readingcCstdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. Nrrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r"r r r r r.s rc@sNeZdZdZdZdddZddZdd Zd d Zd d Z ddZ ddZ dS)rz$Interface for write-only transports.r NcCstdS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. Nrr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdS)z,Return the current size of the write buffer.Nrrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. Nr)r datar r r writefszWriteTransport.writecCsd|}||dS)zWrite a list (or any iterable) of data bytes to the transport. The default implementation concatenates the arguments and calls write() on the result. N)joinr))r Z list_of_datar(r r r writelinesns zWriteTransport.writelinescCstdS)zClose the write end after flushing buffered data. (This is like typing ^D into a UNIX program reading from stdin.) Data may still be received. Nrrr r r write_eofwszWriteTransport.write_eofcCstdS)zAReturn True if this transport supports write_eof(), False if not.Nrrr r r can_write_eofszWriteTransport.can_write_eofcCstdSzClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. Nrrr r r abortszWriteTransport.abort)NN) rrrrrr&r'r)r,r-r.r0r r r r rHs   rc@seZdZdZdZdS)raSInterface representing a bidirectional transport. There may be several implementations, but typically, the user does not implement new transports; rather, the platform provides some useful transports that are implemented using the platform's best practices. The user never instantiates a transport directly; they call a utility function, passing it a protocol factory and other information necessary to create the transport and protocol. (E.g. EventLoop.create_connection() or EventLoop.create_server().) The utility function will asynchronously create a transport and a protocol and hook them up by calling the protocol's connection_made() method, passing it the transport. The implementation here raises NotImplemented for every method except writelines(), which calls write() in a loop. r N)rrrrrr r r r rsrc@s&eZdZdZdZdddZddZdS) rz(Interface for datagram (UDP) transports.r NcCstdS)aSend data to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. addr is target socket address. If addr is None use target address pointed on transport creation. Nr)r r(Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr/rrr r r r0szDatagramTransport.abort)N)rrrrrr1r0r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdS)zGet subprocess id.Nrrr r r get_pidszSubprocessTransport.get_pidcCstdS)zGet subprocess returncode. See also http://docs.python.org/3/library/subprocess#subprocess.Popen.returncode Nrrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdS)z&Get transport for pipe with number fd.Nr)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdS)zSend signal to subprocess. See also: docs.python.org/3/library/subprocess#subprocess.Popen.send_signal Nr)r signalr r r send_signalszSubprocessTransport.send_signalcCstdS)aLStop the subprocess. Alias for close() method. On Posix OSs the method sends SIGTERM to the subprocess. On Windows the Win32 API function TerminateProcess() is called to stop the subprocess. See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.terminate Nrrr r r terminates zSubprocessTransport.terminatecCstdS)zKill the subprocess. On Posix OSs the function sends SIGKILL to the subprocess. On Windows kill() is an alias for terminate(). See also: http://docs.python.org/3/library/subprocess#subprocess.Popen.kill Nrrr r r kills zSubprocessTransport.killN) rrrrr2r3r5r7r8r9r r r r rsrcsZeZdZdZdZdfdd ZddZdd Zd d Zdd d Z dddZ ddZ Z S)_FlowControlMixinavAll the logic for (write) flow control in a mix-in base class. The subclass must implement get_write_buffer_size(). It must call _maybe_pause_protocol() whenever the write buffer size increases, and _maybe_resume_protocol() whenever it decreases. It may also override set_write_buffer_limits() (e.g. to specify different defaults). The subclass constructor must call super().__init__(extra). This will call set_write_buffer_limits(). The user may call set_write_buffer_limits() and get_write_buffer_size(), and their protocol's pause_writing() and resume_writing() may be called. )_loop_protocol_paused _high_water _low_waterNcs0t||dk st||_d|_|dS)NF)superrAssertionErrorr;r<_set_write_buffer_limits)r r Zloop __class__r r rs   z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r'r=r< _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr;call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrD) r<r'r>rFZresume_writingrGrHrIr;rJ)r rLr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r>r=rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr=r>r#r r r rA4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r$r%)rArMr#r r r r&Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r'Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrrMrNrOrAr&r' __classcell__r r rBr r:s  r:N) r__all__rrrrrrr:r r r r s%F6__pycache__/staggered.cpython-38.pyc000064400000010030152343727170013356 0ustar00U e5dh @sdZdZddlZddlZddlmZddlmZddlmZddlm Z dd ej ej gej fej eejejejej eejej efd d d ZdS) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|zfd}|t krt IdH\}}t |}|D]$}| r|s|r|qqlfWSD] }| qXdS)aRun coroutines with staggered start times and take the first to finish. This method takes an iterable of coroutine functions. The first one is started immediately. From then on, whenever the immediately preceding one fails (raises an exception), or when *delay* seconds has passed, the next coroutine is started. This continues until one of the coroutines complete successfully, in which case all others are cancelled, or until all coroutines fail. The coroutines provided should be well-behaved in the following way: * They should only ``return`` if completed successfully. * They should always raise an exception if they did not complete successfully. In particular, if they handle cancellation, they should probably reraise, like this:: try: # do work except asyncio.CancelledError: # undo partially completed work raise Args: coro_fns: an iterable of coroutine functions, i.e. callables that return a coroutine object when called. Use ``functools.partial`` or lambdas to pass arguments. delay: amount of time, in seconds, between starting coroutines. If ``None``, the coroutines will run sequentially. loop: the event loop to use. Returns: tuple *(winner_result, winner_index, exceptions)* where - *winner_result*: the result of the winning coroutine, or ``None`` if no coroutines won. - *winner_index*: the index of the winning coroutine in ``coro_fns``, or ``None`` if no coroutines won. If the winning coroutine may return None on success, *winner_index* can be used to definitively determine whether any coroutine won. - *exceptions*: list of exceptions returned by the coroutines. ``len(exceptions)`` is equal to the number of coroutines actually started, and the order is the same as in ``coro_fns``. The winning coroutine's entry is ``None``. N)previous_failedr c sN|dk r6ttjt|IdHW5QRXzt\}}Wntk r\YdSXt } |} |t |dkst dt |dkstz|IdH}WnLttfk rYnptk r }z||<|W5d}~XYn>Xdkst||tD]\}}||kr,|q,dS)Nr) contextlibsuppressexceptions_mod TimeoutErrorrZwait_forwaitnext StopIterationrEvent create_taskappendlenAssertionError SystemExitKeyboardInterrupt BaseExceptionset enumeratecancel) r Z this_indexZcoro_fnZ this_failedZ next_taskresulteitr Z enum_coro_fnsrr run_one_coroZ running_tasksZ winner_indexZ winner_result)/usr/lib64/python3.8/asyncio/staggered.pyr%Rs4    z$staggered_race..run_one_coror)rZget_running_looprtypingOptionalrrrrrrrrdoneZ cancelledZ exception) r r rZ first_taskr#Z done_countr*_dr&r$r'rs,=  0   r)__doc____all__rr(rrrrrIterableCallable Awaitabler)floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr&r&r&r's&    __pycache__/__main__.cpython-38.pyc000064400000006102152343727170013136 0ustar00U e5d @sJddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z Gdddej Z GdddejZedkrFeZeed eiZd D]Zeeee<qe eeZdad az ddlZWnek rYnXeZd e_ez eWn6e k r>tr6t!s6t"d aYqYqXqFqdS) N)futurescs$eZdZfddZddZZS)AsyncIOInteractiveConsolecs*t||jjjtjO_||_dS)N)super__init__compileZcompilerflagsastZPyCF_ALLOW_TOP_LEVEL_AWAITloop)selflocalsr  __class__(/usr/lib64/python3.8/asyncio/__main__.pyrs z"AsyncIOInteractiveConsole.__init__csttjfdd}t|z WStk rDYn,tk rntrb dn YnXdS)Nc sdadatj}z |}Wnztk r6Ynftk rj}zda|WYdSd}~XYn2tk r}z|WYdSd}~XYnXt |s |dSzj |attWn.tk r}z|W5d}~XYnXdS)NFT) repl_futurerepl_future_interruptedtypes FunctionTyper SystemExitKeyboardInterruptZ set_exception BaseExceptioninspectZ iscoroutineZ set_resultr Z create_taskrZ _chain_future)funccoroZexexccodeZfuturer rrcallbacks,      z3AsyncIOInteractiveConsole.runcode..callbackz KeyboardInterrupt ) concurrentrZFuturer call_soon_threadsaferesultrrrwriteZ showtraceback)r rrrrrruncodes    z!AsyncIOInteractiveConsole.runcode)__name__ __module__ __qualname__rr# __classcell__rrr rrs rc@seZdZddZdS) REPLThreadc CsZz6dtjdtjdt tddd }t j |d d W5tjddtdttjXdS) Nignorez ^coroutine .* was never awaited$)messagecategoryz asyncio REPL z on zy Use "await" directly instead of "asyncio.run()". Type "help", "copyright", "credits" or "license" for more information. Zps1z>>> zimport asynciozexiting asyncio REPL...)bannerZexitmsg) warningsfilterwarningsRuntimeWarningr r stopsysversionplatformgetattrconsoleZinteract)r r,rrrrunFs" zREPLThread.runN)r$r%r&r6rrrrr(Dsr(__main__asyncio> __builtins____spec__r$__file__ __loader__ __package__FT)#r r8rZconcurrent.futuresrrr1Z threadingrr-rZInteractiveConsolerZThreadr(r$Znew_event_loopr Zset_event_loopZ repl_localskeyr r5rrreadline ImportErrorZ repl_threadZdaemonstartZ run_foreverrZdoneZcancelrrrrsF 6      __pycache__/runners.cpython-38.opt-2.pyc000064400000002363152343727170014057 0ustar00U e5d@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr'/usr/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .__pycache__/__init__.cpython-38.pyc000064400000001360152343727170013156 0ustar00U e5d@sdZddlZddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddl mZejejejejejejeje je je je je jejZejdkrddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N)*)_all_tasks_compatZwin32)__doc__sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r (/usr/lib64/python3.8/asyncio/__init__.pysZ       __pycache__/sslproto.cpython-38.opt-2.pyc000064400000034431152343727170014251 0ustar00U e5dJj@sddlZddlZz ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d Z d Z d Zd ZGdddeZGdddejejZGdddejZdS)N) base_events) constants) protocols) transports)loggercCs"|r tdt}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslZcreate_default_contextZcheck_hostname) server_sideserver_hostname sslcontextr (/usr/lib64/python3.8/asyncio/sslproto.py_create_transport_contexts rZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@szeZdZdZdddZeddZeddZed d Zed d Z dd dZ dddZ ddZ dddZ dddZdS)_SSLPipeiNcCsH||_||_||_t|_t|_t|_d|_ d|_ d|_ d|_ dSNF) _context _server_side_server_hostname _UNWRAPPED_stater Z MemoryBIO _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextr r r r r__init__8s   z_SSLPipe.__init__cCs|jSN)rrr r rrNsz_SSLPipe.contextcCs|jSr )rr!r r r ssl_objectSsz_SSLPipe.ssl_objectcCs|jSr )rr!r r r need_ssldata[sz_SSLPipe.need_ssldatacCs |jtkSr )r_WRAPPEDr!r r rwrappedasz_SSLPipe.wrappedcCsR|jtkrtd|jj|j|j|j|jd|_ t |_||_ |j ddd\}}|S)Nz"handshake in progress or completed)r r T)only_handshake) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr feed_ssldatarcallbackssldataappdatar r r do_handshakejs z_SSLPipe.do_handshakecCsB|jtkrtd|jtkr$tdt|_||_|d\}}|S)Nzno security layer presentzshutdown in progressr&)rrr( _SHUTDOWNrr*r+r r rshutdowns  z_SSLPipe.shutdowncCs|j|d\}}dS)Nr&)rZ write_eofr*)rr-r.r r rfeed_eofs z_SSLPipe.feed_eofFc Cs|jtkr"|r|g}ng}g|fSd|_|r8|j|g}g}z|jtkrz|jt|_|j rl| d|rz||fWS|jtkr|j |j }| ||sqqnJ|jt kr|jd|_t|_|jr|n|jtkr| |j Wnztjtjfk rl}zRt|dd}|tjtjtjfkrP|jtkrN|j rN| ||tjk|_W5d}~XYnX|jjr| |j ||fS)NFerrno)rrrrwriter)rr/r$rreadmax_sizeappendr0Zunwraprr SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLrpending)rdatar'r.r-chunkexc exc_errnor r rr*sZ               z_SSLPipe.feed_ssldatarc Cs|jtkr6|t|kr&||dg}ng}|t|fSg}t|}d|_z(|t|krn||j||d7}Wnhtjk r}zHt |dd}|j dkrtj }|_ |tj tj tjfkr|tj k|_W5d}~XYnX|jjr||j|t|ks |jrBq qB||fS)NFr3ZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewrrr4r r8r:reasonr;r3r<r=rr>r7r5)rr?offsetr-ZviewrArBr r r feed_appdatas4       z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname__r6rpropertyrr"r#r%r/r1r2r*rGr r r rr$s        Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dSr)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||Sr )rN_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSr )rN_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSr )rN _app_protocolr!r r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSr )rOr!r r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdSNT)rOrN_start_shutdownr!r r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rOResourceWarningr^)rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rN _transportr( is_reading)rZtrr r rrcDsz _SSLProtocolTransport.is_readingcCs|jjdSr )rNrb pause_readingr!r r rrdJsz#_SSLProtocolTransport.pause_readingcCs|jjdSr )rNrbresume_readingr!r r rreRsz$_SSLProtocolTransport.resume_readingcCs|jj||dSr )rNrbset_write_buffer_limits)rZhighZlowr r rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjSr )rNrbget_write_buffer_sizer!r r rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSr )rNrb_protocol_pausedr!r r rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)Nz+data: expecting a bytes-like instance, got ) isinstancebytes bytearrayrD TypeErrortyperHrN_write_appdatarr?r r rr4xs z_SSLProtocolTransport.writecCsdSrr r!r r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dSr\)rN_abortrOr!r r raborts z_SSLProtocolTransport.abort)N)NN)rHrIrJrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrUrXrZr[r^warningswarnrarcrdrerfrgrKrhr4rprrr r r rrLs$     rLc@seZdZd+ddZddZd,dd Zd d Zd d ZddZddZ ddZ ddZ d-ddZ ddZ ddZddZddZd d!Zd"d#Zd.d%d&Zd'd(Zd)d*ZdS)/ SSLProtocolFNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r(rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrMrVrL_app_transport_sslpipe_session_established _in_handshake _in_shutdownrb_call_connection_made_ssl_handshake_timeout) rrP app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSr )rYrirZBufferedProtocol_app_protocol_is_buffer)rrr r rrVs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSr )r}Z cancelledZ set_exceptionZ set_resultrrAr r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dSr )rbrrvrrr_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)NFT_handshake_timeout_handle) rrM call_soonrYconnection_lostr~rOrbr:rcancelrrrr r rrs    zSSLProtocol.connection_lostcCs|jdSr )rY pause_writingr!r r rrszSSLProtocol.pause_writingcCs|jdSr )rYresume_writingr!r r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)NzSSL error in data receivedz/application protocol failed to receive SSL data)rr* SystemExitKeyboardInterrupt BaseException _fatal_errorrbr4rrZ_feed_data_to_buffered_protorY data_receivedr])rr?r-r.er@Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)Nz%r received EOFz?returning true from eof_received() has no effect when using ssl) rbr^rM get_debugrdebugrConnectionResetErrorrrY eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSr )rxrbrUrRr r rrQCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr&)rrrqrnr!r r rr]Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)r{r7r|rC_process_write_backlogror r rrnTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r&r)rMrrrtime_handshake_start_timerr{r7Z call_laterr_check_handshake_timeoutrrr!r r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr"T)rrrrr"Z getpeercertrrrrir r9rrMrrrrrrxupdaterrrrYrr~rrrr)rZ handshake_excZsslobjrrArZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsB|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj r|j q|jd=|j t|8_ q(Wn\ttfk rYnDtk r<}z$|jr ||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rbrrangerCr{rGr/rr1 _finalizer4Z_pausedrer|rrrrr)rir?rFr-r@rAr r rrs:   z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrW) riOSErrorrMrrrZcall_exception_handlerrbZ _force_close)rrArr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSr )rrbr^r!r r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSr )rrbrrr!r r rrqs zSSLProtocol._abort)FNTN)N)N)r)rHrIrJrrVrrrrrrrrQr]rnrrrrrrrqr r r rrus. .  &   )+ ru)ryrsr ImportErrorrrrrlogrrrr)r$r0objectrZ_FlowControlMixinZ TransportrLZProtocolrur r r rs*       yx__pycache__/format_helpers.cpython-38.opt-1.pyc000064400000004436152343727170015377 0ustar00U e5dd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   __pycache__/staggered.cpython-38.opt-1.pyc000064400000007553152343727170014335 0ustar00U e5dh @sdZdZddlZddlZddlmZddlmZddlmZddlm Z dd ej ej gej fej eejejejej eejej efd d d ZdS) zFSupport for running coroutines in parallel with staggered start times.)staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|z.run_one_coror) rZget_running_looprtypingOptionalrrrrrlenrr)r r rZ first_taskr Z done_countZdone_r#r!r$rs(=  0  r)__doc____all__r r%rrrrrIterableCallable Awaitabler&floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr#r#r#r$s&    __pycache__/base_events.cpython-38.pyc000064400000143516152343727170013727 0ustar00U e5d@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%e dZ&dZ'e(Z)ddZ*ddZ+ddZ,d+ddZ-d,ddZ.dd Z/e%e d!rd"d#Z0nd$d#Z0Gd%d&d&ej1Z2Gd'd(d(ej3Z4Gd)d*d*ej5Z6dS)-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) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr+/usr/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)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"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs |jdk st|jd7_dSrZ)rAssertionErrorrrqrrr_attach#szServer._attachcCs<|jdkst|jd8_|jdkr8|jdkr8|dS)Nrr)rrr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdS)NT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.r)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)zDSchedule a coroutine object. Return a task object. N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)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)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)zRun until stop() is called.) firstiter finalizerFN)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|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)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)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)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrr rr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r)c s2|jr|j}ntj}|d|||||||IdHSrB)rr.r$r'r)rfr;r<r=r>r?r)Z getaddr_funcrrrr'2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr)rrrr0<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr1rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr4rfr*r6r7r8rrrr3Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r<minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r6r7r8 blocksizebuf total_sentviewreadrrrr5Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)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%r>r$r1rr4r5formatr;rrrr2os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)z$Create, bind and connect one socket.Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr*rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r)r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfd d |D| d IdH\}}}|dkr d d Dt dkrdnJt dt fdd Dr҈dtd d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r)r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrS)rCr,)r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r%css|]}t|VqdSrBr`rarrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrSr Zstaggered_racerrallrHr&r>_create_connection_transportrget_extra_inforr )rfrr;r<rTr=r?r)r*rUrrrVrWinfosr,rRrnrr)rr^rbrfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rKrdrboolrrr) rfr*rrTrrrrrrrnrrrrf%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)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 closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr4_sendfile_fallback)rfrnr6r7r8r1rGrWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr:)rfrgr6r7r8rrrrlnszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr<) r<r=r>r\r#r{r?rr@rkwrite) rfrgr6r7r8rArBrCr?rDrErrrrmrs* z BaseEventLoop._sendfile_fallbackrjc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS) zzUpgrade transport to TLS. Return a new transport that *protocol* should start using immediately. Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rTrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r) reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| d d} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st dqڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk rt |trt|dkstd|j||tj|||dIdH}|std|D]:\}}}}}||f}||kr0ddg||<||||<qqfdd|D}|sjtdg}|tk r|rtdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tj tj!d| d r| "|r*| s&|#| |IdH|} Wn^tk rl}z | dk rR| $|%|W5d}~XYn&| dk r| $YnXqq|d |}|&}|'| || |}|j(rrt)d||nt*d||z|IdHWn|$YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rU remote_addrr=r?r)rrrsrtr%css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrr!z2-tuple is expectedrZr[cs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrUrurrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.) stacklevelrIz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))+r>r$r2r%dictr&itemsrKr#rzrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorrrrrd_unsetrrr"r+r&r'Z SO_BROADCASTrLrQrr9rdrrr(r ) rfrrUrur=r?r)rrrsrtr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxrhZfamrRZprorr|rZ local_addressZremote_addressrWrrrnrr}rcreate_datagram_endpoints*                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nr!r/)rAr') rfrr=r>r?r)rr;r<r(rrrrdLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r)rz getaddrinfo(z) returned empty list)rdr$r1r()rfr;r<r=r)rhrrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r)r*rrTrrrsrrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd |D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d dYqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)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 NoneNrXrYposixcygwinr.csg|]}j|dqS))r=r))r)rCr;r=r)r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrcrrz %r is serving).rrkr5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrLr(rOrMrNr>r1rKrrrr()rfrr;r<r=r)r*rrTrrrsrrrZhostsZfsrhZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rTrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS) aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. rcNrXr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rfrrgrr )rfrr*rTrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrr filenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrr rrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrr r&)rfr*rrrr(rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) 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) rr3rr%rrrrr()rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr()rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)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 )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrd t|}d }|| 7}n2|dkrd t|}d }|| 7}nt |}| |d |qnt j d ||ddS)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()`. rz!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>rrRr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rJ r)getr> __traceback__rrsortedr& traceback format_listrstriprr9rr) rfr rrRrZ log_linesr|valuetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)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 handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrprr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs>t|tjstd|jrdSt|tjr.t|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.zA Handle is required hereN)rrrr _cancelledrrr9rfrrrr _add_callbacks zBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsd                  ;   Do__pycache__/events.cpython-38.opt-2.pyc000064400000044723152343727170013675 0ustar00U e5d4f@sxdZddlZddlZddlZddlZddlZddlZddlmZddlm Z GdddZ Gdd d e Z Gd d d Z Gd d d Z GdddZGdddeZdaeZGdddejZeZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Z eZ!eZ"eZ#eZ$zdd*l%mZmZmZmZWne&k rbYnXeZ'eZ(eZ)eZ*dS)+)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpers) exceptionsc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)r) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|dkrt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr&&/usr/lib64/python3.8/asyncio/events.py__init__ s zHandle.__init__cCsl|jjg}|jr|d|jdk r:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r!infoframer&r&r' _repr_info/s    zHandle._repr_infocCs(|jdk r|jS|}dd|S)Nz<{}> )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcs~eZdZddgZdfdd ZfddZdd Zd d Zd d ZddZ ddZ ddZ ddZ fddZ ddZZS)r _scheduled_whenNcs0t|||||jr |jd=||_d|_dS)Nr*F)superr(rrKrJ)r!whenr"r#r$r%r,r&r'r(hs zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rLr2rinsertrK)r!r0posrNr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrKr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rKr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rK__eq__rUr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rTrUr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rXrUr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrKrrrNotImplementedrUr&r&r'rYs     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)rYr^)r!rVZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrLr:r9rNr&r'r:s zTimerHandle.cancelcCs|jSr;rTr9r&r&r'rMszTimerHandle.when)N)r-rGrHrIr(r2rSrWrZr[r\rYr_r:rM __classcell__r&r&rNr'rcs  rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)rcCstdSr;NotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdSr;rbr9r&r&r'get_loopszAbstractServer.get_loopcCstdSr;rbr9r&r&r' is_servingszAbstractServer.is_servingcstdSr;rbr9r&r&r' start_servingszAbstractServer.start_servingcstdSr;rbr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdSr;rbr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rdri)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrdrerfrgrhrirjrkr&r&r&r'rsrc @sReZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddddZdd Zd!d"Zd#d$Zd%d%d%d%d&d'd(Zdtd)d*Zdudd%d%d%ddddddd+ d,d-Zdvejejdd.ddddd/d0 d1d2Zdwd/d3d4d5Zd6ddd7d8d9Zdxddddd:d;d<Zdydd.ddd/d=d>d?Zdzd%d%d%ddddd@dAdBZdCdDZ dEdFZ!e"j#e"j#e"j#dGdHdIZ$e"j#e"j#e"j#dGdJdKZ%dLdMZ&dNdOZ'dPdQZ(dRdSZ)dTdUZ*dVdWZ+dXdYZ,dZd[Z-d\d]Z.d{dd3d^d_Z/d`daZ0dbdcZ1dddeZ2dfdgZ3dhdiZ4djdkZ5dldmZ6dndoZ7dpdqZ8drdsZ9dS)|rcCstdSr;rbr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdSr;rb)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdSr;rbr9r&r&r'stopszAbstractEventLoop.stopcCstdSr;rbr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdSr;rbr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdSr;rbr9r&r&r'rds zAbstractEventLoop.closecstdSr;rbr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdSr;rb)r!r=r&r&r'r`sz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rb)r!Zdelayr"r#r&r&r'rrszAbstractEventLoop.call_latercGstdSr;rb)r!rMr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rbr9r&r&r'time szAbstractEventLoop.timecCstdSr;rbr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rb)r!cororxr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rbrsr&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rb)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rb)r!r|r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rb)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rb)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rb)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrrgc stdSr;rb) r!rrrrrrrrrrrrgr&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdSr;rb)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdSr;rb)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rb)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrrgcstdSr;rb)r!rrrrrrrgr&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdSr;rb) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdSr;rbr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdSr;rbrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rb)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rb)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rbr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rbr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rbrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rbrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rb)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rb)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rb)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rb)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rb)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rb)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rb)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rb)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rb)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rbr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rbr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rb)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rbr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rbrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rbr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rb)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN):r-rGrHrlrmrnrorprdrqr`rtrrrurvrwrzr{r~rrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s4eZdZddZddZddZddZd d Zd S) rcCstdSr;rbr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdSr;rbr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdSr;rbr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdSr;rbr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdSr;rb)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN)r-rGrHrr r r r r&r&r&r'r<s  rc@sBeZdZdZGdddejZddZddZdd Z d d Z dS) BaseDefaultEventLoopPolicyNc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)Nz,There is no current event loop in thread %r.) rrrr] threadingZcurrent_threadZ _MainThreadr r RuntimeErrorrxr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dSr7)rrrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|Sr;) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrrlocalrr(rr r r&r&r&r'r^s  rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdSr;) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dSr;)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttSr;)rrr&r&r&r'rsrcCs|adSr;)r)Zpolicyr&r&r'rsrcCst}|dk r|StSr;)rrr)Z current_loopr&r&r'rs rcCst|dSr;)rr rr&r&r'r sr cCs tSr;)rr r&r&r&r'r sr cCs tSr;)rr r&r&r&r'r sr cCs t|Sr;)rr )rr&r&r'r sr )rr rr)+__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sV   J@*q"9    __pycache__/windows_events.cpython-38.opt-2.pyc000064400000055626152343727170015453 0ustar00U e5di@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd lmZd ZdZd ZdZdZdZdZGddde jZGddde jZGdddeZGdddeZGddde Z!Gdddej"Z#Gdddej$Z%Gd d!d!Z&Gd"d#d#e j'Z(e#Z)Gd$d%d%e j*Z+Gd&d'd'e j*Z,e,Z-dS)(N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?csZeZdZddfdd ZfddZddZfd d Zfd d Zfd dZZ S)_OverlappedFutureNloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname__rr%r6r0r9r; __classcell__r r rr!r+s    rcsjeZdZddfdd ZddZfddZd d Zd d Zfd dZfddZ fddZ Z S)_BaseWaitHandleFutureNrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrCZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrCrJrDr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rErD _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rNrrGr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rTrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rTrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rTrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rrJr%rNrTr0r9r;rAr r rr!rB[s   rBcsBeZdZddfdd ZddZfddZfd d ZZS) _WaitCancelFutureNrcstj||||dd|_dS)Nr)rr_done_callback)rreventrGrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rVr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rVr:rr r!r9s  z_WaitCancelFuture.set_exception)r>r?r@rr0r;r9rAr r rr!rUs rUcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrPZ CreateEvent_event _event_fut)rrrFrGproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r[rI CloseHandler\rZ _unregisterrrrNrLrr r!rNs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrO)rErDrPZUnregisterWaitExr[r1rQrRrr2r3rZ _wait_cancelrNr\rSr r r!rTs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrNrTrAr r rr!rYs rYc@s8eZdZddZddZddZddZd d ZeZd S) PipeServercCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|SNF)rgri)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrIZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPipercZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlerfadd)rfirstflagshpiper r r!ris(     zPipeServer._server_pipe_handlecCs |jdkSr7)rcr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rhr0rcrfclosergclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rrlrirmru__del__r r r r!ras   rac@s eZdZdS)_WindowsSelectorEventLoopN)r>r?r@r r r r!rx,srxcsDeZdZd fdd ZfddZddZdd Zd d d ZZS)r Ncs|dkrt}t|dSr7)rrr)rr]rr r!r3szProactorEventLoop.__init__c sXz||jtW5|jdk rR|jj}|j|dk rL|j|d|_XdSr7) Z_self_reading_futurerr0rZr_ call_soonZ_loop_self_readingr run_foreverrrrr r!rz8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)rZ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rfdiscardrmrurrlrZ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorrhadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rary)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr~) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizer~kwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rrzrrrrAr r rr!r 0s  0r c@seZdZd:ddZddZddZdd Zd;d d Zd dZdddZ d?ddZ d@ddZ ddZddZddZd d!Zd"d#ZdAd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1ZdBd2d3Zd4d5Zd6d7Zd8d9Zd S)CrrcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrH) r2_resultsrPCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cacherdrerE _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrXr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrKrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrJ)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerMr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rQrPZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprP Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrPrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrPrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrPrrnZ WSASendTorr)rrrrrr|rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrPrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrPZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrPrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrH)rrrrrPZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrPZ WSAConnectrr2rr;rZ BindLocalrr1rQerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rMerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrPrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrPrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrPZ ConnectPiper1rQZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrFr4r r r!rs  zIocpProactor.connect_pipecCs|||dSrj)_wait_for_handle)rrFrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Srb)rrV)rrWZ done_callbackrMr r r!r`szIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rJrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrIINFINITEmathceilrPrrnZRegisterWaitWithQueuerr'rUr2rYrr)rrFrZ _is_cancelmsrrGrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrH)rErprPrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dSr7)rrrKr{r r r!r_szIocpProactor._unregistercCst|}|d|SrH)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrPZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrIr^rr0Zdoner1r9rrKr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rJsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrUr0r1r2rr3time monotonicr debugrJrrIr^) rr'rMrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rrrrrrrrrrrrrrrrrr`rrrr_rrJrrurwr r r r!rs6        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2rZrintrCr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr).rPrIrrrrrrrdrrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrBrUrYobjectraZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sP         0J4;e`__pycache__/protocols.cpython-38.opt-1.pyc000064400000020650152343727170014405 0ustar00U e5d@sbdZdZGdddZGdddeZGdddeZGdd d eZGd d d eZd d ZdS)zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s4eZdZdZdZddZddZddZd d Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)selfZ transportrr)/usr/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrrexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrrrrr pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrr rrrresume_writing;szBaseProtocol.resume_writingN) __name__ __module__ __qualname____doc__ __slots__r r rrrrrrr s  rc@s$eZdZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_received^szProtocol.data_receivedcCsdSzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrr rrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZddZddZddZd S) raInterface for stream protocol with manual buffer control. Important: this has been added to asyncio in Python 3.7 *on a provisional basis*! Consider it as an experimental API that might be changed or removed in Python 3.8. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcCsdS)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdS)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)rnbytesrrrbuffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrr rrrrszBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms  rc@s$eZdZdZdZddZddZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrr rrrerror_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrrrrsrc@s,eZdZdZdZddZddZddZd S) rz,Interface for protocol for subprocess calls.rcCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr rrrprocess_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrrs rcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr_feed_data_to_buffered_protos     r&N)r__all__rrrrrr&rrrrs9+9__pycache__/base_futures.cpython-38.opt-1.pyc000064400000003554152343727170015054 0ustar00U e5d @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)zCheck for a Future. This returns True when obj is a Future instance or is advertising itself as duck-type compatible by setting _asyncio_future_blocking. See comment in Future for more details. _asyncio_future_blockingN)hasattr __class__r)objrr,/usr/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) #helper function for Future.__repr__cSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d |S) r Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r&)__all__r _threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr&rrrr s   __pycache__/staggered.cpython-38.opt-2.pyc000064400000003426152343727170014331 0ustar00U e5dh @sdZddlZddlZddlmZddlmZddlmZddlmZddej ej gej fej e ejejejej eejej efd d d ZdS) )staggered_raceN)events) exceptions)locks)tasks)loop)coro_fnsdelayrreturnc sp tt|ddggtjtjddfdd d}|z.run_one_coror) rZget_running_looprtypingOptionalrrrrrlenrr)r r rZ first_taskr Z done_countZdone_r#r!r$rs(=  0  r)__all__r r%rrrrrIterableCallable Awaitabler&floatZAbstractEventLoopZTupleZAnyintZList Exceptionrr#r#r#r$s$    __pycache__/trsock.cpython-38.opt-2.pyc000064400000020045152343727170013665 0ustar00U e5d@s"ddlZddlZGdddZdS)Nc@seZdZdZejdddZddZeddZed d Z ed d Z d dZ ddZ ddZ ddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Z d9d:Z!d;d<Z"d=d>Z#d?d@Z$dAdBZ%dCdDZ&dEdFZ'dGdHZ(dIdJZ)dKdLZ*dMdNZ+dOdPZ,dQdRZ-dSdTZ.dUdVZ/dWdXZ0dYdZZ1d[S)\TransportSocket_sock)sockcCs ||_dSNr)selfrr&/usr/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rs`    r)rr rrrrr s__pycache__/log.cpython-38.opt-2.pyc000064400000000275152343727170013144 0ustar00U e5d|@sddlZeeZdS)N)ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.8/asyncio/log.pys__pycache__/trsock.cpython-38.pyc000064400000020445152343727170012731 0ustar00U e5d@s"ddlZddlZGdddZdS)Nc@seZdZdZdZejdddZddZedd Z ed d Z ed d Z ddZ ddZ ddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(dHdIZ)dJdKZ*dLdMZ+dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d\S)]TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _sock)sockcCs ||_dSNr)selfrr&/usr/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rsb   r)rr rrrrr s__pycache__/format_helpers.cpython-38.opt-2.pyc000064400000004052152343727170015372 0ustar00U e5dd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   __pycache__/base_subprocess.cpython-38.pyc000064400000022312152343727170014601 0ustar00U e5d"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd 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 s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} 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__//usr/lib64/python3.8/asyncio/base_subprocess.pyr sL            z BaseSubprocessTransport.__init__cCs|jjg}|jr|d|jdk r6|d|j|jdk rT|d|jn |jdk rj|dn |d|jd}|dk r|d|j|jd}|jd }|dk r||kr|d |jn6|dk r|d |j|dk r |d |jd d |S)Nclosedzpid=z returncode=Zrunningz not startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}> ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc spzj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<jdk st | j j jD]\}}|j |f|qd_Wn\t tfk r Yn`tk rL}z"|dk r<|s<||W5d}~XYn X|dk rl|sl|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper rAssertionError call_soonrconnection_made SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&sB          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrV)r'cbr`r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rcrZpipe_connection_lost _try_finish)r'rJrar.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rcrZpipe_data_received)r'rJr`r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCs|dk st||jdks$t|j|jrsz6BaseSubprocessTransport._try_finish..T)rrUrallrrArc_call_connection_lostr>r.r.r/rds  z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'rar.r.r/ros z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rcrerfrhrirdro __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r]rJr5rj)r'r]rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rWsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rjr]rerJrqr.r.r/rp sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r]r pause_writingr>r.r.r/rysz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r]rresume_writingr>r.r.r/rzsz'WriteSubprocessPipeProto.resume_writingN) r2rrrsrrWr9rpryrzr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r]rfrJ)r'r`r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rrrsr{r.r.r.r/rTsrT)rrrtrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v __pycache__/runners.cpython-38.pyc000064400000003635152343727170013122 0ustar00U e5d@sBdZddlmZddlmZddlmZddddZd d ZdS) )run) coroutines)events)tasksN)debugcCstdk rtdt|s,td|t}z*t||dk rR| || |WSzt || | W5td| XXdS)aExecute the coroutine and return the result. This function runs the passed coroutine, taking care of managing the asyncio event loop and finalizing asynchronous generators. This function cannot be called when another asyncio event loop is running in the same thread. If debug is True, the event loop will be run in debug mode. This function always creates a new event loop and closes it at the end. It should be used as a main entry point for asyncio programs, and should ideally only be called once. Example: async def main(): await asyncio.sleep(1) print('hello') asyncio.run(main()) Nz8asyncio.run() cannot be called from a running event loopz"a coroutine was expected, got {!r})rZ_get_running_loop RuntimeErrorrZ iscoroutine ValueErrorformatZnew_event_loopZset_event_loopclose_cancel_all_tasksrun_until_completeZshutdown_asyncgensZ set_debug)mainrloopr'/usr/lib64/python3.8/asyncio/runners.pyrs"     rcCsvt|}|sdS|D] }|q|tj||dd|D]0}|rNq@|dk r@|d||dq@dS)NT)rZreturn_exceptionsz1unhandled exception during asyncio.run() shutdown)message exceptiontask)rZ all_tasksZcancelr ZgatherZ cancelledrZcall_exception_handler)rZ to_cancelrrrrr 6s"   r )__all__rrrrr rrrrs    .__pycache__/futures.cpython-38.opt-1.pyc000064400000025412152343727170014057 0ustar00U e5db3@sdZdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ej Z ej Z ejZejZejdZGd d d ZeZd d Zd dZddZddZddZddZddddZz ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZd d Zed d Zejd d ZddZddZddZddZddZddZddZddddZdd Zd!d"Zd#d$Zd%d&Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r/r1rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r/r1rr:r;r<r#r$rrrrr!s    zFuture.exceptionr4cCsB|jtkr|jj|||dn |dkr.t}|j||fdS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. r4N)r/r0r r5 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs g|]\}}|kr||fqSrr).0fr7rArr sz/Future.remove_done_callback..N)rlen)rrAZfiltered_callbacksZ removed_countrrErremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r/r0rr<r=r;r2)rr>rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN) r/r0rr< isinstancetype StopIteration TypeErrorr$r;r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r9_asyncio_future_blockingr-r>rrrr __await__s zFuture.__await__)"r __module__ __qualname____doc__r0r/r=r$r rrPr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r8r9r>r!rBrHrJrOrQ__iter__rrrrrs:    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rL concurrentfuturesr:rargs TimeoutErrorr<)r%Z exc_classrrr_convert_future_exc#s      r`cCsR|r||sdS|}|dk r<|t|n|}||dS)z8Copy state from a future to a concurrent.futures.Future.N)r8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\sourcer!r>rrr_set_concurrent_future_state/srbcCsT|r dS|r|n2|}|dk r>|t|n|}||dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N)r8r3r!rOr`r>rJ)radestr!r>rrr_copy_future_state>s rdcststtjjstdts._set_statecs2|r.dkskr"n jdSr()r8r3call_soon_threadsafe) destination) dest_loopra source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r8Z is_closedrg)ra)rfrirhrjrr_call_set_stateos z&_chain_future.._call_set_state)rrKr\r]rrNrZrB)rarhrkrlr)rfrirhrarjr _chain_futureRs   rmr cCs2t|r |S|dkrt}|}t|||S)z&Wrap concurrent.futures.Future object.N)rrr Z create_futurerm)r"r Z new_futurerrrr|s r)rT__all__Zconcurrent.futuresr\r?Zloggingrrrrr rr0r1r;DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rbrdrmrZ_asyncio ImportErrorZ_CFuturerrrrs:     q  *  __pycache__/exceptions.cpython-38.opt-2.pyc000064400000003563152343727170014547 0ustar00U e5da@shdZGdddeZGdddeZGdddeZGdddeZGd d d eZ Gd d d eZ d S))CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@s eZdZdS)rN__name__ __module__ __qualname__r r */usr/lib64/python3.8/asyncio/exceptions.pyr src@s eZdZdS)rNrr r r r r src@s eZdZdS)rNrr r r r rsrc@s eZdZdS)rNrr r r r rsrcs$eZdZfddZddZZS)rcs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r rr __classcell__r r rr rs rcs$eZdZfddZddZZS)rcst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r s __pycache__/events.cpython-38.opt-1.pyc000064400000066457152343727170013704 0ustar00U e5d4f@s|dZdZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z GdddZ Gd d d e Z Gd d d Z Gd ddZGdddZGdddeZdaeZGdddejZeZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Z d)d*Z!eZ"eZ#eZ$eZ%zdd+l&mZmZmZmZWne'k rfYnXeZ(eZ)eZ*eZ+dS),z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpers) exceptionsc@sFeZdZdZdZdddZddZdd Zd d Zd d Z ddZ dS)rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|dkrt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr&&/usr/lib64/python3.8/asyncio/events.py__init__ s zHandle.__init__cCsl|jjg}|jr|d|jdk r:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r!infoframer&r&r' _repr_info/s    zHandle._repr_infocCs(|jdk r|jS|}dd|S)Nz<{}> )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname____doc__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcseZdZdZddgZdfdd ZfddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ fddZddZZS)rz7Object returned by timed callback registration methods. _scheduled_whenNcs0t|||||jr |jd=||_d|_dS)Nr*F)superr(rrLrK)r!whenr"r#r$r%r,r&r'r(hs zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rMr2rinsertrL)r!r0posrOr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrLr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rLr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rL__eq__rVr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rUrVr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rYrVr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrLrrrNotImplementedrVr&r&r'rZs     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)rZr_)r!rWZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrMr:r9rOr&r'r:s zTimerHandle.cancelcCs|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). rUr9r&r&r'rNszTimerHandle.when)N)r-rGrHrIrJr(r2rTrXr[r\r]rZr`r:rN __classcell__r&r&rOr'rcs  rc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rz,Abstract server returned by create_server().cCstdS)z5Stop serving. This leaves existing connections open.NNotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdS)z4Get the event loop the Server object is attached to.Nrcr9r&r&r'get_loopszAbstractServer.get_loopcCstdS)z3Return True if the server is accepting connections.Nrcr9r&r&r' is_servingszAbstractServer.is_servingcstdS)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. Nrcr9r&r&r' start_servingszAbstractServer.start_servingcstdS)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. Nrcr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdS)z*Coroutine to wait until service is closed.Nrcr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rerj)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrIrerfrgrhrirjrkrlr&r&r&r'rsrc @sVeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddddZd d!Zd"d#Zd$d%Zd&d&d&d&d'd(d)Zdud*d+Zdvdd&d&d&ddddddd, d-d.Zdwejejdd/ddddd0d1 d2d3Zdxd0d4d5d6Zd7ddd8d9d:Zdyddddd;dd?d@Zd{d&d&d&dddddAdBdCZ dDdEZ!dFdGZ"e#j$e#j$e#j$dHdIdJZ%e#j$e#j$e#j$dHdKdLZ&dMdNZ'dOdPZ(dQdRZ)dSdTZ*dUdVZ+dWdXZ,dYdZZ-d[d\Z.d]d^Z/d|dd4d_d`Z0dadbZ1dcddZ2dedfZ3dgdhZ4didjZ5dkdlZ6dmdnZ7dodpZ8dqdrZ9dsdtZ:dS)}rzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.Nrcr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. Nrc)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. Nrcr9r&r&r'stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.Nrcr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.Nrcr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. Nrcr9r&r&r'res zAbstractEventLoop.closecstdS)z,Shutdown all active asynchronous generators.Nrcr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.Nrc)r!r=r&r&r'rasz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rc)r!Zdelayr"r#r&r&r'rsszAbstractEventLoop.call_latercGstdSr;rc)r!rNr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rcr9r&r&r'time szAbstractEventLoop.timecCstdSr;rcr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rc)r!cororyr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rcrtr&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rc)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rc)r!r}r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rc)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rc)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rc)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrrhc stdS)adA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrc) r!rrrrrrrrrrrrhr&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdS)zRSend a file through a transport. Return an amount of sent bytes. Nrc)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdS)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. Nrc)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rc)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrrhcstdS)aA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrc)r!rrrrrrrhr&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. Nrc) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.Nrcr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.Nrcrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rc)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rc)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rcr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rcr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rcrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rcrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rc)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rc)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rc)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rc)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rc)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rc)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rc)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rc)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rc)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rcr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rcr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rc)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rcr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rcrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rcr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rc)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrmrnrorprqrerrrarursrvrwrxr{r|rrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.Nrcr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.Nrcr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.Nrcr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.Nrcr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.Nrc)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN) r-rGrHrIrr r r r r&r&r&r'r<s  rc@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nz,There is no current event loop in thread %r.) rrrr^ threadingZcurrent_threadZ _MainThreadr r RuntimeErrorryr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCsd|j_||j_dS)zSet the event loop.TN)rrrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrIrrlocalrr(rr r r&r&r&r'r^s rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr&r&r&r'rsrcCs|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r)Zpolicyr&r&r'rsrcCst}|dk r|StS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr&r&r'rs rcCst|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rr&r&r'r sr cCs tS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r&r&r&r'r sr cCs tS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r&r&r&r'r sr cCs t|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr&r&r'r sr )rr rr),rI__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sX   J@*q"9    __pycache__/exceptions.cpython-38.opt-1.pyc000064400000004767152343727170014555 0ustar00U e5da@sldZdZGdddeZGdddeZGdddeZGdd d eZGd d d e Z Gd d d eZ dS)zasyncio exceptions.)CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__r r */usr/lib64/python3.8/asyncio/exceptions.pyr src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrr r r r r src@seZdZdZdS)rz+The operation is not allowed in this state.Nrr r r r rsrc@seZdZdZdS)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nrr r r r rsrcs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r r rr __classcell__r r rr rs rcs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) r __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r s__pycache__/base_subprocess.cpython-38.opt-1.pyc000064400000022152152343727170015542 0ustar00U e5d"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd 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 s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} 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__//usr/lib64/python3.8/asyncio/base_subprocess.pyr sL            z BaseSubprocessTransport.__init__cCs|jjg}|jr|d|jdk r6|d|j|jdk rT|d|jn |jdk rj|dn |d|jd}|dk r|d|j|jd}|jd }|dk r||kr|d |jn6|dk r|d |j|dk r |d |jd d |S)Nclosedzpid=z returncode=Zrunningz not startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}> ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc s`zj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<|j j j D]\}}|j|f|qd_ WnZt t fk rYn`tk r<}z"|dk r,|s,||W5d}~XYn X|dk r\|s\|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&s@          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrU)r'cbr_r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rbrZpipe_connection_lost _try_finish)r'rJr`r.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rbrZpipe_data_received)r'rJr_r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCsp|jrtd||||_|jjdkr2||j_||jj | |j D]}| sN| |qNd|_ dS)Nz%r exited with return code %r)rr!rr8rr returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/_process_exiteds    z'BaseSubprocessTransport._process_exitedcs0|jdk r|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*r.r.r/_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jDr:d|_||jddS)Ncss|]}|dk o|jVqdSr:) disconnected).0pr.r.r/ sz6BaseSubprocessTransport._try_finish..T)rallrrArrb_call_connection_lostr>r.r.r/rcs z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'r`r.r.r/rns z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rir\rdrJrpr.r.r/ro sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r\r pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r\rresume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN) r2rqrrrrVr9rorxryr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r\rerJ)r'r_r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrsrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v __pycache__/events.cpython-38.pyc000064400000066633152343727170012741 0ustar00U e5d4f@s|dZdZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z GdddZ Gd d d e Z Gd d d Z Gd ddZGdddZGdddeZdaeZGdddejZeZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Z d)d*Z!eZ"eZ#eZ$eZ%zdd+l&mZmZmZmZWne'k rfYnXeZ(eZ)eZ*eZ+dS),z!Event loop and event loop policy.)AbstractEventLoopPolicyAbstractEventLoopAbstractServerHandle TimerHandleget_event_loop_policyset_event_loop_policyget_event_loopset_event_loopnew_event_loopget_child_watcherset_child_watcher_set_running_loopget_running_loop_get_running_loopN)format_helpers) exceptionsc@sFeZdZdZdZdddZddZdd Zd d Zd d Z ddZ dS)rz1Object returned by callback registration methods.) _callback_args _cancelled_loop_source_traceback_repr __weakref___contextNcCs\|dkrt}||_||_||_||_d|_d|_|jrRt t d|_ nd|_ dS)NFr) contextvarsZ copy_contextrrrrrr get_debugr extract_stacksys _getframer)selfcallbackargsloopcontextr&&/usr/lib64/python3.8/asyncio/events.py__init__ s zHandle.__init__cCsl|jjg}|jr|d|jdk r:|t|j|j|jrh|jd}|d|dd|d|S)N cancelledz created at r:r) __class____name__rappendrr_format_callback_sourcerr)r!infoframer&r&r' _repr_info/s    zHandle._repr_infocCs(|jdk r|jS|}dd|S)Nz<{}> )rr2formatjoin)r!r0r&r&r'__repr__;s zHandle.__repr__cCs0|js,d|_|jr t||_d|_d|_dSNT)rrrreprrrrr!r&r&r'cancelAs   z Handle.cancelcCs|jSN)rr9r&r&r'r)LszHandle.cancelledc Csz|jj|jf|jWn|ttfk r4Yndtk r}zFt|j|j}d|}|||d}|j rz|j |d<|j |W5d}~XYnXd}dS)NzException in callback )messageZ exceptionhandleZsource_traceback) rrunrr SystemExitKeyboardInterrupt BaseExceptionrr/rrcall_exception_handler)r!exccbmsgr%r&r&r'_runOs$  z Handle._run)N) r- __module__ __qualname____doc__ __slots__r(r2r6r:r)rFr&r&r&r'rs   rcseZdZdZddgZdfdd ZfddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ fddZddZZS)rz7Object returned by timed callback registration methods. _scheduled_whenNcs<|dk s tt|||||jr,|jd=||_d|_dS)Nr*F)AssertionErrorsuperr(rrLrK)r!whenr"r#r$r%r,r&r'r(hs  zTimerHandle.__init__cs0t}|jrdnd}||d|j|S)Nrzwhen=)rNr2rinsertrL)r!r0posrPr&r'r2ps zTimerHandle._repr_infocCs t|jSr;)hashrLr9r&r&r'__hash__vszTimerHandle.__hash__cCs |j|jkSr;rLr!otherr&r&r'__lt__yszTimerHandle.__lt__cCs|j|jkrdS||Sr7rL__eq__rWr&r&r'__le__|s zTimerHandle.__le__cCs |j|jkSr;rVrWr&r&r'__gt__szTimerHandle.__gt__cCs|j|jkrdS||Sr7rZrWr&r&r'__ge__s zTimerHandle.__ge__cCs>t|tr:|j|jko8|j|jko8|j|jko8|j|jkStSr;) isinstancerrLrrrNotImplementedrWr&r&r'r[s     zTimerHandle.__eq__cCs||}|tkrtS| Sr;)r[r`)r!rXZequalr&r&r'__ne__s zTimerHandle.__ne__cs |js|j|tdSr;)rr_timer_handle_cancelledrNr:r9rPr&r'r:s zTimerHandle.cancelcCs|jS)zReturn a scheduled callback time. The time is an absolute timestamp, using the same time reference as loop.time(). rVr9r&r&r'rOszTimerHandle.when)N)r-rGrHrIrJr(r2rUrYr\r]r^r[rar:rO __classcell__r&r&rPr'rcs  rc@sPeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ dS)rz,Abstract server returned by create_server().cCstdS)z5Stop serving. This leaves existing connections open.NNotImplementedErrorr9r&r&r'closeszAbstractServer.closecCstdS)z4Get the event loop the Server object is attached to.Nrdr9r&r&r'get_loopszAbstractServer.get_loopcCstdS)z3Return True if the server is accepting connections.Nrdr9r&r&r' is_servingszAbstractServer.is_servingcstdS)zStart accepting connections. This method is idempotent, so it can be called when the server is already being serving. Nrdr9r&r&r' start_servingszAbstractServer.start_servingcstdS)zStart accepting connections until the coroutine is cancelled. The server is closed when the coroutine is cancelled. Nrdr9r&r&r' serve_foreverszAbstractServer.serve_forevercstdS)z*Coroutine to wait until service is closed.Nrdr9r&r&r' wait_closedszAbstractServer.wait_closedcs|Sr;r&r9r&r&r' __aenter__szAbstractServer.__aenter__cs||IdHdSr;)rfrk)r!rCr&r&r' __aexit__szAbstractServer.__aexit__N) r-rGrHrIrfrgrhrirjrkrlrmr&r&r&r'rsrc @sVeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZddZddddZd d!Zd"d#Zd$d%Zd&d&d&d&d'd(d)Zdud*d+Zdvdd&d&d&ddddddd, d-d.Zdwejejdd/ddddd0d1 d2d3Zdxd0d4d5d6Zd7ddd8d9d:Zdyddddd;dd?d@Zd{d&d&d&dddddAdBdCZ dDdEZ!dFdGZ"e#j$e#j$e#j$dHdIdJZ%e#j$e#j$e#j$dHdKdLZ&dMdNZ'dOdPZ(dQdRZ)dSdTZ*dUdVZ+dWdXZ,dYdZZ-d[d\Z.d]d^Z/d|dd4d_d`Z0dadbZ1dcddZ2dedfZ3dgdhZ4didjZ5dkdlZ6dmdnZ7dodpZ8dqdrZ9dsdtZ:dS)}rzAbstract event loop.cCstdS)z*Run the event loop until stop() is called.Nrdr9r&r&r' run_foreverszAbstractEventLoop.run_forevercCstdS)zpRun the event loop until a Future is done. Return the Future's result, or raise its exception. Nrd)r!Zfuturer&r&r'run_until_completesz$AbstractEventLoop.run_until_completecCstdS)zStop the event loop as soon as reasonable. Exactly how soon that is may depend on the implementation, but no more I/O callbacks should be scheduled. Nrdr9r&r&r'stopszAbstractEventLoop.stopcCstdS)z3Return whether the event loop is currently running.Nrdr9r&r&r' is_runningszAbstractEventLoop.is_runningcCstdS)z*Returns True if the event loop was closed.Nrdr9r&r&r' is_closedszAbstractEventLoop.is_closedcCstdS)zClose the loop. The loop should not be running. This is idempotent and irreversible. No other methods should be called after this one. Nrdr9r&r&r'rfs zAbstractEventLoop.closecstdS)z,Shutdown all active asynchronous generators.Nrdr9r&r&r'shutdown_asyncgenssz$AbstractEventLoop.shutdown_asyncgenscCstdS)z3Notification that a TimerHandle has been cancelled.Nrd)r!r=r&r&r'rbsz)AbstractEventLoop._timer_handle_cancelledcGs|jd|f|S)Nr) call_laterr!r"r#r&r&r' call_soonszAbstractEventLoop.call_sooncGstdSr;rd)r!Zdelayr"r#r&r&r'rtszAbstractEventLoop.call_latercGstdSr;rd)r!rOr"r#r&r&r'call_atszAbstractEventLoop.call_atcCstdSr;rdr9r&r&r'time szAbstractEventLoop.timecCstdSr;rdr9r&r&r' create_futureszAbstractEventLoop.create_futureN)namecCstdSr;rd)r!cororzr&r&r' create_taskszAbstractEventLoop.create_taskcGstdSr;rdrur&r&r'call_soon_threadsafesz&AbstractEventLoop.call_soon_threadsafecGstdSr;rd)r!executorfuncr#r&r&r'run_in_executorsz!AbstractEventLoop.run_in_executorcCstdSr;rd)r!r~r&r&r'set_default_executorsz&AbstractEventLoop.set_default_executorr)familytypeprotoflagscstdSr;rd)r!hostportrrrrr&r&r' getaddrinfo#szAbstractEventLoop.getaddrinfocstdSr;rd)r!Zsockaddrrr&r&r' getnameinfo'szAbstractEventLoop.getnameinfo) sslrrrsock local_addrserver_hostnamessl_handshake_timeouthappy_eyeballs_delay interleavec stdSr;rd)r!protocol_factoryrrrrrrrrrrrrr&r&r'create_connection*sz#AbstractEventLoop.create_connectiondT) rrrbacklogr reuse_address reuse_portrric stdS)adA coroutine which creates a TCP server bound to host and port. The return value is a Server object which can be used to stop the service. If host is an empty string or None all interfaces are assumed and a list of multiple sockets will be returned (most likely one for IPv4 and another one for IPv6). The host parameter can also be a sequence (e.g. list) of hosts to bind to. family can be set to either AF_INET or AF_INET6 to force the socket to use IPv4 or IPv6. If not set it will be determined from host (defaults to AF_UNSPEC). flags is a bitmask for getaddrinfo(). sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows. ssl_handshake_timeout is the time in seconds that an SSL server will wait for completion of the SSL handshake before aborting the connection. Default is 60s. start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrd) r!rrrrrrrrrrrrir&r&r' create_server3s3zAbstractEventLoop.create_server)fallbackcstdS)zRSend a file through a transport. Return an amount of sent bytes. Nrd)r! transportfileoffsetcountrr&r&r'sendfilehszAbstractEventLoop.sendfileF) server_siderrcstdS)z|Upgrade a transport to TLS. Return a new transport that *protocol* should start using immediately. Nrd)r!rZprotocolZ sslcontextrrrr&r&r' start_tlsps zAbstractEventLoop.start_tls)rrrrcstdSr;rd)r!rpathrrrrr&r&r'create_unix_connection{sz(AbstractEventLoop.create_unix_connection)rrrrricstdS)aA coroutine which creates a UNIX Domain Socket server. The return value is a Server object, which can be used to stop the service. path is a str, representing a file systsem path to bind the server socket to. sock can optionally be specified in order to use a preexisting socket object. backlog is the maximum number of queued connections passed to listen() (defaults to 100). ssl can be set to an SSLContext to enable SSL over the accepted connections. ssl_handshake_timeout is the time in seconds that an SSL server will wait for the SSL handshake to complete (defaults to 60s). start_serving set to True (default) causes the created server to start accepting connections immediately. When set to False, the user should await Server.start_serving() or Server.serve_forever() to make the server to start accepting connections. Nrd)r!rrrrrrrir&r&r'create_unix_serversz$AbstractEventLoop.create_unix_server)rrrrrallow_broadcastrc stdS)aA coroutine which creates a datagram endpoint. This method will try to establish the endpoint in the background. When successful, the coroutine returns a (transport, protocol) pair. protocol_factory must be a callable returning a protocol instance. socket family AF_INET, socket.AF_INET6 or socket.AF_UNIX depending on host (or family if specified), socket type SOCK_DGRAM. reuse_address tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire. If not specified it will automatically be set to True on UNIX. reuse_port tells the kernel to allow this endpoint to be bound to the same port as other existing endpoints are bound to, so long as they all set this flag when being created. This option is not supported on Windows and some UNIX's. If the :py:data:`~socket.SO_REUSEPORT` constant is not defined then this capability is unsupported. allow_broadcast tells the kernel to allow this endpoint to send messages to the broadcast address. sock can optionally be specified in order to use a preexisting socket object. Nrd) r!rrZ remote_addrrrrrrrrr&r&r'create_datagram_endpoints!z*AbstractEventLoop.create_datagram_endpointcstdS)aRegister read pipe in event loop. Set the pipe to non-blocking mode. protocol_factory should instantiate object with Protocol interface. pipe is a file-like object. Return pair (transport, protocol), where transport supports the ReadTransport interface.Nrdr!rpiper&r&r'connect_read_pipes z#AbstractEventLoop.connect_read_pipecstdS)aRegister write pipe in event loop. protocol_factory should instantiate object with BaseProtocol interface. Pipe is file-like object already switched to nonblocking. Return pair (transport, protocol), where transport support WriteTransport interface.Nrdrr&r&r'connect_write_pipes z$AbstractEventLoop.connect_write_pipe)stdinstdoutstderrcstdSr;rd)r!rcmdrrrkwargsr&r&r'subprocess_shellsz"AbstractEventLoop.subprocess_shellcstdSr;rd)r!rrrrr#rr&r&r'subprocess_execsz!AbstractEventLoop.subprocess_execcGstdSr;rdr!fdr"r#r&r&r' add_readerszAbstractEventLoop.add_readercCstdSr;rdr!rr&r&r' remove_readerszAbstractEventLoop.remove_readercGstdSr;rdrr&r&r' add_writerszAbstractEventLoop.add_writercCstdSr;rdrr&r&r' remove_writerszAbstractEventLoop.remove_writercstdSr;rd)r!rnbytesr&r&r' sock_recvszAbstractEventLoop.sock_recvcstdSr;rd)r!rZbufr&r&r'sock_recv_intosz AbstractEventLoop.sock_recv_intocstdSr;rd)r!rdatar&r&r' sock_sendallszAbstractEventLoop.sock_sendallcstdSr;rd)r!rZaddressr&r&r' sock_connect szAbstractEventLoop.sock_connectcstdSr;rd)r!rr&r&r' sock_acceptszAbstractEventLoop.sock_acceptcstdSr;rd)r!rrrrrr&r&r' sock_sendfileszAbstractEventLoop.sock_sendfilecGstdSr;rd)r!sigr"r#r&r&r'add_signal_handlersz$AbstractEventLoop.add_signal_handlercCstdSr;rd)r!rr&r&r'remove_signal_handlersz'AbstractEventLoop.remove_signal_handlercCstdSr;rd)r!factoryr&r&r'set_task_factorysz"AbstractEventLoop.set_task_factorycCstdSr;rdr9r&r&r'get_task_factory"sz"AbstractEventLoop.get_task_factorycCstdSr;rdr9r&r&r'get_exception_handler'sz'AbstractEventLoop.get_exception_handlercCstdSr;rd)r!Zhandlerr&r&r'set_exception_handler*sz'AbstractEventLoop.set_exception_handlercCstdSr;rdr!r%r&r&r'default_exception_handler-sz+AbstractEventLoop.default_exception_handlercCstdSr;rdrr&r&r'rB0sz(AbstractEventLoop.call_exception_handlercCstdSr;rdr9r&r&r'r5szAbstractEventLoop.get_debugcCstdSr;rd)r!Zenabledr&r&r' set_debug8szAbstractEventLoop.set_debug)r)NN)NN)rN)N)N)NN)rN);r-rGrHrIrnrorprqrrrfrsrbrvrtrwrxryr|r}rrrrrsocketZ AF_UNSPECZ AI_PASSIVErrrrrrrr subprocessPIPErrrrrrrrrrrrrrrrrrrrBrrr&r&r&r'rs     5    ! %    rc@s8eZdZdZddZddZddZdd Zd d Zd S) rz-Abstract policy for accessing the event loop.cCstdS)a:Get the event loop for the current context. Returns an event loop object implementing the BaseEventLoop interface, or raises an exception in case no event loop has been set for the current context and the current policy does not specify to create one. It should never return None.Nrdr9r&r&r'r?sz&AbstractEventLoopPolicy.get_event_loopcCstdS)z3Set the event loop for the current context to loop.Nrdr!r$r&r&r'r Isz&AbstractEventLoopPolicy.set_event_loopcCstdS)zCreate and return a new event loop object according to this policy's rules. If there's need to set this loop as the event loop for the current context, set_event_loop must be called explicitly.Nrdr9r&r&r'r Msz&AbstractEventLoopPolicy.new_event_loopcCstdS)z$Get the watcher for child processes.Nrdr9r&r&r'r Usz)AbstractEventLoopPolicy.get_child_watchercCstdS)z$Set the watcher for child processes.Nrd)r!watcherr&r&r'r Ysz)AbstractEventLoopPolicy.set_child_watcherN) r-rGrHrIrr r r r r&r&r&r'r<s  rc@sFeZdZdZdZGdddejZddZddZ d d Z d d Z dS) BaseDefaultEventLoopPolicyaDefault policy implementation for accessing the event loop. In this policy, each thread has its own event loop. However, we only automatically create an event loop by default for the main thread; other threads by default have no event loop. Other policies may have different rules (e.g. a single global event loop, or automatically creating an event loop per thread, or using some other notion of context to which an event loop is associated). Nc@seZdZdZdZdS)z!BaseDefaultEventLoopPolicy._LocalNF)r-rGrHr _set_calledr&r&r&r'_LocalmsrcCs||_dSr;)r_localr9r&r&r'r(qsz#BaseDefaultEventLoopPolicy.__init__cCsX|jjdkr2|jjs2tttjr2|||jjdkrPt dtj |jjS)zvGet the event loop for the current context. Returns an instance of EventLoop or raises an exception. Nz,There is no current event loop in thread %r.) rrrr_ threadingZcurrent_threadZ _MainThreadr r RuntimeErrorrzr9r&r&r'rts  z)BaseDefaultEventLoopPolicy.get_event_loopcCs*d|j_|dkst|tst||j_dS)zSet the event loop.TN)rrr_rrMrrr&r&r'r sz)BaseDefaultEventLoopPolicy.set_event_loopcCs|S)zvCreate a new event loop. You must call set_event_loop() to make this the current event loop. ) _loop_factoryr9r&r&r'r sz)BaseDefaultEventLoopPolicy.new_event_loop) r-rGrHrIrrlocalrr(rr r r&r&r&r'r^s rc@seZdZdZdS) _RunningLoop)NNN)r-rGrHloop_pidr&r&r&r'rsrcCst}|dkrtd|S)zrReturn the running event loop. Raise a RuntimeError if there is none. This function is thread-specific. Nzno running event loop)rrr$r&r&r'rsrcCs&tj\}}|dk r"|tkr"|SdS)zReturn the running event loop or None. This is a low-level function intended to be used by event loops. This function is thread-specific. N) _running_looprosgetpid)Z running_looppidr&r&r'rs rcCs|tft_dS)zSet the running event loop. This is a low-level function intended to be used by event loops. This function is thread-specific. N)rrrrrr&r&r'r sr c Cs.t tdkr ddlm}|aW5QRXdS)NrDefaultEventLoopPolicy)_lock_event_loop_policyrrr&r&r'_init_event_loop_policys rcCstdkrttS)z"Get the current event loop policy.N)rrr&r&r&r'rsrcCs|dkst|tst|adS)zZSet the current event loop policy. If policy is None, the default policy is restored.N)r_rrMr)Zpolicyr&r&r'rsrcCst}|dk r|StS)aGReturn an asyncio event loop. When called from a coroutine or a callback (e.g. scheduled with call_soon or similar API), this function will always return the running event loop. If there is no running event loop set, the function will return the result of `get_event_loop_policy().get_event_loop()` call. N)rrr)Z current_loopr&r&r'rs rcCst|dS)zCEquivalent to calling get_event_loop_policy().set_event_loop(loop).N)rr rr&r&r'r sr cCs tS)z?Equivalent to calling get_event_loop_policy().new_event_loop().)rr r&r&r&r'r sr cCs tS)zBEquivalent to calling get_event_loop_policy().get_child_watcher().)rr r&r&r&r'r sr cCs t|S)zMEquivalent to calling get_event_loop_policy().set_child_watcher(watcher).)rr )rr&r&r'r sr )rr rr),rI__all__rrrrrrrrrrrrrrrrZLockrrrrrrr rrrrr r r r Z_py__get_running_loopZ_py__set_running_loopZ_py_get_running_loopZ_py_get_event_loopZ_asyncio ImportErrorZ_c__get_running_loopZ_c__set_running_loopZ_c_get_running_loopZ_c_get_event_loopr&r&r&r'sX   J@*q"9    __pycache__/base_tasks.cpython-38.pyc000064400000003632152343727170013542 0ustar00U e5d @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror */usr/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #__pycache__/constants.cpython-38.pyc000064400000001107152343727170013432 0ustar00U e5dx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r )/usr/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s __pycache__/format_helpers.cpython-38.pyc000064400000004436152343727170014440 0ustar00U e5dd @sdddlZddlZddlZddlZddlZddlmZddZddZdd Z dd d Z dd dZ dS)N) constantscCsVt|}t|r&|j}|j|jfSt|tjr&sz*_format_args_and_kwargs..css&|]\}}|dt|VqdS)=Nr)rkvrrrr(sz({})z, )extenditemsformatjoin)rkwargsr"rrr_format_args_and_kwargss r&cCst|tjr.t|||}t|j|j|j|St|drF|j rF|j }n t|dr^|j r^|j }nt |}|t||7}|r||7}|S)N __qualname____name__) r r r r&rr rkeywordshasattrr(r)r)r rr%suffixrrrrr,s rcCsD|dkrtj}|dkr tj}tjjt||dd}| |S)zlReplacement for traceback.extract_stack() that only does the necessary work for asyncio debug mode. NF)limit lookup_lines) sys _getframef_backrZDEBUG_STACK_DEPTH traceback StackSummaryextract walk_stackreverse)fr-stackrrr extract_stack>s r9)r')NN) r rrr/r2r'rr rr&rr9rrrrs   __pycache__/log.cpython-38.opt-1.pyc000064400000000344152343727170013140 0ustar00U e5d|@sdZddlZeeZdS)zLogging configuration.N)__doc__ZloggingZ getLogger __package__Zloggerrr#/usr/lib64/python3.8/asyncio/log.pys__pycache__/selector_events.cpython-38.opt-2.pyc000064400000066531152343727170015576 0ustar00U e5dT@s*dZddlZddlZddlZddlZddlZddlZddlZz ddlZWne k r`dZYnXddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd dZddZGddde jZGdddejejZGdddeZGdddeZdS))BaseSelectorEventLoopN) base_events) constants)events)futures) protocols)sslproto) transports)trsock)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.8/asyncio/selector_events.py_test_selector_event s rcCs tdk rt|tjrtddS)Nz"Socket cannot be of type SSLSocket)ssl isinstanceZ SSLSocket TypeError)sockrrr_check_ssl_socket+srcseZdZdRfdd ZdSdddddZdTddddejdd d ZdUd d Zfd dZ ddZ ddZ ddZ ddZ ddZdddejfddZdddejfddZddejfddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Zd8d9Zd:d;Zdd?Z!d@dAZ"dBdCZ#dDdEZ$dFdGZ%dHdIZ&dJdKZ'dLdMZ(dNdOZ)dPdQZ*Z+S)VrNcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdSr}) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|Sr+)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||Sr+)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|Sr+)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||Sr+)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHSNrthe socket must be non-blocking)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHSr)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHSr)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)NrrAF_UNIX)familyprotoloop) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)NrrF)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN),r! __module__ __qualname__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s|        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)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)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs|jr dSz|j|j}Wnttfk r4Ynttfk rLYntk r}z>|j |j |j | |d|jdk r|j|W5d}~XYnnX|r|jd|=||js|j |j |jdk r|jd|jr|dn|jr|jtjdS)Nr)rrrOrrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs2       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrrrrrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsD            1o__pycache__/transports.cpython-38.opt-2.pyc000064400000015261152343727170014603 0ustar00U e5d(@sxdZGdddZGdddeZGdddeZGdddeeZGd d d eZGd d d eZGd ddeZdS)) BaseTransport ReadTransportWriteTransport TransportDatagramTransportSubprocessTransportc@sDeZdZdZdddZdddZddZd d Zd d Zd dZ dS)r_extraNcCs|dkr i}||_dSNr)selfextrar */usr/lib64/python3.8/asyncio/transports.py__init__szBaseTransport.__init__cCs|j||Sr )rget)r namedefaultr r r get_extra_infoszBaseTransport.get_extra_infocCstdSr NotImplementedErrorr r r r is_closingszBaseTransport.is_closingcCstdSr rrr r r closeszBaseTransport.closecCstdSr r)r protocolr r r set_protocol%szBaseTransport.set_protocolcCstdSr rrr r r get_protocol)szBaseTransport.get_protocol)N)N) __name__ __module__ __qualname__ __slots__rrrrrrr r r r r s   rc@s(eZdZdZddZddZddZdS) rr cCstdSr rrr r r is_reading3szReadTransport.is_readingcCstdSr rrr r r pause_reading7szReadTransport.pause_readingcCstdSr rrr r r resume_reading?szReadTransport.resume_readingN)rrrrrr r!r r r r r.src@sJeZdZdZdddZddZddZd d Zd d Zd dZ ddZ dS)rr NcCstdSr rr highlowr r r set_write_buffer_limitsMsz&WriteTransport.set_write_buffer_limitscCstdSr rrr r r get_write_buffer_sizebsz$WriteTransport.get_write_buffer_sizecCstdSr r)r datar r r writefszWriteTransport.writecCsd|}||dS)N)joinr()r Z list_of_datar'r r r writelinesns zWriteTransport.writelinescCstdSr rrr r r write_eofwszWriteTransport.write_eofcCstdSr rrr r r can_write_eofszWriteTransport.can_write_eofcCstdSr rrr r r abortszWriteTransport.abort)NN) rrrrr%r&r(r+r,r-r.r r r r rHs   rc@seZdZdZdS)rr N)rrrrr r r r rsrc@s"eZdZdZdddZddZdS)rr NcCstdSr r)r r'Zaddrr r r sendtoszDatagramTransport.sendtocCstdSr rrr r r r.szDatagramTransport.abort)N)rrrrr/r.r r r r rs rc@s@eZdZdZddZddZddZdd Zd d Zd d Z dS)rr cCstdSr rrr r r get_pidszSubprocessTransport.get_pidcCstdSr rrr r r get_returncodesz"SubprocessTransport.get_returncodecCstdSr r)r fdr r r get_pipe_transportsz&SubprocessTransport.get_pipe_transportcCstdSr r)r signalr r r send_signalszSubprocessTransport.send_signalcCstdSr rrr r r terminates zSubprocessTransport.terminatecCstdSr rrr r r kills zSubprocessTransport.killN) rrrrr0r1r3r5r6r7r r r r rsrcsVeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ ddZ Z S)_FlowControlMixin)_loop_protocol_paused _high_water _low_waterNcs$t|||_d|_|dS)NF)superrr9r:_set_write_buffer_limits)r r Zloop __class__r r rs z_FlowControlMixin.__init__c Cs|}||jkrdS|jsd|_z|jWnRttfk rJYn:tk r}z|j d|||jdW5d}~XYnXdS)NTzprotocol.pause_writing() failedmessageZ exceptionZ transportr) r&r;r: _protocolZ pause_writing SystemExitKeyboardInterrupt BaseExceptionr9call_exception_handler)r sizeexcr r r _maybe_pause_protocols  z'_FlowControlMixin._maybe_pause_protocolc Cs|jr|||jkr|d|_z|jWnRttfk rBYn:tk rz}z|j d|||jdW5d}~XYnXdS)NFz protocol.resume_writing() failedrA) r:r&r<rCZresume_writingrDrErFr9rG)r rIr r r _maybe_resume_protocol!s z(_FlowControlMixin._maybe_resume_protocolcCs |j|jfSr )r<r;rr r r get_write_buffer_limits1sz)_FlowControlMixin.get_write_buffer_limitscCsj|dkr|dkrd}nd|}|dkr.|d}||krBdksZntd|d|d||_||_dS)Nizhigh (z) must be >= low (z) must be >= 0) ValueErrorr;r<r"r r r r>4sz*_FlowControlMixin._set_write_buffer_limitscCs|j||d|dS)N)r#r$)r>rJr"r r r r%Dsz)_FlowControlMixin.set_write_buffer_limitscCstdSr rrr r r r&Hsz'_FlowControlMixin.get_write_buffer_size)NN)NN)NN) rrrrrrJrKrLr>r%r& __classcell__r r r?r r8s  r8N)__all__rrrrrrr8r r r r s%F6__pycache__/coroutines.cpython-38.pyc000064400000015000152343727170013605 0ustar00U e5d]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr*/usr/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCsZt|st|st|||_||_tt d|_ t |dd|_ t |dd|_ dS)Nr__name__ __qualname__)inspect isgeneratorrAssertionErrorgenfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r! coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrr!rrr__iter__7szCoroWrapper.__iter__cCs |jdSr-rsendr.rrr__next__:szCoroWrapper.__next__cCs |j|Sr-r0)r!valuerrrr1=szCoroWrapper.sendcCs|j|||Sr-)rthrow)r!typer3 tracebackrrrr4@szCoroWrapper.throwcCs |jSr-)rcloser.rrrr7CszCoroWrapper.closecCs|jjSr-)rgi_framer.rrrr8FszCoroWrapper.gi_framecCs|jjSr-)r gi_runningr.rrrr9JszCoroWrapper.gi_runningcCs|jjSr-)rgi_coder.rrrr:NszCoroWrapper.gi_codecCs|Sr-rr.rrr __await__RszCoroWrapper.__await__cCs|jjSr-)r gi_yieldfromr.rrrr<UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr8r#z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) r f_lastijoinr6 format_listrZDEBUG_STACK_DEPTHrstripr error)r!rr+msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rr"r,r/r2r1r4r7propertyr8r9r:r;r<rErrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr-) rZisfuturerr isinstancerr;AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrRr#rr)rrr rr)rOkwdswrSrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrWrrVrris"    rcCst|pt|ddtkS)z6Return True if func is a decorated coroutine function.r`N)rrr r`rRrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)z)Return True if obj is a coroutine object.TdFN)r5_iscoroutine_typecacherJ_COROUTINE_TYPESlenadd)objrrrrs   rc stt|s tt|tfdd}dd}d}t|drF|jrF|j}nt|dr\|jr\|j}||}|s~||rz|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|j pd }d }r0|j dk r0t |j s0t |j }|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rV|j}|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr%z without __name__>z())rZ_format_callbackrhasattrrrr5)rS coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrKr9)rSrrr is_runnings z%_format_coroutine..is_runningcr_coder:z runningr8cr_framezrz done, defined at r$z running, defined at z running at )rrrJrrgrmr:r8rn co_filenamerrr[rZ_get_function_sourcef_linenoco_firstlineno) rSrjrlZ coro_coderhZ coro_framefilenamelinenosourcer*rrirr(sL          r() __all__Zcollections.abcrLr\rrr r6r^rXr=rrrlogr rr_rrobjectr`r CoroutineType GeneratorTyperM Coroutinercsetrbrr(rrrrs2    E8__pycache__/proactor_events.cpython-38.opt-1.pyc000064400000056475152343727170015614 0ustar00U e5d<}@sTdZdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl m Z dd l mZdd l mZdd l mZdd l mZdd lmZddZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZ Gddde j!Z"dS) zEvent loop using a proactor and related classes. A proactor is a "notify-on-completion" multiplexer. Currently a proactor is only implemented on Windows with IOCP. )BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr//usr/lib64/python3.8/asyncio/proactor_events.py_set_socket_extras   rcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ e j fddZ dddZddZddZddZZS)_ProactorBasePipeTransportz*Base class for pipe and socket transports.Ncst||||||_||||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rl|j |j|jj||dk r|jtj|ddS)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attachr call_soon _protocolZconnection_maderZ_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__rrr2s(     z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|jdk rP|d|j|jdk rl|d|j|jdk r|d|j|jr|dt |j|j r|dd d |S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname____doc__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s   rcsTeZdZdZdfdd ZddZddZd d Zd d Zd dZ dddZ Z S)_ProactorReadPipeTransportzTransport for read pipes.Ncs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rfr(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rfrrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rfr$rr*rgre_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr||_dS|s |dSt|jtjrzt|j|Wqtt fk rZYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.) rfrerqrQr+rZBufferedProtocolZ_feed_data_to_buffered_protornrorprVZ data_received)r-rlrUrrrrjs"z)_ProactorReadPipeTransport._data_receivedc Cstd}zRzp|dk r2d|_|r*|}n||jrHd}WWdS|dkr\WWdS|jsv|jj |j d|_Wnt k r}z0|js| |dn|j rtjdddW5d}~XYntk r}z||W5d}~XYnftk r}z| |dW5d}~XYn8tjk r>|js:YnX|jsV|j|jW5|dk rn||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rjr$rXresultrHr(rfr _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrg)r-futrlrUrrrrgs@     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_r`rrhrirmrqrjrgrcrrr3rrds rdcs^eZdZdZdZfddZddZddd Zd d Zd d Z ddZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportzTransport for write pipes.Tcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rl)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr% _loop_writingr#_maybe_pause_protocolextendrkrrrwriteKs,       z%_ProactorBaseWritePipeTransport.writeNc CsVz|dk r |jdkr |jr WdSd|_d|_|r8||dkrL|j}d|_|s|jrf|j|jd|jrz|j t j | nN|jj|j ||_|jst||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk r"}z||W5d}~XYn0tk rP}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rsr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrtsendrXr;ryrrrWrYrwrPrRrV)r-frlrUrrrrqs8    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN)r8r^r_r`Z_start_tls_compatiblerrrrrrrrrcrrr3rr{As & )r{cs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrtrur r$ry _pipe_closedr|r3rrrsz$_ProactorWritePipeTransport.__init__cCs@|r dS|jrdSd|_|jdk r4|tn|dSrB)Z cancelledr(r$r%rPBrokenPipeErrorrI)r-rzrrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrcrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rg)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rl_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQrrrrrr ValueErrorr'rrr rr#r9r%rr)r-rladdrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Cs z|jrWdSd|_|r ||jr2|jrN|jrN|jrH|j|jdWdS|j \}}|jdk r||jj |j ||_n|jj j |j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rsr#rr(rr*rGpopleftrtrr rrRr+error_received ExceptionrVryrr)r-rzrlrrUrrrrs2    z(_ProactorDatagramTransport._loop_writingc Cs4d}zz|jrWWdSd|_|dk rf|}|jrFd}WWdS|jdk r^||j}}n|\}}|jrvWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnJt k r}z|j|W5d}~XYn8tjk r|jsYnX|jdk r|j|jW5|r.|j||XdSrB)r+Zdatagram_receivedr'r$rsr(rrrtrur max_sizeZrecvfromrRrrrxryrg)r-rzrlrresrUrrrrgs>         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrgrcrrr3rrs   !rc@s eZdZdZddZddZdS)_ProactorDuplexPipeTransportzTransport for duplex pipes.cCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_r`rrrrrrrEsrcsBeZdZdZejjZd fdd ZddZ ddZ d d Z Z S) _ProactorSocketTransportz Transport for connected sockets.Ncs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_r`rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrcrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8rt _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rdrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_pipertrIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rtru)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)rtZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rtr)r-rrlrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)rtZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)rtacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrtsendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rhrirrrmZ sock_sendfiler )r-Ztransprrrrmrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rsrrtrurrrxrnrorprTry_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rsrr rSrrrrtrrRr:rTr rrIrrxrry)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHrt _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrcrrr3rrks\            +r)#r`__all__rrr rarrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrdZWriteTransportr{rrZ TransportrrZ BaseEventLooprrrrrsR           n  __pycache__/sslproto.cpython-38.opt-1.pyc000064400000051654152343727170014256 0ustar00U e5dJj@sddlZddlZz ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d Z d Z d Zd ZGdddeZGdddejejZGdddejZdS)N) base_events) constants) protocols) transports)loggercCs"|r tdt}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslZcreate_default_contextZcheck_hostname) server_sideserver_hostname sslcontextr (/usr/lib64/python3.8/asyncio/sslproto.py_create_transport_contexts rZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZdddZeddZedd Zed d Z ed d Z dddZ dddZ ddZ dddZdddZdS)_SSLPipeaAn SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). iNcCsH||_||_||_t|_t|_t|_d|_ d|_ d|_ d|_ dS)a The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) _context _server_side_server_hostname _UNWRAPPED_stater Z MemoryBIO _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextr r r r r__init__8s   z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)rrr r rrNsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )rrr r r ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake that is currently in progress.)rrr r r need_ssldata[sz_SSLPipe.need_ssldatacCs |jtkS)zj Whether a security layer is currently in effect. Return False during handshake. )r_WRAPPEDrr r rwrappedasz_SSLPipe.wrappedcCsR|jtkrtd|jj|j|j|j|jd|_ t |_||_ |j ddd\}}|S)aLStart the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completed)r r T)only_handshake) rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr feed_ssldatarcallbackssldataappdatar r r do_handshakejs z_SSLPipe.do_handshakecCsB|jtkrtd|jtkr$tdt|_||_|d\}}|S)a1Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. zno security layer presentzshutdown in progressr$)rrr& _SHUTDOWNrr(r)r r rshutdowns  z_SSLPipe.shutdowncCs|j|d\}}dS)zSend a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. r$N)rZ write_eofr()rr+r,r r rfeed_eofs z_SSLPipe.feed_eofFc Cs|jtkr"|r|g}ng}g|fSd|_|r8|j|g}g}z|jtkrz|jt|_|j rl| d|rz||fWS|jtkr|j |j }| ||sqqnJ|jt kr|jd|_t|_|jr|n|jtkr| |j Wnztjtjfk rl}zRt|dd}|tjtjtjfkrP|jtkrN|j rN| ||tjk|_W5d}~XYnX|jjr| |j ||fS)aFeed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). FNerrno)rrrrwriter'rr-r"rreadmax_sizeappendr.Zunwraprr SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLrpending)rdatar%r,r+chunkexc exc_errnor r rr(sZ               z_SSLPipe.feed_ssldatarc Cs|jtkr6|t|kr&||dg}ng}|t|fSg}t|}d|_z(|t|krn||j||d7}Wnhtjk r}zHt |dd}|j dkrtj }|_ |tj tj tjfkr|tj k|_W5d}~XYnX|jjr||j|t|ks |jrBq qB||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. NFr1ZPROTOCOL_IS_SHUTDOWN)rrlen memoryviewrrr2r r6r8reasonr9r1r:r;rr<r5r3)rr=offsetr+Zviewr?r@r r r feed_appdatas4       z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname____doc__r4rpropertyrr r!r#r-r/r0r(rEr r r rr$s         Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||S)z#Get optional transport information.)rM_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSN)rM_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrU)rM _app_protocolrr r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrU)rNrr r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rNrM_start_shutdownrr r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rNResourceWarningr])rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rM _transportr& is_reading)rZtrr r rrbDsz _SSLProtocolTransport.is_readingcCs|jjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rMra pause_readingrr r rrcJsz#_SSLProtocolTransport.pause_readingcCs|jjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rMraresume_readingrr r rrdRsz$_SSLProtocolTransport.resume_readingcCs|jj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rMraset_write_buffer_limits)rZhighZlowr r rreZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjS)z,Return the current size of the write buffer.)rMraget_write_buffer_sizerr r rrfosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSrU)rMra_protocol_pausedrr r rrgssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearrayrB TypeErrortyperFrM_write_appdatarr=r r rr2xs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr rr r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. TN)rM_abortrNrr r raborts z_SSLProtocolTransport.abort)N)NN)rFrGrHrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrTrXrZr[r]warningswarnr`rbrcrdrerfrJrgr2rorqr r r rrKs$     rKc@seZdZdZd,ddZddZd-d d Zd d Zd dZddZ ddZ ddZ ddZ d.ddZ ddZddZddZdd Zd!d"Zd#d$Zd/d&d'Zd(d)Zd*d+ZdS)0 SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r&rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrLrVrK_app_transport_sslpipe_session_established _in_handshake _in_shutdownra_call_connection_made_ssl_handshake_timeout) rrO app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSrU)rYrhrZBufferedProtocol_app_protocol_is_buffer)rrr r rrVs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSrU)r|Z cancelledZ set_exceptionZ set_resultrr?r r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rarrurrr~_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FNT_handshake_timeout_handle) rrL call_soonrYconnection_lostr}rNrar8rcancelrr~rr r rrs    zSSLProtocol.connection_lostcCs|jdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rY pause_writingrr r rrszSSLProtocol.pause_writingcCs|jdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rYresume_writingrr r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)zXCalled when some SSL data is received. The argument is a bytes object. NzSSL error in data receivedz/application protocol failed to receive SSL data)r~r( SystemExitKeyboardInterrupt BaseException _fatal_errorrar2rrZ_feed_data_to_buffered_protorY data_receivedr\)rr=r+r,er>Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rar]rL get_debugrdebugrConnectionResetErrorrrY eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSrU)rwrarTrQr r rrPCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr$)rrrprmrr r rr\Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)rzr5r{rA_process_write_backlogrnr r rrmTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r$r)rLrrrtime_handshake_start_timerrzr5Z call_laterr_check_handshake_timeoutrrrr r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr T)rrrr~r Z getpeercertrrrrhr r7rrLrrrrrrwupdaterrrrYrr}rrrr)rZ handshake_excZsslobjrr?rZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsB|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj r|j q|jd=|j t|8_ q(Wn\ttfk rYnDtk r<}z$|jr ||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rar~rangerArzrEr-rr/ _finalizer2Z_pausedrdr{rrrrr)rir=rDr+r>r?r r rrs:   z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrW) rhOSErrorrLrrrZcall_exception_handlerraZ _force_close)rr?rr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSrU)r~rar]rr r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSrU)rrarqrr r rrps zSSLProtocol._abort)FNTN)N)N)r)rFrGrHrIrrVrrrrrrrrPr\rmrrrrrrrpr r r rrts0 .  &   )+ rt)rxrrr ImportErrorrrrrlogrrrr'r"r.objectrZ_FlowControlMixinZ TransportrKZProtocolrtr r r rs*       yx__pycache__/proactor_events.cpython-38.opt-2.pyc000064400000055655152343727170015614 0ustar00U e5d<}@sPdZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZdd lmZd dZGdddejejZGdddeejZGdddeejZGdddeZGdddeZGdddeeejZGdddeeejZGddde j Z!dS))BaseProactorEventLoopN) base_events) constants)futures) exceptions) protocols)sslproto) transports)trsock)loggercCst||jd<z||jd<Wn0tjk rR|jrNtj d|ddYnXd|jkrz| |jd<Wn tjk rd|jd<YnXdS)NsocketZsocknamezgetsockname() failed on %rTexc_infopeername) r TransportSocket_extraZ getsocknamer error_loop get_debugr warningZ getpeername) transportsockr//usr/lib64/python3.8/asyncio/proactor_events.py_set_socket_extras   rcs~eZdZdfdd ZddZddZdd Zd d Zd d ZddZ e j fddZ dddZ ddZddZddZZS)_ProactorBasePipeTransportNcst||||||_||||_d|_d|_d|_d|_ d|_ d|_ d|_ |jdk rl|j |j|jj||dk r|jtj|ddS)NrF)super__init__ _set_extra_sock set_protocol_server_buffer _read_fut _write_fut_pending_write _conn_lost_closing _eof_writtenZ_attachr call_soon _protocolZconnection_maderZ_set_result_unless_cancelledselflooprprotocolwaiterextraserver __class__rrr2s(     z#_ProactorBasePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|jdk rP|d|j|jdk rl|d|j|jdk r|d|j|jr|dt |j|j r|dd d |S) Nclosedclosingzfd=zread=zwrite=zwrite_bufsize=z EOF writtenz<{}> ) r4__name__r appendr(filenor$r%r#lenr)formatjoin)r-inforrr__repr__Hs         z#_ProactorBasePipeTransport.__repr__cCs||jd<dS)Npipe)rr-rrrrrZsz%_ProactorBasePipeTransport._set_extracCs ||_dSNr+)r-r/rrrr!]sz'_ProactorBasePipeTransport.set_protocolcCs|jSrBrCr-rrr get_protocol`sz'_ProactorBasePipeTransport.get_protocolcCs|jSrB)r(rDrrr is_closingcsz%_ProactorBasePipeTransport.is_closingcCs\|jr dSd|_|jd7_|js>|jdkr>|j|jd|jdk rX|jd|_dS)NTr) r(r'r#r%rr*_call_connection_lostr$cancelrDrrrclosefs  z _ProactorBasePipeTransport.closecCs*|jdk r&|d|t|d|dS)Nzunclosed transport )source)r ResourceWarningrI)r-Z_warnrrr__del__qs z"_ProactorBasePipeTransport.__del__Fatal error on pipe transportc CsVzDt|tr*|jrBtjd||ddn|j||||jdW5||XdS)Nz%r: %sTr)message exceptionrr/) _force_close isinstanceOSErrorrrr debugcall_exception_handlerr+)r-excrNrrr _fatal_errorvs   z'_ProactorBasePipeTransport._fatal_errorcCs|jdk r6|js6|dkr*|jdn |j||jr@dSd|_|jd7_|jrj|jd|_|jr|jd|_d|_ d|_ |j |j |dS)NTrr) _empty_waiterdone set_resultZ set_exceptionr(r'r%rHr$r&r#rr*rG)r-rUrrrrPs"   z'_ProactorBasePipeTransport._force_closec Cs^z|j |W5t|jdr,|jtj|jd|_|j}|dk rX|d|_XdS)Nshutdown) hasattrr rZr Z SHUT_RDWRrIr"Z_detachr+Zconnection_lost)r-rUr2rrrrGs  z0_ProactorBasePipeTransport._call_connection_lostcCs"|j}|jdk r|t|j7}|SrB)r&r#r;)r-sizerrrget_write_buffer_sizes z0_ProactorBasePipeTransport.get_write_buffer_size)NNN)rM)r8 __module__ __qualname__rr?rr!rErFrIwarningswarnrLrVrPrGr] __classcell__rrr3rr.s  rcsPeZdZdfdd ZddZddZdd Zd d Zd d ZdddZ Z S)_ProactorReadPipeTransportNcs:d|_d|_t|||||||j|jd|_dS)NTF) _pending_data_pausedrrrr* _loop_readingr,r3rrrs z#_ProactorReadPipeTransport.__init__cCs|j o|j SrB)rer(rDrrr is_readingsz%_ProactorReadPipeTransport.is_readingcCs0|js |jrdSd|_|jr,td|dS)NTz%r pauses reading)r(rerrr rSrDrrr pause_readings   z(_ProactorReadPipeTransport.pause_readingcCsn|js |jsdSd|_|jdkr0|j|jd|j}d|_|dk rT|j|j||jrjt d|dS)NFz%r resumes reading) r(rer$rr*rfrd_data_receivedrr rSr-datarrrresume_readings   z)_ProactorReadPipeTransport.resume_readingc Cs|jrtd|z|j}WnLttfk r>Yn4tk rp}z| |dWYdSd}~XYnX|s~| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rSr+Z eof_received SystemExitKeyboardInterrupt BaseExceptionrVrI)r-Z keep_openrUrrr _eof_receiveds  z(_ProactorReadPipeTransport._eof_receivedc Cs|jr||_dS|s |dSt|jtjrzt|j|Wqtt fk rZYqt k r}z| |dWYdSd}~XYqXn |j |dS)Nz3Fatal error: protocol.buffer_updated() call failed.) rerdrprQr+rZBufferedProtocolZ_feed_data_to_buffered_protormrnrorVZ data_received)r-rkrUrrrris"z)_ProactorReadPipeTransport._data_receivedc Cstd}zRzp|dk r2d|_|r*|}n||jrHd}WWdS|dkr\WWdS|jsv|jj |j d|_Wnt k r}z0|js| |dn|j rtjdddW5d}~XYntk r}z||W5d}~XYnftk r}z| |dW5d}~XYn8tjk r>|js:YnX|jsV|j|jW5|dk rn||XdS)Niz"Fatal read error on pipe transportz*Read error on pipe transport while closingTr)rir$rXresultrHr(rer _proactorrecvr ConnectionAbortedErrorrVrr rSConnectionResetErrorrPrRrCancelledErroradd_done_callbackrf)r-futrkrUrrrrfs@     z(_ProactorReadPipeTransport._loop_reading)NNN)N) r8r^r_rrgrhrlrprirfrbrrr3rrcs rccsZeZdZdZfddZddZdddZd d Zd d Zd dZ ddZ ddZ Z S)_ProactorBaseWritePipeTransportTcstj||d|_dSrB)rrrWr-argskwr3rrrGsz(_ProactorBaseWritePipeTransport.__init__cCst|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jdkr|jt|dn.|jst||_|n|j||dS)Nz/data argument must be a bytes-like object, not zwrite_eof() already calledz(unable to write; sendfile is in progresszsocket.send() raised exception.r)rk)rQbytes bytearray memoryview TypeErrortyper8r) RuntimeErrorrWr'r!LOG_THRESHOLD_FOR_CONNLOST_WRITESr rr% _loop_writingr#_maybe_pause_protocolextendrjrrrwriteKs,       z%_ProactorBaseWritePipeTransport.writeNc CsVz|dk r |jdkr |jr WdSd|_d|_|r8||dkrL|j}d|_|s|jrf|j|jd|jrz|j t j | nN|jj|j ||_|jst||_|j|j|n|j|j|jdk r|jdkr|jdWn\tk r"}z||W5d}~XYn0tk rP}z||dW5d}~XYnXdS)Nrz#Fatal write error on pipe transport)r%r(r&rrr#rr*rGr)r rZr SHUT_WR_maybe_resume_protocolrssendrXr;rxrrrWrYrvrPrRrV)r-frkrUrrrrqs8    z-_ProactorBaseWritePipeTransport._loop_writingcCsdSNTrrDrrr can_write_eofsz-_ProactorBaseWritePipeTransport.can_write_eofcCs |dSrB)rIrDrrr write_eofsz)_ProactorBaseWritePipeTransport.write_eofcCs|ddSrBrPrDrrrabortsz%_ProactorBaseWritePipeTransport.abortcCs:|jdk rtd|j|_|jdkr4|jd|jS)NzEmpty waiter is already set)rWrrZ create_futurer%rYrDrrr_make_empty_waiters     z2_ProactorBaseWritePipeTransport._make_empty_waitercCs d|_dSrB)rWrDrrr_reset_empty_waitersz3_ProactorBaseWritePipeTransport._reset_empty_waiter)NN) r8r^r_Z_start_tls_compatiblerrrrrrrrrbrrr3rrzAs & )rzcs$eZdZfddZddZZS)_ProactorWritePipeTransportcs4tj|||jj|jd|_|j|jdS)N) rrrrsrtr r$rx _pipe_closedr{r3rrrsz$_ProactorWritePipeTransport.__init__cCs@|r dS|jrdSd|_|jdk r4|tn|dSrB)Z cancelledr(r$r%rPBrokenPipeErrorrI)r-ryrrrrs z(_ProactorWritePipeTransport._pipe_closed)r8r^r_rrrbrrr3rrs rcsXeZdZdZdfdd ZddZddZd d Zdd d Zdd dZ dddZ Z S)_ProactorDatagramTransportiNcs>||_d|_tj|||||dt|_|j|j dS)N)r0r1) _addressrWrr collectionsdequer#rr*rf)r-r.rr/addressr0r1r3rrrs  z#_ProactorDatagramTransport.__init__cCst||dSrBrrArrrrsz%_ProactorDatagramTransport._set_extracCstdd|jDS)Ncss|]\}}t|VqdSrB)r;).0rk_rrr szC_ProactorDatagramTransport.get_write_buffer_size..)sumr#rDrrrr]sz0_ProactorDatagramTransport.get_write_buffer_sizecCs|ddSrBrrDrrrrsz _ProactorDatagramTransport.abortcCst|tttfstdt||s&dS|jdk rN|d|jfkrNtd|j|jr|jr|jt j krpt d|jd7_dS|j t||f|jdkr||dS)Nz,data argument must be bytes-like object (%r)z!Invalid address: must be None or z!socket.sendto() raised exception.r)rQr~rrrrr ValueErrorr'rrr rr#r9r%rr)r-rkaddrrrrsendtos&     z!_ProactorDatagramTransport.sendtoc Cs z|jrWdSd|_|r ||jr2|jrN|jrN|jrH|j|jdWdS|j \}}|jdk r||jj |j ||_n|jj j |j ||d|_WnZtk r}z|j|W5d}~XYnDtk r}z||dW5d}~XYnX|j|j|dS)N)rz'Fatal write error on datagram transport)r'r%rrr#rr(rr*rGpopleftrsrr rrRr+error_received ExceptionrVrxrr)r-ryrkrrUrrrrs2    z(_ProactorDatagramTransport._loop_writingc Cs4d}zz|jrWWdSd|_|dk rf|}|jrFd}WWdS|jdk r^||j}}n|\}}|jrvWWdS|jdk r|jj |j |j |_n|jj |j |j |_WnJt k r}z|j|W5d}~XYn8tjk r|jsYnX|jdk r|j|jW5|r.|j||XdSrB)r+Zdatagram_receivedr'r$rrr(rrrsrtr max_sizeZrecvfromrRrrrwrxrf)r-ryrkrresrUrrrrfs>         z(_ProactorDatagramTransport._loop_reading)NNN)N)N)N) r8r^r_rrrr]rrrrfrbrrr3rrs   !rc@seZdZddZddZdS)_ProactorDuplexPipeTransportcCsdS)NFrrDrrrrJsz*_ProactorDuplexPipeTransport.can_write_eofcCstdSrB)NotImplementedErrorrDrrrrMsz&_ProactorDuplexPipeTransport.write_eofN)r8r^r_rrrrrrrEsrcs>eZdZejjZd fdd ZddZddZ dd Z Z S) _ProactorSocketTransportNcs$t||||||t|dSrB)rrrZ _set_nodelayr,r3rrrXsz!_ProactorSocketTransport.__init__cCst||dSrBrrArrrr]sz#_ProactorSocketTransport._set_extracCsdSrrrDrrrr`sz&_ProactorSocketTransport.can_write_eofcCs2|js |jrdSd|_|jdkr.|jtjdSr)r(r)r%r rZr rrDrrrrcs   z"_ProactorSocketTransport.write_eof)NNN) r8r^r_rZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrbrrr3rrQsrcseZdZfddZd3ddZd4dddddddd Zd5d d Zd6d d Zd7ddZd8ddZ fddZ ddZ ddZ ddZ ddZddZddZd d!Zd"d#Zd$d%Zd9d&d'Zd(d)Zd:d+d,Zd-d.Zd/d0Zd1d2ZZS);rcshttd|jj||_||_d|_i|_ | || t t krdt|jdS)NzUsing proactor: %s)rrr rSr4r8rs _selector_self_reading_future_accept_futuresZset_loop_make_self_pipe threadingcurrent_thread main_threadsignal set_wakeup_fd_csockr:)r-Zproactorr3rrrms  zBaseProactorEventLoop.__init__NcCst||||||SrB)r)r-rr/r0r1r2rrr_make_socket_transportzs z,BaseProactorEventLoop._make_socket_transportF) server_sideserver_hostnamer1r2ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)rr1r2)r Z SSLProtocolrZ_app_transport) r-Zrawsockr/ sslcontextr0rrr1r2rZ ssl_protocolrrr_make_ssl_transportsz)BaseProactorEventLoop._make_ssl_transportcCst||||||SrB)r)r-rr/rr0r1rrr_make_datagram_transports z.BaseProactorEventLoop._make_datagram_transportcCst|||||SrB)rr-rr/r0r1rrr_make_duplex_pipe_transports z1BaseProactorEventLoop._make_duplex_pipe_transportcCst|||||SrB)rcrrrr_make_read_pipe_transportsz/BaseProactorEventLoop._make_read_pipe_transportcCst|||||SrB)rrrrr_make_write_pipe_transports z0BaseProactorEventLoop._make_write_pipe_transportcsj|rtd|rdSttkr6td|| |j d|_ d|_ t dS)Nz!Cannot close a running event loop)Z is_runningr is_closedrrrrr_stop_accept_futures_close_self_pipersrIrrrDr3rrrIs  zBaseProactorEventLoop.closecs|j||IdHSrB)rsrt)r-rnrrr sock_recvszBaseProactorEventLoop.sock_recvcs|j||IdHSrB)rsZ recv_into)r-rZbufrrrsock_recv_intosz$BaseProactorEventLoop.sock_recv_intocs|j||IdHSrB)rsr)r-rrkrrr sock_sendallsz"BaseProactorEventLoop.sock_sendallcs|j||IdHSrB)rsZconnect)r-rrrrr sock_connectsz"BaseProactorEventLoop.sock_connectcs|j|IdHSrB)rsacceptrArrr sock_acceptsz!BaseProactorEventLoop.sock_acceptc s(z |}Wn2ttjfk r>}ztdW5d}~XYnXzt|j}Wn,t k r|}ztdW5d}~XYnX|r|n|}|sdSt |d}|rt |||n|} t ||}d} zLt | ||}|dkr| W0S|j ||||IdH||7}| |7} qW5| dkr"| |XdS)Nznot a regular filerl)r:AttributeErrorioUnsupportedOperationrZSendfileNotAvailableErrorosfstatst_sizerRminseekrssendfile) r-rfileoffsetcountr:errZfsizeZ blocksizeZend_posZ total_sentrrr_sock_sendfile_natives0     z+BaseProactorEventLoop._sock_sendfile_nativecsZ|}||IdHz |j|j|||ddIdHWS||rT|XdS)NF)Zfallback)rgrhrrrlZ sock_sendfiler )r-Ztransprrrrlrrr_sendfile_nativesz&BaseProactorEventLoop._sendfile_nativecCsL|jdk r|jd|_|jd|_|jd|_|jd8_dS)Nr)rrH_ssockrIr _internal_fdsrDrrrrs    z&BaseProactorEventLoop._close_self_pipecCs:t\|_|_|jd|jd|jd7_dS)NFr)r Z socketpairrrZ setblockingrrDrrrrs  z%BaseProactorEventLoop._make_self_pipec Csz4|dk r||j|k r"WdS|j|jd}Wnbtjk rLYdSttfk rdYnFt k r}z| d||dW5d}~XYnX||_| |j dS)Niz.Error on reading from the event loop self pipe)rNrOr.) rrrrsrtrrrwrmrnrorTrx_loop_self_reading)r-rrUrrrrs$ z(BaseProactorEventLoop._loop_self_readingcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTr)rrrR_debugr rS)r-Zcsockrrr_write_to_selfsz$BaseProactorEventLoop._write_to_selfdcs(dfdd dS)Nc s,z|dk rn|\}}jr,td||}dk rXj||dd|idnj||d|idr|WdSj}Wnt k r}zH dkrʈ d|t dnjrtjd dd W5d}~XYn8tjk rYnX|j <|dS) Nz#%r got a new connection from %r: %rTr)rr1r2rrrzAccept failed on a socket)rNrOr zAccept failed on socket %rr)rrrr rSrrrrsrrRr:rTr rrIrrwrrx)rZconnrr/rUr.protocol_factoryr-r2rrrrrr./s\   z2BaseProactorEventLoop._start_serving..loop)N)r*)r-rrrr2Zbacklogrrrr_start_serving+s%z$BaseProactorEventLoop._start_servingcCsdSrBr)r-Z event_listrrr_process_eventsVsz%BaseProactorEventLoop._process_eventscCs&|jD] }|q |jdSrB)rvaluesrHclear)r-futurerrrrZs z*BaseProactorEventLoop._stop_accept_futurescCs6|j|d}|r||j||dSrB)rpopr:rHrs _stop_servingrI)r-rrrrrr_s  z#BaseProactorEventLoop._stop_serving)NNN)N)NNN)NN)NN)NN)N)NNrN)r8r^r_rrrrrrrrIrrrrrrrrrrrrrrrrbrrr3rrks\            +r)"__all__rrr r`rrrrrrrrr r r logr rZ_FlowControlMixinZ BaseTransportrZ ReadTransportrcZWriteTransportrzrrZ TransportrrZ BaseEventLooprrrrrsP           n  __pycache__/windows_utils.cpython-38.opt-2.pyc000064400000007563152343727170015304 0ustar00U e5d@sddlZejdkredddlZddlZddlZddlZddlZddlZddl Z dZ dZ ej Z ej Z eZdde dd d ZGd d d ZGd ddejZdS)NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)Nz\\.\pipe\python-pipe-{:d}-{:d}-)prefixrTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@s^eZdZddZddZeddZddZej d d d Z e j fd d Z ddZddZdS)rcCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcseZdZdfdd ZZS)rNc sxd}}}d} } } |tkr@tddd\} } t| tj}n|}|tkrhtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d|Wn0| | | fD]}|dk rt |qւYn>X| dk r t | |_ | dk rt | |_| dk r2t | |_W5|tkrJt||tkr^t||tkrrt|XdS)N)FTT)rr)TFr r)stdinstdoutstderr)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr6r7r8)rargsr6r7r8kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsN              zPopen.__init__)NNN)r#r1r2r __classcell__rrr@rr}sr)sysplatform ImportErrorr itertoolsr9r subprocessr r4__all__ZBUFSIZErr;countrrrrrrrrs" 1,__pycache__/futures.cpython-38.pyc000064400000025673152343727170013131 0ustar00U e5db3@sdZdZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ej Z ej Z ejZejZejdZGd d d ZeZd d Zd dZddZddZddZddZddddZz ddlZWnek rYn XejZZdS)z.A Future class similar to the one in PEP 3148.)Future wrap_futureisfutureN) base_futures)events) exceptions)format_helpersc@seZdZdZeZdZdZdZdZ dZ dZ ddddZ e jZddZd d Zed d Zejd d ZddZddZddZddZddZddZddZddddZdd Zd!d"Zd#d$Zd%d&Z e Z!dS)'ra,This class is *almost* compatible with concurrent.futures.Future. Differences: - This class is not thread-safe. - result() and exception() do not take a timeout argument and raise an exception when the future isn't done yet. - Callbacks registered with add_done_callback() are always called via the event loop's call_soon(). - This class is not compatible with the wait() and as_completed() methods in the concurrent.futures package. (In Python 3.4 or later we may be able to unify the implementations.) NFloopcCs@|dkrt|_n||_g|_|jr )format __class____name__join _repr_inforrrr__repr__Vs  zFuture.__repr__cCsF|js dS|j}|jjd||d}|jr6|j|d<|j|dS)Nz exception was never retrieved)message exceptionfutureZsource_traceback)_Future__log_traceback _exceptionrrrr Zcall_exception_handler)rexccontextrrr__del__Zs  zFuture.__del__cCs|jSN)r#rrrr_log_tracebackjszFuture._log_tracebackcCst|rtdd|_dS)Nz'_log_traceback can only be set to FalseF)bool ValueErrorr#)rvalrrrr)nscCs|j}|dkrtd|S)z-Return the event loop the Future is bound to.Nz!Future object is not initialized.)r RuntimeErrorrrrrget_looptszFuture.get_loopcCs&d|_|jtkrdSt|_|dS)zCancel the future and schedule callbacks. If the future is already done or cancelled, return False. Otherwise, change the future's state to cancelled, schedule the callbacks and return True. FT)r#_state_PENDING _CANCELLED_Future__schedule_callbacksrrrrcancel{s  z Future.cancelcCsH|jdd}|sdSg|jdd<|D]\}}|jj|||dq(dS)zInternal: Ask the event loop to call all callbacks. The callbacks are scheduled to be called as soon as possible. Also clears the callback list. Nr&)rr call_soon)rZ callbackscallbackctxrrrZ__schedule_callbackss  zFuture.__schedule_callbackscCs |jtkS)z(Return True if the future was cancelled.)r/r1rrrr cancelledszFuture.cancelledcCs |jtkS)zReturn True if the future is done. Done means either that a result / exception are available, or that the future was cancelled. )r/r0rrrrdonesz Future.donecCs@|jtkrtj|jtkr$tdd|_|jdk r:|j|jS)aReturn the result this future represents. If the future has been cancelled, raises CancelledError. If the future's result isn't yet available, raises InvalidStateError. If the future is done and has an exception set, this exception is raised. zResult is not ready.FN) r/r1rCancelledError _FINISHEDInvalidStateErrorr#r$_resultrrrrresults    z Future.resultcCs0|jtkrtj|jtkr$tdd|_|jS)a&Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError. zException is not set.F)r/r1rr:r;r<r#r$rrrrr!s    zFuture.exceptionr4cCsB|jtkr|jj|||dn |dkr.t}|j||fdS)zAdd a callback to be run when the future becomes done. The callback is called with a single argument - the future object. If the future is already done when this is called, the callback is scheduled with call_soon. r4N)r/r0r r5 contextvarsZ copy_contextrappend)rfnr&rrradd_done_callbacks  zFuture.add_done_callbackcs<fdd|jD}t|jt|}|r8||jdd<|S)z}Remove all instances of a callback from the "call when done" list. Returns the number of callbacks removed. cs g|]\}}|kr||fqSrr).0fr7rArr sz/Future.remove_done_callback..N)rlen)rrAZfiltered_callbacksZ removed_countrrErremove_done_callbacks zFuture.remove_done_callbackcCs8|jtkr t|jd|||_t|_|dS)zMark the future done and set its result. If the future is already done when this method is called, raises InvalidStateError. : N)r/r0rr<r=r;r2)rr>rrr set_results  zFuture.set_resultcCsb|jtkr t|jd|t|tr0|}t|tkrDtd||_t |_| d|_ dS)zMark the future done and set an exception. If the future is already done when this method is called, raises InvalidStateError. rIzPStopIteration interacts badly with generators and cannot be raised into a FutureTN) r/r0rr< isinstancetype StopIteration TypeErrorr$r;r2r#)rr!rrr set_exceptions   zFuture.set_exceptionccs,|sd|_|V|s$td|S)NTzawait wasn't used with future)r9_asyncio_future_blockingr-r>rrrr __await__s zFuture.__await__)"r __module__ __qualname____doc__r0r/r=r$r rrPr#rrZ_future_repr_inforrr'propertyr)setterr.r3r2r8r9r>r!rBrHrJrOrQ__iter__rrrrrs:    rcCs,z |j}Wntk rYnX|S|jSr()r.AttributeErrorr )futr.rrr _get_loops  rZcCs|r dS||dS)z?Helper setting the result only if the future was not cancelled.N)r8rJ)rYr>rrr_set_result_unless_cancelledsr[cCsXt|}|tjjkr tj|jS|tjjkr8tj|jS|tjjkrPtj|jS|SdSr()rL concurrentfuturesr:rargs TimeoutErrorr<)r%Z exc_classrrr_convert_future_exc#s      r`cCs^|s t|r||s(dS|}|dk rH|t|n|}| |dS)z8Copy state from a future to a concurrent.futures.Future.N) r9AssertionErrorr8r3Zset_running_or_notify_cancelr!rOr`r>rJ)r\sourcer!r>rrr_set_concurrent_future_state/s rccCsl|s t|rdS|r$t|r6|n2|}|dk rV|t|n|}||dS)zqInternal helper to copy state from another Future. The other Future may be a concurrent.futures.Future. N) r9rar8r3r!rOr`r>rJ)rbdestr!r>rrr_copy_future_state>s   recststtjjstdts._set_statecs2|r.dkskr"n jdSr()r8r3call_soon_threadsafe) destination) dest_looprb source_looprr_call_check_cancelhs z)_chain_future.._call_check_cancelcsJrdk rrdSdks,kr8|n|dSr()r8Z is_closedrh)rb)rgrjrirkrr_call_set_stateos z&_chain_future.._call_set_state)rrKr\r]rrNrZrB)rbrirlrmr)rgrjrirbrkr _chain_futureRs   rnr cCsNt|r |St|tjjs(td||dkr8t}|}t |||S)z&Wrap concurrent.futures.Future object.z+concurrent.futures.Future is expected, got N) rrKr\r]rrarr Z create_futurern)r"r Z new_futurerrrr|s r)rT__all__Zconcurrent.futuresr\r?Zloggingrrrrr rr0r1r;DEBUGZ STACK_DEBUGrZ _PyFuturerZr[r`rcrernrZ_asyncio ImportErrorZ_CFuturerrrrs:     q  *  __pycache__/locks.cpython-38.pyc000064400000037762152343727170012551 0ustar00U e5d|C@sdZdZddlZddlZddlZddlmZddlmZddlmZddlm Z Gd d d Z Gd d d Z Gd dde Z GdddZ Gddde ZGddde ZGdddeZdS)zSynchronization primitives.)LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s(eZdZdZddZddZddZdS) _ContextManagera\Context manager. This enables the following idiom for acquiring and releasing a lock around a block: with (yield from lock): while failing loudly when accidentally using: with lock: Deprecated, use 'async with' statement: async with lock: cCs ||_dSN)_lock)selflockr%/usr/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname____doc__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r&r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadr r!)r#r$r%!_ContextManagerMixin__acquire_ctx __await__rrrrr)Ys z_ContextManagerMixin.__await__cs|IdHdSr )r&rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner'r Z _is_coroutiner(r)r*r.rrrrr1s rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)raPrimitive lock objects. A primitive lock is a synchronization primitive that is not owned by a particular coroutine when locked. A primitive lock is in one of two states, 'locked' or 'unlocked'. It is created in the unlocked state. It has two basic methods, acquire() and release(). When the state is unlocked, acquire() changes the state to locked and returns immediately. When the state is locked, acquire() blocks until a call to release() in another coroutine changes it to unlocked, then the acquire() call resets it to locked and returns. The release() method should only be called in the locked state; it changes the state to unlocked and returns immediately. If an attempt is made to release an unlocked lock, a RuntimeError will be raised. When more than one coroutine is blocked in acquire() waiting for the state to turn to unlocked, only one coroutine proceeds when a release() call resets the state to unlocked; first coroutine which is blocked in acquire() is being processed. acquire() is a coroutine and should be called with 'await'. Locks also support the asynchronous context management protocol. 'async with lock' statement should be used. Usage: lock = Lock() ... await lock.acquire() try: ... finally: lock.release() Context manager usage: lock = Lock() ... async with lock: ... Lock objects can be tested for locking state: if not lock.locked(): await lock.acquire() else: # lock is acquired ... NloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r r!)_waiters_lockedrget_event_loop_loopr#r$r%rr2rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r6r5lenrresZextra __class__rrrBs  z Lock.__repr__cCs|jS)z Return True if lock is acquired.)r6rrrrr;sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)zAcquire a lock. This method blocks until the lock is unlocked, then sets it to locked and returns True. Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r6r5all collectionsdequer8 create_futureappendremover CancelledError_wake_up_firstrfutrrrr&s&    z Lock.acquirecCs"|jrd|_|ntddS)aGRelease a lock. When the lock is locked, reset it to unlocked, and return. If any other coroutines are blocked waiting for the lock to become unlocked, allow exactly one of them to proceed. When invoked on an unlocked lock, a RuntimeError is raised. There is no return value. FzLock is not acquired.N)r6rSrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddS)z*Wake up the first waiter if it isn't done.NT)r5nextiter StopIterationdone set_resultrTrrrrSszLock._wake_up_first) rrrrrrBr;r&rrS __classcell__rrrFrrjs5  rcsNeZdZdZddddZfddZdd Zd d Zd d ZddZ Z S)ra#Asynchronous equivalent to threading.Event. Class implementing event objects. An event manages a flag that can be set to true with the set() method and reset to false with the clear() method. The wait() method blocks until the flag is true. The flag is initially false. Nr1cCs>t|_d|_|dkr$t|_n||_tjdt dddSr3) rMrNr5_valuerr7r8r#r$r%r9rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr<r=rr>r?r@)rArBr\r5rCrDrFrrrB s  zEvent.__repr__cCs|jS)z5Return True if and only if the internal flag is true.r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdS)zSet the internal flag to true. All coroutines waiting for it to become true are awakened. Coroutine that call wait() once the flag is true will not block at all. TN)r\r5rYrZrTrrrr]s  z Event.setcCs d|_dS)zReset the internal flag to false. Subsequently, coroutines calling wait() will block until set() is called to set the internal flag to true again.FNr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdS)zBlock until the internal flag is true. If the internal flag is true on entry, return True immediately. Otherwise, block until another coroutine calls set() to set the flag to true, then return True. TN)r\r8rOr5rPrQrTrrrwait(s   z Event.wait) rrrrrrBr_r]r`rar[rrrFrrs  rcsReZdZdZdddddZfddZdd Zd d Zdd dZddZ Z S)raAsynchronous equivalent to threading.Condition. This class implements condition variable objects. A condition variable allows one or more coroutines to wait until they are notified by another coroutine. A new Lock object is created and used as the underlying lock. Nr1cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr4r r!r1z"loop argument must agree with lock)rr7r8r#r$r%r ValueErrorrr;r&rrMrNr5)rrr2rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr:)rArBr;r5rCrDrFrrrB[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)aWait until notified. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method releases the underlying lock, and then blocks until it is awakened by a notify() or notify_all() call for the same condition variable in another coroutine. Once awakened, it re-acquires the lock and returns True. zcannot wait on un-acquired lockFNT) r;rrr&r rRr8rOr5rPrQ)rrHrUrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|S)zWait until a predicate becomes true. The predicate should be a callable which result will be interpreted as a boolean value. The final predicate value is the return value. N)ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)aBy default, wake up one coroutine waiting on this condition, if any. If the calling coroutine has not acquired the lock when this method is called, a RuntimeError is raised. This method wakes up at most n of the coroutines waiting for the condition variable; it is a no-op if no coroutines are waiting. Note: an awakened coroutine does not actually return from its wait() call until it can reacquire the lock. Since notify() does not release the lock, its caller should. z!cannot notify on un-acquired lockrrFN)r;rr5rYrZ)rnidxrUrrrnotifys  zCondition.notifycCs|t|jdS)aWake up all threads waiting on this condition. This method acts like notify(), but wakes up all waiting threads instead of one. If the calling thread has not acquired the lock when this method is called, a RuntimeError is raised. N)rgrCr5rrrr notify_allszCondition.notify_all)N)r) rrrrrrBrardrgrhr[rrrFrr;s  % rcsPeZdZdZdddddZfddZd d Zd d Zd dZddZ Z S)raA Semaphore implementation. A semaphore manages an internal counter which is decremented by each acquire() call and incremented by each release() call. The counter can never go below zero; when acquire() finds that it is zero, it blocks, waiting until some other thread calls release(). Semaphores also support the context management protocol. The optional argument gives the initial value for the internal counter; it defaults to 1. If the value given is less than 0, ValueError is raised. rNr1cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r4r r!) rbr\rMrNr5rr7r8r#r$r%rvaluer2rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr;zunlocked, value:r<r=rr>r?r@)rArBr;r\r5rCrDrFrrrBs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r5popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)z:Returns True if semaphore can not be acquired immediately.rr^rrrrr;szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)a5Acquire a semaphore. If the internal counter is larger than zero on entry, decrement it by one and return True immediately. If it is zero on entry, block, waiting until some other coroutine has called release() to make it larger than 0, and then return True. rNrT)r\r8rOr5rPZcancelrHrlrTrrrr&s    zSemaphore.acquirecCs|jd7_|dS)zRelease a semaphore, incrementing the internal counter by one. When it was zero on entry and another coroutine is waiting for it to become larger than zero again, wake up that coroutine. rN)r\rlrrrrrszSemaphore.release)r) rrrrrrBrlr;r&rr[rrrFrrs rcs4eZdZdZd ddfdd ZfddZZS) rzA bounded semaphore implementation. This raises ValueError in release() if it would increase the value above the initial value. rNr1cs.|rtjdtdd||_tj||ddS)Nr4r r!r1)r#r$r% _bound_valuerArrirFrrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbrArrrFrrrs zBoundedSemaphore.release)r)rrrrrrr[rrrFrrs r)r__all__rMr/r#rr r r r rrrrrrrrrrs     "9DzN__pycache__/queues.cpython-38.opt-2.pyc000064400000013110152343727170013662 0ustar00U e5d @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@s eZdZdS)rN__name__ __module__ __qualname__rr&/usr/lib64/python3.8/asyncio/queues.pyr src@s eZdZdS)rNr rrrrrsrc@seZdZd(ddddZddZdd Zd d Zd d ZddZddZ ddZ ddZ e ddZ ddZddZddZddZd d!Zd"d#Zd$d%Zd&d'ZdS))rrNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer!r"rrrr 6sz Queue._initcCs |jSr$)r%popleftr!rrr_get9sz Queue._getcCs|j|dSr$r%appendr!itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr$)r'ZdoneZ set_result)r!waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr(rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr1r2r3)r4r r6r(rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r%z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr%rlenrr)r!resultrrrr6Os  z Queue._formatcCs t|jSr$)r<r%r(rrrqsize[sz Queue.qsizecCs|jSr$)rr(rrrr"_sz Queue.maxsizecCs|j Sr$r%r(rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)NrF)rr>r(rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |Sr$) rAr create_futurerr+cancelremove ValueError cancelledr0 put_nowait)r!r-Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)Nr)rArr.rrclearr0rr,rrrrGs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| Sr$) r@rrBrr+rCrDrErFr0 get_nowait)r!getterrrrgets    z Queue.getcCs$|r t|}||j|Sr$)r@rr)r0rr,rrrrJs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)Nrz!task_done() called too many timesr)rrErrr(rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)Nr)rrwaitr(rrrjoins z Queue.join)r)r r r r#r r)r.r0r7r8r6r>propertyr"r@rArHrGrLrJrMrOrrrrrs&      rc@s0eZdZddZejfddZejfddZdS)rcCs g|_dSr$r?r&rrrr szPriorityQueue._initcCs||j|dSr$r?)r!r-heappushrrrr.szPriorityQueue._putcCs ||jSr$r?)r!heappoprrrr)szPriorityQueue._getN) r r r r heapqrQr.rRr)rrrrrsrc@s$eZdZddZddZddZdS)rcCs g|_dSr$r?r&rrrr szLifoQueue._initcCs|j|dSr$r*r,rrrr.szLifoQueue._putcCs |jSr$)r%popr(rrrr)szLifoQueue._getN)r r r r r.r)rrrrrsr) __all__rrSrrr Exceptionrrrrrrrrrs  K__pycache__/constants.cpython-38.opt-1.pyc000064400000001107152343727170014371 0ustar00U e5dx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r )/usr/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s __pycache__/selector_events.cpython-38.pyc000064400000071767152343727170014645 0ustar00U e5dT@s.dZdZddlZddlZddlZddlZddlZddlZddlZz ddl Z Wne k rddZ YnXddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd lmZddZddZGddde jZGdddejejZGdddeZGdddeZdS)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)loggercCs8z||}Wntk r$YdSXt|j|@SdSNF)get_keyKeyErrorboolr)selectorfdZeventkeyr//usr/lib64/python3.8/asyncio/selector_events.py_test_selector_event s rcCs tdk rt|tjrtddS)Nz"Socket cannot be of type SSLSocket)ssl isinstanceZ SSLSocket TypeError)sockrrr_check_ssl_socket+srcseZdZdZdSfdd ZdTdddddZdUddddejd d d ZdVd d Z fddZ ddZ ddZ ddZ ddZddZdddejfddZdddejfddZddejfdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+Z,S)WrzJSelector event loop. See events.EventLoop for API specification. NcsFt|dkrt}td|jj||_| t |_ dS)NzUsing selector: %s) super__init__ selectorsZDefaultSelectorr debug __class____name__ _selector_make_self_pipeweakrefZWeakValueDictionary _transports)selfrr rrr6s zBaseSelectorEventLoop.__init__extraservercCst||||||SN)_SelectorSocketTransport)r&rprotocolwaiterr)r*rrr_make_socket_transport@s z,BaseSelectorEventLoop._make_socket_transportF) server_sideserver_hostnamer)r*ssl_handshake_timeoutc Cs0tj||||||| d} t||| ||d| jS)N)r2r()r Z SSLProtocolr,Z_app_transport) r&Zrawsockr- sslcontextr.r0r1r)r*r2Z ssl_protocolrrr_make_ssl_transportEsz)BaseSelectorEventLoop._make_ssl_transportcCst||||||Sr+)_SelectorDatagramTransport)r&rr-addressr.r)rrr_make_datagram_transportRs z.BaseSelectorEventLoop._make_datagram_transportcsL|rtd|rdS|t|jdk rH|jd|_dS)Nz!Cannot close a running event loop)Z is_running RuntimeError is_closed_close_self_pipercloser"r&r'rrr;Ws   zBaseSelectorEventLoop.closecCsB||j|jd|_|jd|_|jd8_dS)Nr)_remove_reader_ssockfilenor;_csock _internal_fdsr<rrrr:bs   z&BaseSelectorEventLoop._close_self_pipecCsNt\|_|_|jd|jd|jd7_||j|jdS)NFr) socketZ socketpairr>r@ setblockingrA _add_readerr?_read_from_selfr<rrrr#js   z%BaseSelectorEventLoop._make_self_pipecCsdSr+rr&datarrr_process_self_datarsz(BaseSelectorEventLoop._process_self_datacCsXz"|jd}|sWqT||Wqtk r:YqYqtk rPYqTYqXqdS)Ni)r>recvrHInterruptedErrorBlockingIOErrorrFrrrrEus z%BaseSelectorEventLoop._read_from_selfcCsN|j}|dkrdSz|dWn(tk rH|jrDtjdddYnXdS)Nz3Fail to write a null byte into the self-pipe socketTexc_info)r@sendOSError_debugr r)r&Zcsockrrr_write_to_selfsz$BaseSelectorEventLoop._write_to_selfdc Cs"|||j||||||dSr+)rDr?_accept_connection)r&protocol_factoryrr3r*backlogr2rrr_start_servingsz$BaseSelectorEventLoop._start_servingc Cst|D]}z0|\}} |jr0td|| ||dWntttfk rZYdSt k r} zd| j t j t j t j t jfkr|d| t|d|||tj|j||||||nW5d} ~ XYqXd| i} |||| |||} || qdS)Nz#%r got a new connection from %r: %rFz&socket.accept() out of system resource)message exceptionrBpeername)rangeacceptrQr rrCrKrJConnectionAbortedErrorrPerrnoZEMFILEZENFILEZENOBUFSZENOMEMcall_exception_handlerr TransportSocketr=r?Z call_laterrZACCEPT_RETRY_DELAYrW_accept_connection2Z create_task) r&rUrr3r*rVr2_connaddrexcr)r\rrrrTsV   z(BaseSelectorEventLoop._accept_connectionc sd}d}zt|}|} |r8|j|||| d|||d}n|j||| ||d}z| IdHWntk rx|YnXWntttfk rYn\tk r} z>|jrd| d} |dk r|| d<|dk r|| d<|| W5d} ~ XYnXdS)NT)r.r0r)r*r2)r.r)r*z3Error on transport creation for incoming connection)rXrYr- transport) create_futurer4r/ BaseExceptionr; SystemExitKeyboardInterruptrQr_) r&rUrcr)r3r*r2r-rfr.recontextrrrrasP z)BaseSelectorEventLoop._accept_connection2c Cs|}t|tsJzt|}Wn*tttfk rHtd|dYnXz|j|}Wntk rlYnX|st d|d|dS)NzInvalid file object: zFile descriptor z is used by transport ) rintr?AttributeErrorr ValueErrorr%r is_closingr8)r&rr?rfrrr_ensure_fd_no_transports z-BaseSelectorEventLoop._ensure_fd_no_transportc Gs|t|||d}z|j|}Wn*tk rR|j|tj|dfYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) _check_closedrHandler"rrregisterr EVENT_READrGmodifycancel r&rcallbackargsZhandlermaskreaderwriterrrrrDs  z!BaseSelectorEventLoop._add_readercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j ||d|f|dk r| dSdSdSNFT) r9r"rrrrGrrt unregisterrurvr&rrrzr{r|rrrr=s z$BaseSelectorEventLoop._remove_readerc Gs|t|||d}z|j|}Wn*tk rR|j|tjd|fYn>X|j|j }\}}|j ||tjB||f|dk r| dSr+) rqrrrr"rrrsr EVENT_WRITErGrurvrwrrr _add_writer%s  z!BaseSelectorEventLoop._add_writercCs|r dSz|j|}Wntk r2YdSX|j|j}\}}|tjM}|sd|j|n|j |||df|dk r| dSdSdS)Remove a writer callback.FNT) r9r"rrrrGrrr~rurvrrrr_remove_writer4s z$BaseSelectorEventLoop._remove_writercGs|||j||f|S)zAdd a reader callback.)rprDr&rrxryrrr add_readerKs z BaseSelectorEventLoop.add_readercCs||||S)zRemove a reader callback.)rpr=r&rrrr remove_readerPs z#BaseSelectorEventLoop.remove_readercGs|||j||f|S)zAdd a writer callback..)rprrrrr add_writerUs z BaseSelectorEventLoop.add_writercCs||||S)r)rprrrrr remove_writerZs z#BaseSelectorEventLoop.remove_writerc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)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-blockingN)rrQ gettimeoutrnrIrKrJrgr?r _sock_recvadd_done_callback functoolspartial_sock_read_done)r&rnfutrrrr sock_recv_s  zBaseSelectorEventLoop.sock_recvcCs||dSr+)rr&rrrrrrtsz%BaseSelectorEventLoop._sock_read_donec Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) donerIrKrJrirjrh set_exception set_result)r&rrrrGrerrrrwsz BaseSelectorEventLoop._sock_recvc st||jr"|dkr"tdz ||WSttfk rFYnX|}|}| ||j |||| t |j||IdHS)zReceive data from the socket. The received data is written into *buf* (a writable buffer). The return value is the number of bytes written. rrN)rrQrrn recv_intorKrJrgr?r_sock_recv_intorrrr)r&rbufrrrrrsock_recv_intos  z$BaseSelectorEventLoop.sock_recv_intoc Cs|r dSz||}Wn\ttfk r4YdSttfk rLYn6tk rv}z||W5d}~XYn X||dSr+) rrrKrJrirjrhrr)r&rrrnbytesrerrrrsz%BaseSelectorEventLoop._sock_recv_intoc st||jr"|dkr"tdz||}Wnttfk rLd}YnX|t|kr^dS|}| }| t |j ||||j||t||g|IdHS)aSend 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. rrN)rrQrrnrOrKrJlenrgr?rrr_sock_write_doner _sock_sendall memoryview)r&rrGrrrrrr sock_sendalls&    z"BaseSelectorEventLoop.sock_sendallc Cs|r dS|d}z|||d}Wnbttfk rDYdSttfk r\Yn2tk r}z||WYdSd}~XYnX||7}|t|kr| dn||d<dS)Nr) rrOrKrJrirjrhrrr)r&rrZviewposstartrrerrrrs    z#BaseSelectorEventLoop._sock_sendallcst||jr"|dkr"tdttdr8|jtjkrf|j||j|j |dIdH}|d\}}}}}| }| ||||IdHS)zTConnect to a remote socket at address. This method is a coroutine. rrAF_UNIX)familyprotoloopN) rrQrrnhasattrrBrrZ_ensure_resolvedrrg _sock_connect)r&rr6Zresolvedrbrrrr sock_connects z"BaseSelectorEventLoop.sock_connectc Cs|}z||Wnttfk rV|t|j||||j |||YnNt t fk rnYn6t k r}z| |W5d}~XYn X|ddSr+)r?ZconnectrKrJrrrrr_sock_connect_cbrirjrhrr)r&rrr6rrerrrrs z#BaseSelectorEventLoop._sock_connectcCs||dSr+)rrrrrrsz&BaseSelectorEventLoop._sock_write_donec Cs|r dSz,|tjtj}|dkr6t|d|WnZttfk rPYnNtt fk rhYn6t k r}z| |W5d}~XYn X| ddS)NrzConnect call failed ) rZ getsockoptrBZ SOL_SOCKETZSO_ERRORrPrKrJrirjrhrr)r&rrr6errrerrrrsz&BaseSelectorEventLoop._sock_connect_cbcsBt||jr"|dkr"td|}||d||IdHS)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. rrFN)rrQrrnrg _sock_accept)r&rrrrr sock_accepts z!BaseSelectorEventLoop.sock_acceptc Cs|}|r|||r"dSz|\}}|dWnnttfk rh|||j|d|YnRt t fk rYn:t k r}z| |W5d}~XYnX| ||fdSr})r?rrr\rCrKrJrrrirjrhrr)r&rZ registeredrrrcr6rerrrr*s  z"BaseSelectorEventLoop._sock_acceptc sp|j|j=|}||IdHz |j|j|||ddIdHWS||r^|||j|j<XdS)NF)Zfallback) r%_sock_fd is_reading pause_reading_make_empty_waiter_reset_empty_waiterresume_readingZ sock_sendfile_sock)r&Ztranspfileoffsetcountrrrr_sendfile_native<s z&BaseSelectorEventLoop._sendfile_nativecCs|D]v\}}|j|j}\}}|tj@rL|dk rL|jrB||n |||tj@r|dk r|jrp||q||qdSr+) fileobjrGrrtZ _cancelledr=Z _add_callbackrr)r&Z event_listrrzrr{r|rrr_process_eventsJs    z%BaseSelectorEventLoop._process_eventscCs|||dSr+)r=r?r;)r&rrrr _stop_servingXsz#BaseSelectorEventLoop._stop_serving)N)N)N)NNN)-r! __module__ __qualname____doc__rr/rZSSL_HANDSHAKE_TIMEOUTr4r7r;r:r#rHrErRrWrTrarprDr=rrrrrrrrrrrrrrrrrrrrrr __classcell__rrr'rr0s~        . )rcseZdZdZeZdZdfdd ZddZddZ d d Z d d Z d dZ ddZ ejfddZdddZddZddZddZddZZS) _SelectorTransportiNcst||t||jd<z||jd<Wntk rNd|jd<YnXd|jkrz||jd<Wn tj k rd|jd<YnX||_ | |_ d|_ ||||_||_d|_d|_|jdk r|j||j|j <dS)NrBZsocknamerZFr)rrr r`_extraZ getsocknamerPZ getpeernamerBerrorrr?r_protocol_connected set_protocol_server_buffer_factory_buffer _conn_lost_closingZ_attachr%)r&rrr-r)r*r'rrris,      z_SelectorTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|j|jdk r|jst|jj |jt j }|rz|dn |dt|jj |jt j }|rd}nd}| }|d|d |d d d |S) Nclosedclosingzfd=z read=pollingz read=idlepollingZidlezwrite=z<{}> )r r!rappendrr_loopr9rr"rrtrget_write_buffer_sizeformatjoin)r&inforstatebufsizerrr__repr__s0      z_SelectorTransport.__repr__cCs|ddSr+) _force_closer<rrrabortsz_SelectorTransport.abortcCs||_d|_dSNT) _protocolrr&r-rrrrsz_SelectorTransport.set_protocolcCs|jSr+)rr<rrr get_protocolsz_SelectorTransport.get_protocolcCs|jSr+)rr<rrrrosz_SelectorTransport.is_closingcCsT|jr dSd|_|j|j|jsP|jd7_|j|j|j|jddSNTr) rrr=rrrr call_soon_call_connection_lostr<rrrr;sz_SelectorTransport.closecCs,|jdk r(|d|t|d|jdS)Nzunclosed transport )source)rResourceWarningr;)r&Z_warnrrr__del__s z_SelectorTransport.__del__Fatal error on transportcCsNt|tr(|jr@tjd||ddn|j||||jd||dS)Nz%r: %sTrM)rXrYrfr-) rrPr get_debugr rr_rr)r&rerXrrr _fatal_errors  z_SelectorTransport._fatal_errorcCsd|jr dS|jr(|j|j|j|jsBd|_|j|j|jd7_|j|j |dSr) rrclearrrrrr=rrr&rerrrrs z_SelectorTransport._force_closecCsVz|jr|j|W5|jd|_d|_d|_|j}|dk rP|d|_XdSr+)rr;rrrZ_detachrZconnection_lost)r&rer*rrrrs z(_SelectorTransport._call_connection_lostcCs t|jSr+)rrr<rrrrsz(_SelectorTransport.get_write_buffer_sizecGs"|jr dS|jj||f|dSr+)rrrDrrrrrDsz_SelectorTransport._add_reader)NN)r)r!rrmax_size bytearrayrrrrrrrror;warningswarnrrrrrrDrrrr'rr]s    rcseZdZdZejjZd#fdd ZfddZ ddZ d d Z d d Z d dZ ddZddZddZddZddZddZddZfddZdd Zd!d"ZZS)$r,TNcs~d|_t|||||d|_d|_d|_t|j|j |j j ||j |j |j|j|dk rz|j tj|ddSr )_read_ready_cbrr_eof_paused _empty_waiterrZ _set_nodelayrrrrconnection_maderDr _read_readyr_set_result_unless_cancelled)r&rrr-r.r)r*r'rrrs    z!_SelectorSocketTransport.__init__cs.t|tjr|j|_n|j|_t|dSr+)rrZBufferedProtocol_read_ready__get_bufferr_read_ready__data_receivedrrrr'rrr s  z%_SelectorSocketTransport.set_protocolcCs|j o|j Sr+)rrr<rrrrsz#_SelectorSocketTransport.is_readingcCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrr=rrr rr<rrrrs   z&_SelectorSocketTransport.pause_readingcCs@|js |jsdSd|_||j|j|jrYn4tk rp}z| |dWYdSd}~XYnX|r|j |j n| dS)Nz%r received EOFz1Fatal error: protocol.eof_received() call failed.) rrr rrZ eof_receivedrirjrhrr=rr;)r&Z keep_openrerrrres  z,_SelectorSocketTransport._read_ready__on_eofc Cs6t|tttfs$tdt|j|jr2td|j dk rDtd|sLdS|j rz|j t j krht d|j d7_ dS|jsz|j|}Wnbttfk rYnbttfk rYnJtk r}z||dWYdSd}~XYnX||d}|s dS|j|j|j|j||dS)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)rbytesrrrtyper!rr8rrr!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrrOrKrJrirjrhrrrr _write_readyextend_maybe_pause_protocol)r&rGrrerrrwritezs:      z_SelectorSocketTransport.writec Cs(|jstd|jrdSz|j|j}Wnttfk rBYnttfk rZYnt k r}z>|j |j |j ||d|jdk r|j|W5d}~XYnpX|r|jd|=||js$|j |j |jdk r|jd|jr|dn|jr$|jtjdS)NzData should not be emptyr)rAssertionErrorrrrOrKrJrirjrhrrrrrrr_maybe_resume_protocolrrrrshutdownrBSHUT_WR)r&rrerrrrs4       z%_SelectorSocketTransport._write_readycCs.|js |jrdSd|_|js*|jtjdSr)rrrrrrBrr<rrr write_eofs  z"_SelectorSocketTransport.write_eofcCsdSrrr<rrr can_write_eofsz&_SelectorSocketTransport.can_write_eofcs*t||jdk r&|jtddS)NzConnection is closed by peer)rrrrConnectionErrorrr'rrrs   z._SelectorSocketTransport._call_connection_lostcCs6|jdk rtd|j|_|js0|jd|jS)NzEmpty waiter is already set)rr8rrgrrr<rrrrs    z+_SelectorSocketTransport._make_empty_waitercCs d|_dSr+)rr<rrrrsz,_SelectorSocketTransport._reset_empty_waiter)NNN)r!rrZ_start_tls_compatiblerZ _SendfileModeZ TRY_NATIVEZ_sendfile_compatiblerrrrrrrrrrrr r rrrrrrr'rr,s* %' r,csFeZdZejZd fdd ZddZddZd dd Z d d Z Z S)r5Ncs^t||||||_|j|jj||j|j|j|j |dk rZ|jt j |ddSr+) rr_addressrrrrrDrrrr)r&rrr-r6r.r)r'rrrs  z#_SelectorDatagramTransport.__init__cCstdd|jDS)Ncss|]\}}t|VqdSr+)r).0rGrbrrr szC_SelectorDatagramTransport.get_write_buffer_size..)sumrr<rrrrsz0_SelectorDatagramTransport.get_write_buffer_sizec Cs|jr dSz|j|j\}}Wnttfk r8Yntk rd}z|j|W5d}~XYnTt t fk r|Yn<t k r}z| |dW5d}~XYnX|j ||dS)Nz&Fatal read error on datagram transport)rrZrecvfromrrKrJrPrerror_receivedrirjrhrZdatagram_receivedr&rGrdrerrrrsz&_SelectorDatagramTransport._read_readyc Cst|tttfs$tdt|j|s,dS|jrV|d|jfkrPtd|j|j}|j r|jr|j t j krxt d|j d7_ dS|jslz,|jdr|j|n|j||WdSttfk r|j|j|jYntk r}z|j|WYdSd}~XYnPttfk r6Yn6tk rj}z||dWYdSd}~XYnX|j t||f|!dS)Nrz!Invalid address: must be None or rrrZ'Fatal write error on datagram transport)"rrrrrrr!r rnrrrr rrrrrOsendtorKrJrrr _sendto_readyrPrrrirjrhrrrrrrrrsH      z!_SelectorDatagramTransport.sendtoc Cs|jr|j\}}z*|jdr.|j|n|j||Wqttfk rj|j||fYqYqt k r}z|j |WYdSd}~XYqt t fk rYqtk r}z||dWYdSd}~XYqXq||js|j|j|jr|ddS)NrZr)rpopleftrrrOrrKrJ appendleftrPrrrirjrhrrrrrrrrrrrr*s2  z(_SelectorDatagramTransport._sendto_ready)NNN)N) r!rr collectionsdequerrrrrrrrrr'rr5s  +r5)r__all__rr^rrrBrr$r ImportErrorrrrrrr r r logr rrZ BaseEventLooprZ_FlowControlMixinZ Transportrr,r5rrrrsF            1o__pycache__/base_events.cpython-38.opt-2.pyc000064400000121527152343727170014665 0ustar00U e5d@sddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlm Z dZ!dZ"dZ#e$edZ%dZ&e'Z(ddZ)ddZ*ddZ+d*ddZ,d+ddZ-ddZ.e$ed rd!d"Z/nd#d"Z/Gd$d%d%ej0Z1Gd&d'd'ej2Z3Gd(d)d)ej4Z5dS),N) constants) coroutines)events) exceptions)futures) protocols)sslproto) staggered)tasks) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr+/usr/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)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"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)Nrrcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs|jd7_dSrZ)rrqrrr_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|dS)Nrr)rr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdSNT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)Nr)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)Nz'task factory must be a callable or None)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jSrB)rrqrrrget_task_factoryszBaseEventLoop.get_task_factory)extraservercCstdSrBNotImplementedError)rfr*protocolrrrrrr_make_socket_transportsz$BaseEventLoop._make_socket_transportFT) server_sideserver_hostnamerrrcall_connection_madec CstdSrBr) rfZrawsockr sslcontextrrrrrrrrrr_make_ssl_transportsz!BaseEventLoop._make_ssl_transportcCstdSrBr)rfr*raddressrrrrr_make_datagram_transportsz&BaseEventLoop._make_datagram_transportcCstdSrBrrfpiperrrrrr_make_read_pipe_transportsz'BaseEventLoop._make_read_pipe_transportcCstdSrBrrrrr_make_write_pipe_transportsz(BaseEventLoop._make_write_pipe_transportc stdSrBr) rfrargsshellstdinstdoutstderrbufsizerkwargsrrr_make_subprocess_transportsz(BaseEventLoop._make_subprocess_transportcCstdSrBrrqrrr_write_to_selfszBaseEventLoop._write_to_selfcCstdSrBr)rf event_listrrr_process_eventsszBaseEventLoop._process_eventscCs|jrtddS)NzEvent loop is closed)rrmrqrrrrszBaseEventLoop._check_closedcCs*|j||s&||j|dSrB)rdiscardrcall_soon_threadsaferacloserfagenrrr_asyncgen_finalizer_hooks z&BaseEventLoop._asyncgen_finalizer_hookcCs.|jrtjd|dt|d|j|dS)Nzasynchronous generator z3 was scheduled after loop.shutdown_asyncgens() callsource)rwarningswarnResourceWarningraddrrrr_asyncgen_firstiter_hooks z&BaseEventLoop._asyncgen_firstiter_hookcsd|_t|jsdSt|j}|jtjdd|Dd|dIdH}t||D]*\}}t|t rT| d|||dqTdS)NTcSsg|] }|qSr)r)rCZagrrr sz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)N) firstiter finalizerF)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|S)N call_soonr)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rZHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)NzMNon-thread-safe operation invoked on an event loop other than the current one)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)Nrr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrr rr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r'c s2|jr|j}ntj}|d|||||||IdHSrB)rr,r$r%r)rfr;r<r=r>r?r'Z getaddr_funcrrrr%2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr'rrrr.<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr/rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr2rfr*r4r5r6rrrr1Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r:minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r4r5r6 blocksizebuf total_sentviewreadrrrr3Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)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%r>r$r1rr4r5formatr9rrrr0os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr(rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r'r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfdd |D| d IdH\}}}|dkr d d Dt dkrd nJt d t fdd Dr҈d td d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r'r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrQ)rCr*)r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r#css|]}t|VqdSrBr^r_rrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrQr Zstaggered_racerrallrFr$r>_create_connection_transportrget_extra_inforr )rfrr;r<rRr=r?r'r*rSrrrTrUinfosr*rPrnrr)rr\r`rfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rIrdrboolrrr) rfr*rrRrrrrrrrnrrrrd%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)NzTransport is closingZ_sendfile_compatiblez(sendfile is not supported for transport zHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr2_sendfile_fallback)rfrnr4r5r6r/rErWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr8)rfrgr4r5r6rrrrjnszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr:) r:r;r<r\r#r{r=rr>rkwrite) rfrgr4r5r6r?r@rAr?rBrCrrrrkrs* z BaseEventLoop._sendfile_fallbackrhc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS)Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rRrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r' reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| dd} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st d qڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk r|j||tj|||dIdH}|std|D]:\}}}}}||f}||krddg||<||||<qqfdd|D}|sHtdg}|tk rv|rftdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tjtjd| dr| |r| s| | |IdH|} Wn^tk rJ}z | dk r0| !|"|W5d}~XYn&| dk rb| !YnXq|qz|d |}|#}|$| || |}|j%r̈rt&d||nt'd||z|IdHWn|!YnX||fS)NzA UDP Socket was expected, got )rS remote_addrr=r?r'rprqrrr#css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrrXrYcs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrSrsrrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r) stacklevelrGz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%dictr$itemsrIr#rxrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorrb_unsetrrr r+r&r'Z SO_BROADCASTrJrOrr9rdrrr&r ) rfrrSrsr=r?r'rprqrrr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxrfZfamrPZprorrzrZ local_addressZremote_addressrWrrrnrr{rcreate_datagram_endpoints$                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nrr-)rAr%) rfrr=r>r?r'rr;r<r&rrrrbLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r'rz getaddrinfo(z) returned empty list)rbr$r1r()rfr;r<r=r'rfrrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r'r*rrRrprqrrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd|D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d d YqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)Nz*ssl argument must be an SSLContext or NonerVrWposixcygwinr.csg|]}j|dqS))r=r')r)rCr;r=r'r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedrarrz %r is serving).rrir5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrJr(rMrKrLr>r1rIrrrr&)rfrr;r<r=r'r*rrRrprqrrrZhostsZfsrfZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rRrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS)NrarVr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rdrrerr )rfrr*rRrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrr filenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrr rrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrr r$)rfr(rrrr&rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) 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) rr3rr%rrrrr&)rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr&)rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jSrB)rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)Nz+A callable object or None is expected, got )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrdt|}d }|| 7}n2|dkrdt|}d }|| 7}nt |}| |d |qnt j d ||d dS)Nrz!Unhandled exception in event looprRFZsource_tracebackZhandle_traceback>rrRr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rH r)getr> __traceback__rrsortedr$ traceback format_listrstriprr9rr) rfr rrRrZ log_linesrzvaluetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)Nz&Exception in default exception handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrnrr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs|jr dS|j|dSrB) _cancelledrr9rfrrrr _add_callbackszBaseEventLoop._add_callbackcCs|||dSrB)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dSrZ)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsb                  ;   Do__pycache__/unix_events.cpython-38.pyc000064400000114652152343727170013777 0ustar00U e5dۿ@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe jdkredddZGdddejZGdddej Z!Gdddej"ej#Z$Gdddej%Z&GdddZ'ddZ(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),z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr+/usr/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZdZd)fdd ZfddZddZd d Zd d Zd dZ ddZ d*ddZ d+ddZ d,ddZ ddZd-dddddddZd.dddddddd Zd!d"Zd#d$Zd%d&Zd'd(ZZS)/_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncst|i|_dSN)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fr5r6Nr3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |dkst|tst|r,|dkrLtdn |dk r.cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname____doc__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sH -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrxrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rxreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrxrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc CsRt|tttfstt|t|tr.t|}|s6dS|jsB|jrj|jtj krXt d|jd7_dS|j s8zt |j|}Wntttfk rd}YnZttfk rYnBtk r}z$|jd7_||dWYdSd}~XYnX|t|kr dS|dkr&t||d}|j|j|j|j |7_ |dS)Nz=pipe closed by peer or os.write(pipe, data) raised exception.rr#Fatal write error on pipe transport)rObytesr memoryviewrwreprrrrZ!LOG_THRESHOLD_FOR_CONNLOST_WRITESr warningrrxwriterrrrarbrcrrrZ _add_writer _write_readyZ_maybe_pause_protocol)rr1nrFrrrrs8      z_UnixWritePipeTransport.writec Cs|jstdzt|j|j}Wnttfk r:Ynttfk rRYnt k r}z6|j |j d7_ |j |j||dW5d}~XYnhX|t|jkr|j |j |j||jr|j |j|ddS|dkr |jd|=dS)NzData should not be emptyrrr)rrwrxrrrrrarbrcr-rr_remove_writerrrZ_maybe_resume_protocolrrr)rrrFrrrrs,    z$_UnixWritePipeTransport._write_readycCsdSrrrrrr can_write_eofsz%_UnixWritePipeTransport.can_write_eofcCsB|jr dS|jstd|_|js>|j|j|j|jddSr) rrrwrrrrrrrrrr write_eofs z!_UnixWritePipeTransport.write_eofcCs ||_dSrrrrrrrsz$_UnixWritePipeTransport.set_protocolcCs|jSrrrrrrrsz$_UnixWritePipeTransport.get_protocolcCs|jSrrrrrrrsz"_UnixWritePipeTransport.is_closingcCs|jdk r|js|dSr)rrr rrrrr%sz_UnixWritePipeTransport.closecCs,|jdk r(|d|t|d|jdSrrrrrrrs z_UnixWritePipeTransport.__del__cCs|ddSr)rrrrrabortsz_UnixWritePipeTransport.abortrcCsNt|tr(|jr@tjd||ddn|j||||jd||dSr) rOr=rrr rrrrrrrrrs  z$_UnixWritePipeTransport._fatal_errorcCsFd|_|jr|j|j|j|j|j|j|j|dSr) rrrr rr-rrrrrrrrs  z_UnixWritePipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrrrrrrs  z-_UnixWritePipeTransport._call_connection_lost)NN)r)N)rrrrrrrrrr r rrrr%r*r+rr rrrrrrr!rrY<s"% #   rYc@seZdZddZdS)r^c Ksd}|tjkrt\}}zPtj|f||||d|d||_|dk rh|t|d|d|j_ d}W5|dk r||XdS)NF)rdrerfrgZuniversal_newlinesrhwb) buffering) subprocessPIPErzZ socketpairr%Popen_procrdetachre) rrErdrerfrgrhriZstdin_wrrr_start s.  z_UnixSubprocessTransport._startN)rrrrrrrrr^ sr^c@sHeZdZdZddZddZddZdd Zd d Zd d Z ddZ dS)raHAbstract base class for monitoring child processes. Objects derived from this class monitor a collection of subprocesses and report their termination or interruption by a signal. New callbacks are registered with .add_child_handler(). Starting a new process must be done within a 'with' block to allow the watcher to suspend its activity until the new process if fully registered (this is needed to prevent a race condition in some implementations). Example: with watcher: proc = subprocess.Popen("sleep 1") watcher.add_child_handler(proc.pid, callback) Notes: Implementations of this class must be thread-safe. Since child watcher objects may catch the SIGCHLD signal and call waitpid(-1), there should be only one active object per process. cGs tdS)aRegister a new child handler. Arrange for callback(pid, returncode, *args) to be called when process 'pid' terminates. Specifying another callback for the same process replaces the previous handler. Note: callback() must be thread-safe. NNotImplementedErrorrrnrDrErrrr_9s z&AbstractChildWatcher.add_child_handlercCs tdS)zRemoves the handler for process 'pid'. The function returns True if the handler was successfully removed, False if there was nothing to remove.Nrrrnrrrremove_child_handlerDsz)AbstractChildWatcher.remove_child_handlercCs tdS)zAttach the watcher to an event loop. If the watcher was previously attached to an event loop, then it is first detached before attaching to the new loop. Note: loop may be None. Nrrrrrr attach_loopLsz AbstractChildWatcher.attach_loopcCs tdS)zlClose the watcher. This must be called to make sure that any underlying resource is freed. Nrrrrrr%VszAbstractChildWatcher.closecCs tdS)zReturn ``True`` if the watcher is active and is used by the event loop. Return True if the watcher is installed and ready to handle process exit notifications. Nrrrrrr\]szAbstractChildWatcher.is_activecCs tdS)zdEnter the watcher's context and allow starting new processes This function must return selfNrrrrr __enter__fszAbstractChildWatcher.__enter__cCs tdS)zExit the watcher's contextNrrabcrrr__exit__lszAbstractChildWatcher.__exit__N) rrrrr_rrr%r\rr!rrrrr"s   rcCs2t|rt| St|r*t|S|SdSr)rx WIFSIGNALEDWTERMSIG WIFEXITED WEXITSTATUS)statusrrr_compute_returncodeqs     r'c@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)BaseChildWatchercCsd|_i|_dSr)r _callbacksrrrrrszBaseChildWatcher.__init__cCs|ddSr)rrrrrr%szBaseChildWatcher.closecCs|jdk o|jSr)rZ is_runningrrrrr\szBaseChildWatcher.is_activecCs tdSrr)r expected_pidrrr _do_waitpidszBaseChildWatcher._do_waitpidcCs tdSrrrrrr_do_waitpid_allsz BaseChildWatcher._do_waitpid_allcCs~|dkst|tjst|jdk r<|dkr<|jrrr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r=r?rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r=r?r>r?r-r r)rrrr Zcollateral_victimsrrrr!s  zFastChildWatcher.__exit__c Gst|jstd|jFz|j|}Wn.tk rT||f|j|<YW5QRdSXW5QRX|||f|dS)NzMust use the context manager)r?rwr=r>r;rJr))rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr1r2rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr6z8Caught subprocess termination from unknown pid: %d -> %d)rxr8r9r:r'r=r)r;rJr?r>rrr rr)rrnr&rorDrErrrr,<s@    z FastChildWatcher._do_waitpid_all) rrrrrr%rr!r_rr,rrrr!rrs  rc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cCsi|_d|_dSr)r)_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r@rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r)r-r@r9 getsignalr.r/r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrr!szMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr)r+)rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr1r2rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..N)r(rIvaluesr)rthreadsrOrrrrJsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrrBrrrr!szThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rKrMrrrrP sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rIrQr"r,)rrrRrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErL) rrDr<ZThreadr+nextrHrIstart)rrnrDrErrOrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCs|dks tzt|d\}}Wn(tk rH|}d}td|Yn Xt|}|rhtd||| rtd||n|j |||f||j |dS)Nrr4r5r6rE) rwrxr8r:r rr'rrrFrmrIr;)rrr*rDrErnr&rorrrr+"s(  z ThreadedChildWatcher._do_waitpidN)rrrrrr\r%rJrr!r*r+rr_rrr+rrrrrs  rcsHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr=rXrrOr<current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprXrOr<rYrZrrr!rrr]Ms   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. N)rXr\rrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs4|dkst|tst|jdk r*|j||_dS)z$Set the watcher for child processes.N)rOrrwrXr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrr\r]r[r^rrrr!rrW=s   rW)2rrBrrGrxrr9rzrrr&r<r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr'r(rrrrZBaseDefaultEventLoopPolicyrWrrrrrrs`             NO5Ji}Y3__pycache__/exceptions.cpython-38.pyc000064400000004767152343727170013616 0ustar00U e5da@sldZdZGdddeZGdddeZGdddeZGdd d eZGd d d e Z Gd d d eZ dS)zasyncio exceptions.)CancelledErrorInvalidStateError TimeoutErrorIncompleteReadErrorLimitOverrunErrorSendfileNotAvailableErrorc@seZdZdZdS)rz!The Future or Task was cancelled.N__name__ __module__ __qualname____doc__r r */usr/lib64/python3.8/asyncio/exceptions.pyr src@seZdZdZdS)rz*The operation exceeded the given deadline.Nrr r r r r src@seZdZdZdS)rz+The operation is not allowed in this state.Nrr r r r rsrc@seZdZdZdS)rz~Sendfile syscall is not available. Raised if OS does not support sendfile syscall for given socket or file type. Nrr r r r rsrcs(eZdZdZfddZddZZS)rz Incomplete read error. Attributes: - partial: read bytes string before the end of stream was reached - expected: total number of expected bytes (or None if unknown) cs@|dkr dnt|}tt|d|d||_||_dS)NZ undefinedz bytes read on a total of z expected bytes)reprsuper__init__lenpartialexpected)selfrrZ r_expected __class__r r r$szIncompleteReadError.__init__cCst||j|jffSN)typerrrr r r __reduce__+szIncompleteReadError.__reduce__rr r r rr __classcell__r r rr rs rcs(eZdZdZfddZddZZS)rzReached the buffer limit while looking for a separator. Attributes: - consumed: total number of to be consumed bytes. cst|||_dSr)rrconsumed)rmessagerrr r r5s zLimitOverrunError.__init__cCst||jd|jffS)N)rargsrrr r r r9szLimitOverrunError.__reduce__rr r rr r/s rN) r __all__ BaseExceptionr Exceptionrr RuntimeErrorrEOFErrorrrr r r r s__pycache__/coroutines.cpython-38.opt-2.pyc000064400000014303152343727170014552 0ustar00U e5d]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr*/usr/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCs>||_||_ttd|_t|dd|_t|dd|_ dS)Nr__name__ __qualname__) genfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrrrrr__iter__7szCoroWrapper.__iter__cCs |jdSr*rsendr+rrr__next__:szCoroWrapper.__next__cCs |j|Sr*r-)rvaluerrrr.=szCoroWrapper.sendcCs|j|||Sr*)rthrow)rtyper0 tracebackrrrr1@szCoroWrapper.throwcCs |jSr*)rcloser+rrrr4CszCoroWrapper.closecCs|jjSr*)rgi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)rgi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr __await__RszCoroWrapper.__await__cCs|jjSr*)r gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr5r z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) rf_lastijoinr3 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr(msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rrr)r,r/r.r1r4propertyr5r6r7r8r9rBrrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)NzN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr*) rZisfutureinspectZ isgenerator isinstancerr8AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrPr rr)rrrrr)rMkwdswrQrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrGrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrUrrTrris"    rcCst|pt|ddtkS)Nr^)rGrrr^rPrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)NTdF)r2_iscoroutine_typecacherH_COROUTINE_TYPESlenadd)objrrrrs   rc sht|tfdd}dd}d}t|dr:|jr:|j}nt|drP|jrP|j}||}|sr||rn|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|jpd }d }r$|jdk r$t |js$t |j}|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rJ|j }|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr"z without __name__>z())rZ_format_callbackrhasattrrrr2)rQ coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrIr6)rQrrr is_runnings z%_format_coroutine..is_runningcr_coder7z runningr5cr_framezrz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl co_filenamerrGrYrZ_get_function_sourcef_linenoco_firstlineno) rQrhrjZ coro_coderfZ coro_framefilenamelinenosourcer'rrgrr%sJ         r%) __all__Zcollections.abcrJrZrGrr r3r\rVr:rrrlogr rr]rrobjectr^r CoroutineType GeneratorTyperK Coroutinerasetr`rr%rrrrs2    E8__pycache__/streams.cpython-38.opt-1.pyc000064400000047617152343727170014053 0ustar00U e5d h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS) aA wrapper for create_connection() returning a (reader, writer) pair. The reader returned is a StreamReader instance; the writer is a StreamWriter instance. The arguments are all the usual arguments to create_connection() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). (If you want to customize the StreamReader and/or StreamReaderProtocol classes, just copy the code -- there's really nothing special here except some convenience.) N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr'/usr/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)aStart a socket server, call back for each client connected. The first parameter, `client_connected_cb`, takes two parameters: client_reader, client_writer. client_reader is a StreamReader object, while client_writer is a StreamWriter object. This parameter can either be a plain callback function or a coroutine; if it is a coroutine, it will be automatically converted into a Task. The rest of the arguments are all the usual arguments to loop.create_server() except protocol_factory; most common are positional host and port, with various optional keyword arguments following. The return value is the same as loop.create_server(). Additional optional keyword arguments are loop (to set the event loop instance to use) and limit (to set the buffer limit passed to the StreamReader). The return value is the same as loop.create_server(), i.e. a Server object which can be used to stop the service. Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS) z@Similar to `open_connection` but works with UNIX Domain Sockets.NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)z=Similar to `start_server` but works with UNIX Domain Sockets.Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)FlowControlMixina)Reusable flow control logic for StreamWriter.drain(). This implements the protocol methods pause_writing(), resume_writing() and connection_lost(). If the subclass overrides these it must call the super methods. StreamWriter.drain() must wait for _drain_helper() coroutine. NcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs d|_|jrtd|dS)NTz%r pauses writing)r5r4 get_debugrdebugr8rrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jrtd||j}|dk rBd|_|sB|ddS)NFz%r resumes writing)r5r4r:rr;r6done set_resultr8waiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r>r? set_exceptionr8excrArrrconnection_losts z FlowControlMixin.connection_lostcs<|jrtd|jsdS|j}|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6r4 create_futurer@rrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname____doc__r9r=rBrGrJrNrrrrr2s   r2csfeZdZdZdZdfdd ZeddZddZfd d Z d d Z d dZ ddZ ddZ ZS)ra=Helper class to adapt between Protocol and StreamReader. (This is a helper class instead of making StreamReader itself a Protocol subclass, because the StreamReader has other potential uses, and to prevent the user of the StreamReader to accidentally call inappropriate methods of the protocol.) Ncsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rI_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rVr<rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)rYrWr4Zcall_exception_handlerabortr[ra set_transportget_extra_infor]r\rrZr Z iscoroutineZ create_taskrX)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) rafeed_eofrDr^r>r?rSrGrVrZr[)r8rFr'r_rrrG s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)ra feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)rarir])r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r^rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r^r> cancelled exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrRrWr9propertyrarhrGrlrmrNrq __classcell__rrr_rrs   rc@sveZdZdZddZddZeddZdd Zd d Z d d Z ddZ ddZ ddZ ddZdddZddZdS)ra'Wraps a Transport. This exposes write(), writelines(), [can_]write_eof(), get_extra_info() and close(). It adds drain() which returns an optional Future on which you can wait for flow control. It also adds a transport property which references the Transport directly. cCs4||_||_||_||_|j|_|jddSr)r[ _protocol_readerr4rIZ _complete_futr?)r8r(rr'rrrrr9@s  zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )r`rOr[ruappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSrr[r<rrrr(PszStreamWriter.transportcCs|j|dSr)r[writer8rkrrrrTszStreamWriter.writecCs|j|dSr)r[ writelinesrrrrrWszStreamWriter.writelinescCs |jSr)r[ write_eofr<rrrrZszStreamWriter.write_eofcCs |jSr)r[ can_write_eofr<rrrr]szStreamWriter.can_write_eofcCs |jSr)r[closer<rrrr`szStreamWriter.closecCs |jSr)r[ is_closingr<rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rtrNr<rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)r[re)r8namedefaultrrrreiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)zyFlush the write buffer. The intended use is to write w.write(data) await w.drain() Nr)ruror[rrrtrJ)r8rFrrrdrainls   zStreamWriter.drain)N)rOrPrQrRr9r~rrr(rrrrrrrrerrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionr[r5r:r extract_stacksys _getframerW)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=rvZpausedrwrx) rrylenrr_DEFAULT_LIMITrrr[r5rzr{r|rrrr~s    zStreamReader.__repr__cCs|jSr)rr<rrrroszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrnrDrErrrrDs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddS)z1Wakeup read*() functions waiting for data or EOF.N)rrnr?r@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dSrr)r8r(rrrrdszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrr[resume_readingr<rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrC)rrr<rrrriszStreamReader.feed_eofcCs|jo |j S)z=Return True if the buffer is empty and 'feed_eof' was called.)rrr<rrrat_eofszStreamReader.at_eofcCst|sdS|j|||jdk rp|jspt|jd|jkrpz|jWntk rhd|_YnXd|_dS)NrT) rextendrr[r5rrZ pause_readingrKrrrrrjs   zStreamReader.feed_datacsX|jdk rt|d|jr.d|_|j|j|_z|jIdHW5d|_XdS)zpWait until feed_data() or feed_eof() is called. If stream was paused, automatically resume it. NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr5r[rr4rI)r8Z func_namerrr_wait_for_datas   zStreamReader._wait_for_datac sd}t|}z||IdH}Wntjk rN}z|jWYSd}~XYnhtjk r}zH|j||jr|jd|j|=n |j | t |j dW5d}~XYnX|S)aRead chunk of data from the stream until newline (b' ') is found. On success, return chunk that ends with newline. If only partial line can be read due to EOF, return incomplete line without terminating newline. When EOF was reached while no bytes read, empty bytes object is returned. If limit is reached, ValueError will be raised. In that case, if newline was found, complete line including newline will be removed from internal buffer. Else, internal buffer will be cleared. Limit is compared against part of the line without newline. If stream was paused, this function will automatically resume it if needed.  Nr) r readuntilr IncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)r8sepseplenlineerrrreadline s  zStreamReader.readlinercst|}|dkrtd|jdk r(|jd}t|j}|||kr||j||}|dkrZq|d|}||jkr|td||jrt |j}|j t |d| dIdHq,||jkrtd||jd||}|jd||=| t |S) aVRead data from the stream until ``separator`` is found. On success, the data and separator will be removed from the internal buffer (consumed). Returned data will include the separator at the end. Configured stream limit is used to check result. Limit sets the maximal length of data that can be returned, not counting the separator. If an EOF occurs and the complete separator is still not found, an IncompleteReadError exception will be raised, and the internal buffer will be reset. The IncompleteReadError.partial attribute may contain the separator partially. If the data cannot be read because of over limit, a LimitOverrunError exception will be raised, and the data will be left in the internal buffer, so it can be read again. rz,Separator should be at least one-byte stringNr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrr rrbytesrrrr)r8Z separatorroffsetZbuflenZisepchunkrrrr(s>         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)aRead up to `n` bytes from the stream. If n is not provided, or set to -1, read until EOF and return all read bytes. If the EOF was received and the internal buffer is empty, return an empty bytes object. If n is zero, return empty bytes object immediately. If n is positive, this function try to read `n` bytes, and may return less or equal bytes than requested, but at least one byte. If EOF was received before any byte is read, this function returns empty byte object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. Nrrread) rrrryr{rrrrr)r8nZblocksblockrkrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)aRead exactly `n` bytes. Raise an IncompleteReadError if EOF is reached before `n` bytes can be read. The IncompleteReadError.partial attribute of the exception will contain the partial read bytes. if n is zero, return empty bytes object. Returned value is not limited with limit, configured at stream creation. If stream was paused, this function will automatically resume it if needed. rz*readexactly size can not be less than zeroNr readexactly) rrrrrrrr rrr)r8rZ incompleterkrrrrs&       zStreamReader.readexactlycCs|Srrr<rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rOrPrQrWrr9r~rorDrrdrrirrjrrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rThasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkP__pycache__/windows_events.cpython-38.pyc000064400000060011152343727170014473 0ustar00U e5di@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd ZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZ Gddde!Z"Gdddej#Z$Gdd d ej%Z&Gd!d"d"Z'Gd#d$d$e j(Z)e$Z*Gd%d&d&e j+Z,Gd'd(d(e j+Z-e-Z.dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rr%r6r0r9r; __classcell__r r rr!r+s   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrDZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrDrKrEr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rFrE _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rOrrHr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rUrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rUrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rUrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s   rCcsFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrcstj||||dd|_dS)Nr)rr_done_callback)rreventrHrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rWr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rWr:rr r!r9s  z_WaitCancelFuture.set_exception) r>r?r@rArr0r;r9rBr r rr!rVs  rVcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrQZ CreateEvent_event _event_fut)rrrGrHproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r\rJ CloseHandler]r[ _unregisterrrrOrMrr r!rOs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[ _wait_cancelrOr]rTr r r!rUs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZs rZc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|S)NF)rhrj)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlergadd)rfirstflagshpiper r r!rjs(     zPipeServer._server_pipe_handlecCs |jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rir0rdrgcloserhclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rArrlrjrmru__del__r r r r!rbs  rbc@seZdZdZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd fdd ZfddZddZd d Zdd d ZZ S)r z2Windows version of proactor event loop using IOCP.Ncs|dkrt}t|dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c sfz(|jdkst||jt W5|jdk r`|jj}|j|dk rZ|j|d|_XdSr7) Z_self_reading_futurerr0r[r`AssertionError call_soonZ_loop_self_readingr run_foreverrrrr r!r{8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)r[ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr}r~rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rgdiscardrmrurrlr[ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorriadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rbrz)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizerkwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rArr{rrrrBr r rr!r 0s 0r c@seZdZdZd;ddZddZddZd d ZdddZ d?ddZ d@ddZ dAddZddZddZdd Zd!d"Zd#d$ZdBd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2ZdCd3d4Zd5d6Zd7d8Zd9d:Zd S)Drz#Proactor implementation using IOCP.rcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrI) r2_resultsrQCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cachererfrF _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrYr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrLrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrK)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerNr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprQ Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrQrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrQrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrQrrnZ WSASendTorr)rrrrrr}rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrQrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrQrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrI)rrrrrQZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrQZ WSAConnectrr2rr;rZ BindLocalrr1rRerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rNerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrQrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrQrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrQZ ConnectPiper1rRZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrGr4r r r!rs  zIocpProactor.connect_pipecCs|||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rrGrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Src)rrW)rrXZ done_callbackrNr r r!raszIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rKrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrJINFINITEmathceilrQrrnZRegisterWaitWithQueuerr'rVr2rZrr)rrGrZ _is_cancelmsrrHrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrI)rFrprQrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrrLr|r r r!r`szIocpProactor._unregistercCst|}|d|SrI)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrQZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrJr_rr0Zdoner1r9rrLr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rKsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrVr0r1r2rr3time monotonicr debugrKrrJr_) rr'rNrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArrrrrrrrrrrrrrrrrrarrrr`rrKrrurwr r r r!rs8        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2r[rintrDr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr)/rArQrJrrrrrrrerrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrCrVrZobjectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sR         0J4;e`__pycache__/tasks.cpython-38.opt-2.pyc000064400000040401152343727170013503 0ustar00U e5d@srdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZedjZdAd d ZdBd d ZdCddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejjZejj Z ejj!Z!dde!dddZ"ddZ#ddddZ$dd Z%d!d"Z&ddd#d$d%Z'ej(d&d'Z)dDddd(d)Z*ddd*d+Z+ej(d,d-Z,ee,_Gd.d/d/ej-Z.dd0d1d2d3Z/ddd4d5Z0d6d7Z1e 2Z3iZ4d8d9Z5d:d;Z6dd?Z8e5Z9e8Z:e6Z;e7Ze6Z?e7Z@dS)E)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|SN)rget_running_loop_current_tasksgetloopr"%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrcs&h|]}t|kr|s|qSr")r _get_loopdone.0tr r"r# <szall_tasks..)rrlist _all_tasks RuntimeErrorr!iZtasksr"r r#r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr$csh|]}t|kr|qSr")rr%r'r r"r#r*Usz$_all_tasks_compat..)rget_event_loopr+r,r-r.r"r r#_all_tasks_compat@s r1cCs4|dk r0z |j}Wntk r&Yn X||dSr)set_nameAttributeError)tasknamer2r"r"r#_set_task_nameXs  r6cseZdZdZed$ddZed%ddZdddfdd Zfd d Zd d Z ddZ ddZ ddZ ddZ ddZddddZdddddZddZd&fd d! Zd"d#ZZS)'rTNcCs(tjdtdd|dkr t}t|S)NzVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevel)warningswarnDeprecationWarningrr0rclsr!r"r"r#rtszTask.current_taskcCstjdtddt|S)NzPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r1r=r"r"r#rs zTask.all_tasks)r!r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)Nr Fza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror!r5 __class__r"r#rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr"r#rXs  z Task.__del__cCs t|Sr)rZ_task_repr_inforSr"r"r# _repr_infoszTask._repr_infocCs|jSr)rMrYr"r"r#get_corosz Task.get_corocCs|jSr)rIrYr"r"r#get_namesz Task.get_namecCst||_dSr)rJrI)rSvaluer"r"r#r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr-)rSresultr"r"r# set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr"r"r# set_exceptionszTask.set_exception)limitcCs t||Sr)rZ_task_get_stack)rSrcr"r"r# get_stackszTask.get_stack)rcfilecCst|||Sr)rZ_task_print_stack)rSrcrer"r"r# print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dSNFT)Z_log_tracebackr&rLcancelrKrYr"r"r#rhs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r&rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrhr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr%r-rQrRrOriadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr"r#Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr)r_rqrR)rSfuturervr"r"r#Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrhrRrt __classcell__r"r"rUr#rbs$    !Tr)r5cCs t}||}t|||Sr)rrrr6)rTr5r!r4r"r"r#rxs  r)r!timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfddt|D}t|||IdHS) Nzexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: [The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSr r r(fr r"r#r*szwait..)risfuturerrErGtypery ValueErrorrrrrrr:r;r<set_wait)fsr!r~rr"r r#rs rcGs|s|ddSr)r&r`)waiterargsr"r"r#_release_waitersrr c s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)Nrr7r8rr )rrr:r;r<r r&r__cancel_and_waitrrk TimeoutError create_future call_laterr functoolspartialrsrhremove_done_callback)futr~r!rvrtimeout_handlecbr"r"r#rsL              rc s|d|dk r"||tt|fdd}|D]}||q@zIdHW5dk rp|D]}||qtXtt}}|D]"}|r| |q| |q||fS)NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrarhr&r`rZcounterrrrr"r#_on_completions z_wait.._on_completion) rrrlenrsrhrrr&add)rr~rr!rrr&Zpendingr"rr#rs(    rc sF|}tt|}||z||IdHW5||XdSr)rrrrrsrrh)rr!rrr"r"r#r&s  r)r!r~c#st|st|r(tdt|jddlm}|ddkrPt nt j dt ddfdd t|Ddfd d }fd d fdd}D]}|qr|dk r҈||ttD] }|VqdS)Nz#expect an iterable of futures, not r)Queuer rr7r8csh|]}t|dqSrrrr r"r#r*Uszas_completed..cs*D]}|dqdSr)r put_nowaitclearr)rr&todor"r# _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr)removerrhr)r&rrr"r#r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr)rrrr_r)r&r"r# _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrryZqueuesrrr0r:r;r<rrsrranger)rr!r~rrrr_r")rr&r!rrr#r7s*       rccs dVdSrr"r"r"r"r#__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)Nrrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrh)Zdelayr_r!rxhr"r"r#r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)Nr?zRThe future belongs to a different loop than the one specified as the loop argumentr z:An asyncio.Future, a coroutine or an awaitable is required)rrErr0rrDrrr%rruZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer!r4r"r"r#r s    r ccs|EdHSr) __await__)Z awaitabler"r"r#rsrcs*eZdZddfdd ZddZZS)_GatheringFutureNr cstj|d||_d|_dS)Nr F)rBrC _children_cancel_requested)rSchildrenr!rUr"r#rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|Srg)r&rrhr)rSZretZchildr"r"r#rhs z_GatheringFuture.cancel)ryrzr{rCrhr}r"r"rUr#rsrF)r!return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd|_ d 7|||<| |n||} |qdt |dS) Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r&rrarrkrbr_appendrr`)rrvZresultsresrZ nfinishedZnfutsouterrr"r#_done_callbacks4    zgather.._done_callbackrr Fr)rr0r:r;r<rr`r rr%rFrsrr)r!rZcoros_or_futuresrZ arg_to_futargrr"rr#r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd}|S) Nrr7r8r cs\r|s|dS|r.n*|}|dk rJ|n|dSr)rrarhrbr`r_)innerrvrr"r#_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr)r&rr)rrr"r#_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r&rr%rrs)rr!rr")rrrr#r Ps     r cs:tstdtjfdd}|S)NzA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr )rZ _chain_futurer rprorqZset_running_or_notify_cancelrb)rvrTrxr!r"r#callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr!rr"rr#r s    r cCst|dSr)r,rr4r"r"r#rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr-r!r4rr"r"r#rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr"r"r#rs rcCst|dSr)r,discardrr"r"r#rsr)rrrrr,r)N)N)N)N)A__all__Zconcurrent.futuresrrNrru itertoolstypesr:weakrefrrrrrrcount__next__rHrrr1r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr,rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr"r"r"r#s                #H,>  x?$__pycache__/trsock.cpython-38.opt-1.pyc000064400000020445152343727170013670 0ustar00U e5d@s"ddlZddlZGdddZdS)Nc@seZdZdZdZejdddZddZedd Z ed d Z ed d Z ddZ ddZ ddZddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Zd6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dBdCZ&dDdEZ'dFdGZ(dHdIZ)dJdKZ*dLdMZ+dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dXdYZ1dZd[Z2d\S)]TransportSocketzA socket-like wrapper for exposing real transport sockets. These objects can be safely returned by APIs like `transport.get_extra_info('socket')`. All potentially disruptive operations (like "socket.close()") are banned. _sock)sockcCs ||_dSNr)selfrr&/usr/lib64/python3.8/asyncio/trsock.py__init__szTransportSocket.__init__cCstjd|dt|ddS)NzUsing z on sockets returned from get_extra_info('socket') will be prohibited in asyncio 3.9. Please report your use case to bugs.python.org.)source)warningswarnDeprecationWarning)rZwhatrrr _nas  zTransportSocket._nacCs|jjSr)rfamilyrrrr rszTransportSocket.familycCs|jjSr)rtyperrrr rszTransportSocket.typecCs|jjSr)rprotorrrr r"szTransportSocket.protocCsd|d|jd|jd|j}|dkrz|}|rN|d|}Wntjk rfYnXz|}|r|d|}Wntjk rYnX|dS) Nz)filenorrr getsocknamesocketerror getpeername)rsZladdrZraddrrrr __repr__&s $ zTransportSocket.__repr__cCs tddS)Nz/Cannot serialize asyncio.TransportSocket object) TypeErrorrrrr __getstate__=szTransportSocket.__getstate__cCs |jSr)rrrrrr r@szTransportSocket.filenocCs |jSr)rduprrrr rCszTransportSocket.dupcCs |jSr)rget_inheritablerrrr r FszTransportSocket.get_inheritablecCs|j|dSr)rshutdown)rZhowrrr r!IszTransportSocket.shutdowncOs|jj||Sr)r getsockoptrargskwargsrrr r"NszTransportSocket.getsockoptcOs|jj||dSr)r setsockoptr#rrr r&QszTransportSocket.setsockoptcCs |jSr)rrrrrr rTszTransportSocket.getpeernamecCs |jSr)rrrrrr rWszTransportSocket.getsocknamecCs |jSr)r getsockbynamerrrr r'ZszTransportSocket.getsockbynamecCs|d|jS)Nzaccept() method)rracceptrrrr r(]s zTransportSocket.acceptcOs|d|jj||S)Nzconnect() method)rrconnectr#rrr r)as zTransportSocket.connectcOs|d|jj||S)Nzconnect_ex() method)rr connect_exr#rrr r*es zTransportSocket.connect_excOs|d|jj||S)Nz bind() method)rrbindr#rrr r+is zTransportSocket.bindcOs|d|jj||S)Nzioctl() method)rrioctlr#rrr r,ms zTransportSocket.ioctlcOs|d|jj||S)Nzlisten() method)rrlistenr#rrr r-qs zTransportSocket.listencCs|d|jS)Nzmakefile() method)rrmakefilerrrr r.us zTransportSocket.makefilecOs|d|jj||S)Nzsendfile() method)rrsendfiler#rrr r/ys zTransportSocket.sendfilecCs|d|jS)Nzclose() method)rrcloserrrr r0}s zTransportSocket.closecCs|d|jS)Nzdetach() method)rrdetachrrrr r1s zTransportSocket.detachcOs|d|jj||S)Nzsendmsg_afalg() method)rr sendmsg_afalgr#rrr r2s zTransportSocket.sendmsg_afalgcOs|d|jj||S)Nzsendmsg() method)rrsendmsgr#rrr r3s zTransportSocket.sendmsgcOs|d|jj||S)Nzsendto() method)rrsendtor#rrr r4s zTransportSocket.sendtocOs|d|jj||S)Nz send() method)rrsendr#rrr r5s zTransportSocket.sendcOs|d|jj||S)Nzsendall() method)rrsendallr#rrr r6s zTransportSocket.sendallcOs|d|jj||S)Nzset_inheritable() method)rrset_inheritabler#rrr r7s zTransportSocket.set_inheritablecCs|d|j|S)Nzshare() method)rrshare)rZ process_idrrr r8s zTransportSocket.sharecOs|d|jj||S)Nzrecv_into() method)rr recv_intor#rrr r9s zTransportSocket.recv_intocOs|d|jj||S)Nzrecvfrom_into() method)rr recvfrom_intor#rrr r:s zTransportSocket.recvfrom_intocOs|d|jj||S)Nzrecvmsg_into() method)rr recvmsg_intor#rrr r;s zTransportSocket.recvmsg_intocOs|d|jj||S)Nzrecvmsg() method)rrrecvmsgr#rrr r<s zTransportSocket.recvmsgcOs|d|jj||S)Nzrecvfrom() method)rrrecvfromr#rrr r=s zTransportSocket.recvfromcOs|d|jj||S)Nz recv() method)rrrecvr#rrr r>s zTransportSocket.recvcCs|dkr dStddS)NrzrBrCrErGrHrrrr rsb   r)rr rrrrr s__pycache__/coroutines.cpython-38.opt-1.pyc000064400000014653152343727170014561 0ustar00U e5d]"@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr*/usr/lib64/python3.8/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCs>||_||_ttd|_t|dd|_t|dd|_ dS)Nr__name__ __qualname__) genfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr4|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cCs|SNrrrrr__iter__7szCoroWrapper.__iter__cCs |jdSr*rsendr+rrr__next__:szCoroWrapper.__next__cCs |j|Sr*r-)rvaluerrrr.=szCoroWrapper.sendcCs|j|||Sr*)rthrow)rtyper0 tracebackrrrr1@szCoroWrapper.throwcCs |jSr*)rcloser+rrrr4CszCoroWrapper.closecCs|jjSr*)rgi_framer+rrrr5FszCoroWrapper.gi_framecCs|jjSr*)r gi_runningr+rrrr6JszCoroWrapper.gi_runningcCs|jjSr*)rgi_coder+rrrr7NszCoroWrapper.gi_codecCs|Sr*rr+rrr __await__RszCoroWrapper.__await__cCs|jjSr*)r gi_yieldfromr+rrrr9UszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr5r z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) rf_lastijoinr3 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr(msgtbrrr__del__Ys     zCoroWrapper.__del__)N)NN)r __module__rrr)r,r/r.r1r4propertyr5r6r7r8r9rBrrrrr$s"      rcsztjdtddtrStr.ntfddt t sX}ntfdd}t |_ |S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. zN"@coroutine" decorator is deprecated since Python 3.8, use "async def" instead) stacklevelc?sr||}t|s(t|s(t|tr4|EdH}n:z |j}Wntk rRYnXt|tj j rn|EdH}|Sr*) rZisfutureinspectZ isgenerator isinstancerr8AttributeError collectionsabc Awaitable)argskwresZ await_methrrrcorozs    zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)NrPr rr)rrrrr)rMkwdswrQrrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrGrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrUrrTrris"    rcCst|pt|ddtkS)z6Return True if func is a decorated coroutine function.r^N)rGrrr^rPrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)z)Return True if obj is a coroutine object.TdFN)r2_iscoroutine_typecacherH_COROUTINE_TYPESlenadd)objrrrrs   rc sht|tfdd}dd}d}t|dr:|jr:|j}nt|drP|jrP|j}||}|sr||rn|dS|Sd}t|dr|jr|j}nt|d r|jr|j}|jpd }d }r$|jdk r$t |js$t |j}|dk r|\}}|dkr|d |d |} n|d|d |} n@|dk rJ|j }|d|d |} n|j}|d |d |} | S)Ncs`rt|jdiSt|dr,|jr,|j}n*t|drD|jrD|j}ndt|jd}|dS)Nrrrr"z without __name__>z())rZ_format_callbackrhasattrrrr2)rQ coro_nameZis_corowrapperrrget_namesz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF) cr_runningrIr6)rQrrr is_runnings z%_format_coroutine..is_runningcr_coder7z runningr5cr_framezrz done, defined at r!z running, defined at z running at )rHrrerkr7r5rl co_filenamerrGrYrZ_get_function_sourcef_linenoco_firstlineno) rQrhrjZ coro_coderfZ coro_framefilenamelinenosourcer'rrgrr%sJ         r%) __all__Zcollections.abcrJrZrGrr r3r\rVr:rrrlogr rr]rrobjectr^r CoroutineType GeneratorTyperK Coroutinerasetr`rr%rrrrs2    E8__pycache__/windows_utils.cpython-38.opt-1.pyc000064400000010445152343727170015274 0ustar00U e5d@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname____doc__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc sxd}}}d} } } |tkr@tddd\} } t| tj}n|}|tkrhtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz tj |f|||d|Wn0| | | fD]}|dk rt |qւYn>X| dk r t | |_ | dk rt | |_| dk r2t | |_W5|tkrJt||tkr^t||tkrrt|XdS)N)FTT)rr)TFr r)stdinstdoutstderr)rrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr7r8r9)rargsr7r8r9kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsN              zPopen.__init__)NNN)r#r1r2r3r __classcell__rrrArr}sr)r3sysplatform ImportErrorr itertoolsr:r subprocessr r5__all__ZBUFSIZErr<countrrrrrrrrs$ 1,__pycache__/windows_utils.cpython-38.pyc000064400000010571152343727170014335 0ustar00U e5d@sdZddlZejdkredddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZeZdde d d d ZGd d d ZGdddejZdS)z)Various Windows specific bits and pieces.NZwin32z win32 only)pipePopenPIPE PipeHandlei F)TT)duplex overlappedbufsizec Cs$tjdtttd}|r>tj}tj tj B}||}}ntj }tj }d|}}|tj O}|drp|tj O}|drtj }nd}d} } z\t||tjd||tjtj} t||dtjtj|tj} tj| dd} | d| | fWS| dk rt| | dk rt| YnXdS)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)prefixrNTr)tempfileZmktempformatosgetpidnext _mmap_counter_winapiZPIPE_ACCESS_DUPLEXZ GENERIC_READZ GENERIC_WRITEZPIPE_ACCESS_INBOUNDZFILE_FLAG_FIRST_PIPE_INSTANCEZFILE_FLAG_OVERLAPPEDZCreateNamedPipeZ PIPE_WAITZNMPWAIT_WAIT_FOREVERZNULLZ CreateFileZ OPEN_EXISTINGZConnectNamedPipeZGetOverlappedResult CloseHandle) rrrZaddressZopenmodeaccessZobsizeZibsizeZflags_and_attribsZh1Zh2Zovr-/usr/lib64/python3.8/asyncio/windows_utils.pyr sb           rc@sbeZdZdZddZddZeddZdd Ze j d d d Z e j fd dZddZddZdS)rzWrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. cCs ||_dSN_handleselfhandlerrr__init__VszPipeHandle.__init__cCs2|jdk rd|j}nd}d|jjd|dS)Nzhandle=closed< >)r __class____name__rrrr__repr__Ys zPipeHandle.__repr__cCs|jSrrrrrrr`szPipeHandle.handlecCs|jdkrtd|jS)NzI/O operation on closed pipe)r ValueErrorr%rrrfilenods zPipeHandle.fileno)rcCs|jdk r||jd|_dSrr)rrrrrcloseis  zPipeHandle.closecCs*|jdk r&|d|t|d|dS)Nz unclosed )source)rResourceWarningr()rZ_warnrrr__del__ns zPipeHandle.__del__cCs|Srrr%rrr __enter__sszPipeHandle.__enter__cCs |dSr)r()rtvtbrrr__exit__vszPipeHandle.__exit__N)r# __module__ __qualname____doc__rr$propertyrr'rrr(warningswarnr+r,r0rrrrrQs rcs"eZdZdZdfdd ZZS)rzReplacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc s|drt|dddks"td}}}d} } } |tkrbtddd\} } t| tj}n|}|tkrtdd\} } t| d}n|}|tkrtdd\} }t|d}n|tkr|}n|}zz t j |f|||d |Wn0| | | fD]}|dk rt |qYn>X| dk r,t| |_| dk r@t| |_| dk rTt| |_W5|tkrlt ||tkrt ||tkrt |XdS) NZuniversal_newlinesrr)FTT)rr)TFr )stdinstdoutstderr)getAssertionErrorrrmsvcrtZopen_osfhandlerO_RDONLYSTDOUTr(superrrrrr7r8r9)rargsr7r8r9kwdsZ stdin_rfdZ stdout_wfdZ stderr_wfdZstdin_whZ stdout_rhZ stderr_rhZstdin_rhZ stdout_whZ stderr_whhr"rrrsR              zPopen.__init__)NNN)r#r1r2r3r __classcell__rrrCrr}sr)r3sysplatform ImportErrorr itertoolsr<r subprocessr r5__all__ZBUFSIZErr>countrrrrrrrrs$ 1,__pycache__/streams.cpython-38.opt-2.pyc000064400000034211152343727170014036 0ustar00U e5d h@s&dZddlZddlZddlZddlZeedr6ed7ZddlmZddlmZddlm Z dd lm Z dd lm Z dd l m Z dd lmZd ZddedddZd dedddZeedrd!dedddZd"dedddZGddde jZGdddee jZGdddZGdddZdS)#) StreamReader StreamWriterStreamReaderProtocolopen_connection start_serverNZAF_UNIX)open_unix_connectionstart_unix_server) coroutines)events) exceptions)format_helpers) protocols)logger)sleepi)looplimitc st|dkrt}ntjdtddt||d}t||d|jfdd||f|IdH\}}t|||}||fS)N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10. stacklevelrrrcsSNrprotocolr'/usr/lib64/python3.8/asyncio/streams.py5z!open_connection..) r get_event_loopwarningswarnDeprecationWarningrrZcreate_connectionr) hostportrrkwdsreader transport_writerrrrrs"    rcsJdkrtntjdtddfdd}j|||f|IdHS)Nrrrcstd}t|d}|SNrrrrr'rclient_connected_cbrrrrfactoryXs  zstart_server..factory)r r r!r"r#Z create_server)r/r$r%rrr&r0rr.rr:s rcsr|dkrt}ntjdtddt||d}t||d|jfdd|f|IdH\}}t|||}||fS)NrrrrrcsSrrrrrrrprz&open_unix_connection..) r r r!r"r#rrZcreate_unix_connectionr)pathrrr&r'r(r)r*rrrrds     rcsHdkrtntjdtddfdd}j||f|IdHS)Nrrrcstd}t|d}|Sr+r,r-r.rrr0~s  z"start_unix_server..factory)r r r!r"r#Zcreate_unix_server)r/r1rrr&r0rr.rrts rc@s>eZdZdddZddZddZdd Zd d Zd d ZdS)FlowControlMixinNcCs0|dkrt|_n||_d|_d|_d|_dSNF)r r _loop_paused _drain_waiter_connection_lost)selfrrrr__init__s  zFlowControlMixin.__init__cCs d|_|jrtd|dS)NTz%r pauses writing)r5r4 get_debugrdebugr8rrr pause_writings zFlowControlMixin.pause_writingcCsFd|_|jrtd||j}|dk rBd|_|sB|ddS)NFz%r resumes writing)r5r4r:rr;r6done set_resultr8waiterrrrresume_writings  zFlowControlMixin.resume_writingcCsVd|_|jsdS|j}|dkr"dSd|_|r4dS|dkrH|dn ||dSNT)r7r5r6r>r? set_exceptionr8excrArrrconnection_losts z FlowControlMixin.connection_lostcs<|jrtd|jsdS|j}|j}||_|IdHdS)NzConnection lost)r7ConnectionResetErrorr5r6r4 create_futurer@rrr _drain_helpers zFlowControlMixin._drain_helpercCstdSr)NotImplementedErrorr8streamrrr_get_close_waitersz"FlowControlMixin._get_close_waiter)N) __name__ __module__ __qualname__r9r=rBrGrJrNrrrrr2s    r2csbeZdZdZdfdd ZeddZddZfdd Zd d Z d d Z ddZ ddZ Z S)rNcsntj|d|dk r,t||_|j|_nd|_|dk r@||_d|_d|_d|_ ||_ d|_ |j |_dS)NrF)superr9weakrefref_stream_reader_wr_source_traceback_strong_reader_reject_connection_stream_writer _transport_client_connected_cb _over_sslr4rI_closed)r8Z stream_readerr/r __class__rrr9s  zStreamReaderProtocol.__init__cCs|jdkrdS|Sr)rUr<rrr_stream_readers z#StreamReaderProtocol._stream_readercCs|jr6ddi}|jr|j|d<|j||dS||_|j}|dk rT|||ddk |_ |j dk rt ||||j|_ | ||j }t |r|j|d|_dS)NmessagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)rXrVr4Zcall_exception_handlerabortrZr` set_transportget_extra_infor\r[rrYr Z iscoroutineZ create_taskrW)r8r(contextr'resrrrconnection_mades2      z$StreamReaderProtocol.connection_madecsx|j}|dk r*|dkr |n |||jsV|dkrJ|jdn |j|t|d|_d|_ d|_ dSr) r`feed_eofrDr]r>r?rRrGrUrYrZ)r8rFr'r^rrrG s     z$StreamReaderProtocol.connection_lostcCs|j}|dk r||dSr)r` feed_data)r8datar'rrr data_receivedsz"StreamReaderProtocol.data_receivedcCs$|j}|dk r||jr dSdS)NFT)r`rhr\)r8r'rrr eof_received s z!StreamReaderProtocol.eof_receivedcCs|jSr)r]rLrrrrN+sz&StreamReaderProtocol._get_close_waitercCs"|j}|r|s|dSr)r]r> cancelled exception)r8closedrrr__del__.szStreamReaderProtocol.__del__)NN)rOrPrQrVr9propertyr`rgrGrkrlrNrp __classcell__rrr^rrs    rc@sreZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZddZdS)rcCs4||_||_||_||_|j|_|jddSr)rZ _protocol_readerr4rIZ _complete_futr?)r8r(rr'rrrrr9@s  zStreamWriter.__init__cCs@|jjd|jg}|jdk r0|d|jdd|S)N transport=zreader=<{}> )r_rOrZrtappendformatjoinr8inforrr__repr__Js zStreamWriter.__repr__cCs|jSrrZr<rrrr(PszStreamWriter.transportcCs|j|dSr)rZwriter8rjrrrrTszStreamWriter.writecCs|j|dSr)rZ writelinesrrrrrWszStreamWriter.writelinescCs |jSr)rZ write_eofr<rrrrZszStreamWriter.write_eofcCs |jSr)rZ can_write_eofr<rrrr]szStreamWriter.can_write_eofcCs |jSr)rZcloser<rrrr`szStreamWriter.closecCs |jSr)rZ is_closingr<rrrrcszStreamWriter.is_closingcs|j|IdHdSr)rsrNr<rrr wait_closedfszStreamWriter.wait_closedNcCs|j||Sr)rZrd)r8namedefaultrrrrdiszStreamWriter.get_extra_infocsL|jdk r |j}|dk r ||jr8tdIdH|jIdHdS)Nr)rtrnrZrrrsrJ)r8rFrrrdrainls   zStreamWriter.drain)N)rOrPrQr9r}rqr(rrrrrrrrdrrrrrr6s    rc@seZdZdZedfddZddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZd&ddZd'ddZd d!Zd"d#Zd$d%ZdS)(rNcCsv|dkrtd||_|dkr*t|_n||_t|_d|_d|_d|_ d|_ d|_ |j rrt td|_dS)NrzLimit cannot be <= 0Fr ) ValueError_limitr r r4 bytearray_buffer_eof_waiter _exceptionrZr5r:r extract_stacksys _getframerV)r8rrrrrr9s   zStreamReader.__init__cCsdg}|jr"|t|jd|jr2|d|jtkrN|d|j|jrf|d|j|jr~|d|j|jr|d|j|j r|dd d |S) Nrz byteseofzlimit=zwaiter=z exception=ruZpausedrvrw) rrxlenrr_DEFAULT_LIMITrrrZr5ryrzr{rrrr}s    zStreamReader.__repr__cCs|jSr)rr<rrrrnszStreamReader.exceptioncCs0||_|j}|dk r,d|_|s,||dSr)rrrmrDrErrrrDs zStreamReader.set_exceptioncCs*|j}|dk r&d|_|s&|ddSr)rrmr?r@rrr_wakeup_waiters zStreamReader._wakeup_waitercCs ||_dSrr~)r8r(rrrrcszStreamReader.set_transportcCs*|jr&t|j|jkr&d|_|jdSr3)r5rrrrZresume_readingr<rrr_maybe_resume_transportsz$StreamReader._maybe_resume_transportcCsd|_|dSrC)rrr<rrrrhszStreamReader.feed_eofcCs|jo |j Sr)rrr<rrrat_eofszStreamReader.at_eofcCst|sdS|j|||jdk rp|jspt|jd|jkrpz|jWntk rhd|_YnXd|_dS)NrT) rextendrrZr5rrZ pause_readingrKrrrrris   zStreamReader.feed_datacsX|jdk rt|d|jr.d|_|j|j|_z|jIdHW5d|_XdS)NzF() called while another coroutine is already waiting for incoming dataF)r RuntimeErrorr5rZrr4rI)r8Z func_namerrr_wait_for_datas   zStreamReader._wait_for_datac sd}t|}z||IdH}Wntjk rN}z|jWYSd}~XYnhtjk r}zH|j||jr|jd|j|=n |j | t |j dW5d}~XYnX|S)N r) r readuntilr IncompleteReadErrorpartialLimitOverrunErrorr startswithconsumedclearrrargs)r8sepseplenlineerrrreadline s  zStreamReader.readlinercst|}|dkrtd|jdk r(|jd}t|j}|||kr||j||}|dkrZq|d|}||jkr|td||jrt |j}|j t |d| dIdHq,||jkrtd||jd||}|jd||=| t |S)Nrz,Separator should be at least one-byte stringr z2Separator is not found, and chunk exceed the limitrz2Separator is found, but chunk is longer than limit)rrrrfindrr rrbytesrrrr)r8Z separatorroffsetZbuflenZisepchunkrrrr(s>         zStreamReader.readuntilrcs|jdk r|j|dkrdS|dkrVg}||jIdH}|s@qL||q(d|S|jsr|jsr|dIdHt|jd|}|jd|=| |S)Nrrread) rrrrxrzrrrrr)r8nZblocksblockrjrrrrs"     zStreamReader.readcs|dkrtd|jdk r |j|dkr,dSt|j|krr|jr`t|j}|jt||| dIdHq,t|j|krt|j}|jnt|jd|}|jd|=| |S)Nrz*readexactly size can not be less than zeror readexactly) rrrrrrrr rrr)r8rZ incompleterjrrrrs&       zStreamReader.readexactlycCs|Srrr<rrr __aiter__szStreamReader.__aiter__cs|IdH}|dkrt|S)Nr)rStopAsyncIteration)r8valrrr __anext__szStreamReader.__anext__)r)r)rOrPrQrVrr9r}rnrDrrcrrhrrirrrrrrrrrrrrs$  [ 2)r)NN)NN)N)N)__all__Zsocketrr!rShasattrr r r r rlogrZtasksrrrrrrZProtocolr2rrrrrrrsF         ! '   DkP__pycache__/protocols.cpython-38.pyc000064400000020650152343727170013446 0ustar00U e5d@sbdZdZGdddZGdddeZGdddeZGdd d eZGd d d eZd d ZdS)zAbstract Protocol base classes.) BaseProtocolProtocolDatagramProtocolSubprocessProtocolBufferedProtocolc@s4eZdZdZdZddZddZddZd d Zd S) ra Common base class for protocol interfaces. Usually user implements protocols that derived from BaseProtocol like Protocol or ProcessProtocol. The only case when BaseProtocol should be implemented directly is write-only transport like write pipe cCsdS)zCalled when a connection is made. The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called. Nr)selfZ transportrr)/usr/lib64/python3.8/asyncio/protocols.pyconnection_madeszBaseProtocol.connection_madecCsdS)zCalled when the connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). Nrrexcrrrconnection_lostszBaseProtocol.connection_lostcCsdS)aCalled when the transport's buffer goes over the high-water mark. Pause and resume calls are paired -- pause_writing() is called once when the buffer goes strictly over the high-water mark (even if subsequent writes increases the buffer size even more), and eventually resume_writing() is called once when the buffer size reaches the low-water mark. Note that if the buffer size equals the high-water mark, pause_writing() is not called -- it must go strictly over. Conversely, resume_writing() is called when the buffer size is equal or lower than the low-water mark. These end conditions are important to ensure that things go as expected when either mark is zero. NOTE: This is the only Protocol callback that is not called through EventLoop.call_soon() -- if it were, it would have no effect when it's most needed (when the app keeps writing without yielding until pause_writing() is called). Nrrrrr pause_writing%szBaseProtocol.pause_writingcCsdS)zvCalled when the transport's buffer drains below the low-water mark. See pause_writing() for details. Nrr rrrresume_writing;szBaseProtocol.resume_writingN) __name__ __module__ __qualname____doc__ __slots__r r rrrrrrr s  rc@s$eZdZdZdZddZddZdS)ranInterface for stream protocol. The user should implement this interface. They can inherit from this class but don't need to. The implementations here do nothing (they don't raise exceptions). When the user wants to requests a transport, they pass a protocol factory to a utility function (e.g., EventLoop.create_connection()). When the connection is made successfully, connection_made() is called with a suitable transport object. Then data_received() will be called 0 or more times with data (bytes) received from the transport; finally, connection_lost() will be called exactly once with either an exception object or None as an argument. State machine of calls: start -> CM [-> DR*] [-> ER?] -> CL -> end * CM: connection_made() * DR: data_received() * ER: eof_received() * CL: connection_lost() rcCsdS)zTCalled when some data is received. The argument is a bytes object. Nr)rdatarrr data_received^szProtocol.data_receivedcCsdSzCalled when the other end calls write_eof() or equivalent. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. Nrr rrr eof_receiveddszProtocol.eof_receivedN)rrrrrrrrrrrrBsrc@s,eZdZdZdZddZddZddZd S) raInterface for stream protocol with manual buffer control. Important: this has been added to asyncio in Python 3.7 *on a provisional basis*! Consider it as an experimental API that might be changed or removed in Python 3.8. Event methods, such as `create_server` and `create_connection`, accept factories that return protocols that implement this interface. The idea of BufferedProtocol is that it allows to manually allocate and control the receive buffer. Event loops can then use the buffer provided by the protocol to avoid unnecessary data copies. This can result in noticeable performance improvement for protocols that receive big amounts of data. Sophisticated protocols can allocate the buffer only once at creation time. State machine of calls: start -> CM [-> GB [-> BU?]]* [-> ER?] -> CL -> end * CM: connection_made() * GB: get_buffer() * BU: buffer_updated() * ER: eof_received() * CL: connection_lost() rcCsdS)aPCalled to allocate a new receive buffer. *sizehint* is a recommended minimal size for the returned buffer. When set to -1, the buffer size can be arbitrary. Must return an object that implements the :ref:`buffer protocol `. It is an error to return a zero-sized buffer. Nr)rsizehintrrr get_bufferszBufferedProtocol.get_buffercCsdS)zCalled when the buffer was updated with the received data. *nbytes* is the total number of bytes that were written to the buffer. Nr)rnbytesrrrbuffer_updatedszBufferedProtocol.buffer_updatedcCsdSrrr rrrrszBufferedProtocol.eof_receivedN)rrrrrrrrrrrrrms  rc@s$eZdZdZdZddZddZdS)rz Interface for datagram protocol.rcCsdS)z&Called when some datagram is received.Nr)rrZaddrrrrdatagram_receivedsz"DatagramProtocol.datagram_receivedcCsdS)z~Called when a send or receive operation raises an OSError. (Other than BlockingIOError or InterruptedError.) Nrr rrrerror_receivedszDatagramProtocol.error_receivedN)rrrrrrrrrrrrsrc@s,eZdZdZdZddZddZddZd S) rz,Interface for protocol for subprocess calls.rcCsdS)zCalled when the subprocess writes data into stdout/stderr pipe. fd is int file descriptor. data is bytes object. Nr)rfdrrrrpipe_data_receivedsz%SubprocessProtocol.pipe_data_receivedcCsdS)zCalled when a file descriptor associated with the child process is closed. fd is the int file descriptor that was closed. Nr)rrr rrrpipe_connection_lostsz'SubprocessProtocol.pipe_connection_lostcCsdS)z"Called when subprocess has exited.Nrr rrrprocess_exitedsz!SubprocessProtocol.process_exitedN)rrrrrr r!r"rrrrrs rcCst|}|r||}t|}|s*td||krL||d|<||dS|d||d|<||||d}t|}qdS)Nz%get_buffer() returned an empty buffer)lenr RuntimeErrorr)protorZdata_lenZbufZbuf_lenrrr_feed_data_to_buffered_protos     r&N)r__all__rrrrrr&rrrrs9+9__pycache__/__init__.cpython-38.opt-1.pyc000064400000001360152343727170014115 0ustar00U e5d@sdZddlZddlTddlTddlTddlTddlTddlTddlTddl Tddl Tddl Tddl Tddl TddlTddl mZejejejejejejeje je je je je jejZejdkrddlTeej7ZnddlTeej7ZdS)z'The asyncio package, tracking PEP 3156.N)*)_all_tasks_compatZwin32)__doc__sysZ base_eventsZ coroutinesZevents exceptionsZfuturesZlocksZ protocolsZrunnersZqueuesZstreams subprocessZtasksZ transportsr__all__platformZwindows_eventsZ unix_eventsr r (/usr/lib64/python3.8/asyncio/__init__.pysZ       __pycache__/queues.cpython-38.pyc000064400000020277152343727170012736 0ustar00U e5d @sdZddlZddlZddlZddlmZddlmZGdddeZGdd d eZ Gd d d Z Gd d d e Z Gddde Z dS))Queue PriorityQueue LifoQueue QueueFull QueueEmptyN)events)locksc@seZdZdZdS)rz;Raised when Queue.get_nowait() is called on an empty Queue.N__name__ __module__ __qualname____doc__rr&/usr/lib64/python3.8/asyncio/queues.pyr src@seZdZdZdS)rzDRaised when the Queue.put_nowait() method is called on a full Queue.Nr rrrrrsrc@seZdZdZd)ddddZddZd d Zd d Zd dZddZ ddZ ddZ ddZ e ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdS)*raA queue, useful for coordinating producer and consumer coroutines. If maxsize is less than or equal to zero, the queue size is infinite. If it is an integer greater than 0, then "await put()" will block when the queue reaches maxsize, until an item is removed by get(). Unlike the standard library Queue, you can reliably know this Queue's size with qsize(), since your single-threaded asyncio application won't be interrupted between calling qsize() and doing an operation on the Queue. rNloopcCsp|dkrt|_n||_tjdtdd||_t|_ t|_ d|_ t j |d|_|j||dS)Nz[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.) stacklevelrr)rZget_event_loop_loopwarningswarnDeprecationWarning_maxsize collectionsdeque_getters_putters_unfinished_tasksr ZEvent _finishedset_init)selfmaxsizerrrr__init__!s    zQueue.__init__cCst|_dSN)rr_queuer"r#rrrr!6sz Queue._initcCs |jSr%)r&popleftr"rrr_get9sz Queue._getcCs|j|dSr%r&appendr"itemrrr_put<sz Queue._putcCs&|r"|}|s|dq"qdSr%)r(ZdoneZ set_result)r"waitersZwaiterrrr _wakeup_nextAs  zQueue._wakeup_nextcCs(dt|jdt|dd|dS)N)typer id_formatr)rrr__repr__IszQueue.__repr__cCsdt|jd|dS)Nr2r3r4)r5r r7r)rrr__str__Lsz Queue.__str__cCs~d|j}t|ddr,|dt|j7}|jrH|dt|jd7}|jrd|dt|jd7}|jrz|d|j7}|S)Nzmaxsize=r&z _queue=z _getters[]z _putters[z tasks=)rgetattrlistr&rlenrr)r"resultrrrr7Os  z Queue._formatcCs t|jS)zNumber of items in the queue.)r=r&r)rrrqsize[sz Queue.qsizecCs|jS)z%Number of items allowed in the queue.)rr)rrrr#_sz Queue.maxsizecCs|j S)z3Return True if the queue is empty, False otherwise.r&r)rrremptydsz Queue.emptycCs |jdkrdS||jkSdS)zReturn True if there are maxsize items in the queue. Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True. rFN)rr?r)rrrfullhs z Queue.fullc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| |S)zPut an item into the queue. Put an item into the queue. If the queue is full, wait until a free slot is available before adding item. N) rBr create_futurerr,cancelremove ValueError cancelledr1 put_nowait)r"r.Zputterrrrputss    z Queue.putcCs>|r t|||jd7_|j||jdS)zyPut an item into the queue without blocking. If no free slot is immediately available, raise QueueFull. rN)rBrr/rrclearr1rr-rrrrHs   zQueue.put_nowaitc s|r|j}|j|z|IdHWq|z|j|Wntk r`YnX|s~|s~| |jYqXq| S)zoRemove and return an item from the queue. If queue is empty, wait until an item is available. N) rArrCrr,rDrErFrGr1 get_nowait)r"getterrrrgets    z Queue.getcCs$|r t|}||j|S)zRemove and return an item from the queue. Return an item if one is immediately available, else raise QueueEmpty. )rArr*r1rr-rrrrKs  zQueue.get_nowaitcCs8|jdkrtd|jd8_|jdkr4|jdS)a$Indicate that a formerly enqueued task is complete. Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete. If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue). Raises ValueError if called more times than there were items placed in the queue. rz!task_done() called too many timesrN)rrFrr r)rrr task_dones   zQueue.task_donecs|jdkr|jIdHdS)aBlock until all items in the queue have been gotten and processed. The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks. rN)rrwaitr)rrrjoins z Queue.join)r)r r r rr$r!r*r/r1r8r9r7r?propertyr#rArBrIrHrMrKrNrPrrrrrs(      rc@s4eZdZdZddZejfddZejfddZ dS) rzA subclass of Queue; retrieves entries in priority order (lowest first). Entries are typically tuples of the form: (priority number, data). cCs g|_dSr%r@r'rrrr!szPriorityQueue._initcCs||j|dSr%r@)r"r.heappushrrrr/szPriorityQueue._putcCs ||jSr%r@)r"heappoprrrr*szPriorityQueue._getN) r r r rr!heapqrRr/rSr*rrrrrsrc@s(eZdZdZddZddZddZdS) rzEA subclass of Queue that retrieves most recently added entries first.cCs g|_dSr%r@r'rrrr!szLifoQueue._initcCs|j|dSr%r+r-rrrr/szLifoQueue._putcCs |jSr%)r&popr)rrrr*szLifoQueue._getN)r r r rr!r/r*rrrrrsr) __all__rrTrrr Exceptionrrrrrrrrrs  K__pycache__/tasks.cpython-38.opt-1.pyc000064400000057243152343727170013516 0ustar00U e5d@svdZdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZedjZdBd d ZdCd dZdDddZddZGdddejZeZz ddlZWnek rYn XejZZddddZejj Z ejj!Z!ejj"Z"dde"dddZ#ddZ$ddddZ%d d!Z&d"d#Z'ddd$d%d&Z(ej)d'd(Z*dEddd)d*Z+ddd+d,Z,ej)d-d.Z-ee-_Gd/d0d0ej.Z/dd1d2d3d4Z0ddd5d6Z1d7d8Z2e 3Z4iZ5d9d:Z6d;d<Z7d=d>Z8d?d@Z9e6Z:e9Z;e7Ze9Z?e7Z@e8ZAdS)Fz0Support for tasks, coroutines and the scheduler.)Task create_taskFIRST_COMPLETEDFIRST_EXCEPTION ALL_COMPLETEDwaitwait_for as_completedsleepgathershield ensure_futurerun_coroutine_threadsafe current_task all_tasks_register_task_unregister_task _enter_task _leave_taskN) base_tasks) coroutines)events) exceptions)futures) _is_coroutinecCs|dkrt}t|S)z!Return a currently executed task.N)rget_running_loop_current_tasksgetloopr!%/usr/lib64/python3.8/asyncio/tasks.pyr"srcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)z'Return a set of all tasks for the loop.Nrrcs&h|]}t|kr|s|qSr!)r _get_loopdone.0trr!r" <szall_tasks..)rrlist _all_tasks RuntimeErrorr iZtasksr!rr"r)s rcs^dkrtd}z tt}WqLtk rF|d7}|dkrBYqXqLqfdd|DS)Nrrr#csh|]}t|kr|qSr!)rr$r&rr!r"r)Usz$_all_tasks_compat..)rget_event_loopr*r+r,r-r!rr"_all_tasks_compat@s r0cCs4|dk r0z |j}Wntk r&Yn X||dSN)set_nameAttributeError)tasknamer2r!r!r"_set_task_nameXs  r6cseZdZdZdZed%ddZed&ddZdddfd d Zfd d Z d dZ ddZ ddZ ddZ ddZddZddddZdddddZdd Zd'fd!d" Zd#d$ZZS)(rz A coroutine wrapped in a Future.TNcCs(tjdtdd|dkr t}t|S)zReturn the currently running task in an event loop or None. By default the current task for the current event loop is returned. None is returned when called not in the context of a Task. zVTask.current_task() is deprecated since Python 3.7, use asyncio.current_task() instead stacklevelN)warningswarnDeprecationWarningrr/rclsr r!r!r"rtszTask.current_taskcCstjdtddt|S)z|Return a set of all tasks for an event loop. By default all tasks for the current event loop are returned. zPTask.all_tasks() is deprecated since Python 3.7, use asyncio.all_tasks() insteadr7r8)r:r;r<r0r=r!r!r"rs zTask.all_tasks)r r5cstj|d|jr|jd=t|s:d|_td||dkrRdt|_n t ||_d|_ d|_ ||_ t |_|jj|j|jdt|dS)NrFza coroutine was expected, got zTask-context)super__init___source_tracebackr iscoroutine_log_destroy_pending TypeError_task_name_counter_namestr _must_cancel _fut_waiter_coro contextvarsZ copy_context_context_loop call_soon _Task__stepr)selfcoror r5 __class__r!r"rCs   z Task.__init__csF|jtjkr8|jr8|dd}|jr,|j|d<|j|tdS)Nz%Task was destroyed but it is pending!)r4messageZsource_traceback) Z_staterZ_PENDINGrFrDrPZcall_exception_handlerrB__del__)rSrArUr!r"rXs  z Task.__del__cCs t|Sr1)rZ_task_repr_inforSr!r!r" _repr_infoszTask._repr_infocCs|jSr1)rMrYr!r!r"get_corosz Task.get_corocCs|jSr1)rIrYr!r!r"get_namesz Task.get_namecCst||_dSr1)rJrI)rSvaluer!r!r"r2sz Task.set_namecCs tddS)Nz*Task does not support set_result operationr,)rSresultr!r!r" set_resultszTask.set_resultcCs tddS)Nz-Task does not support set_exception operationr^)rS exceptionr!r!r" set_exceptionszTask.set_exception)limitcCs t||S)aReturn the list of stack frames for this task's coroutine. If the coroutine is not done, this returns the stack where it is suspended. If the coroutine has completed successfully or was cancelled, this returns an empty list. If the coroutine was terminated by an exception, this returns the list of traceback frames. The frames are always ordered from oldest to newest. The optional limit gives the maximum number of frames to return; by default all available frames are returned. Its meaning differs depending on whether a stack or a traceback is returned: the newest frames of a stack are returned, but the oldest frames of a traceback are returned. (This matches the behavior of the traceback module.) For reasons beyond our control, only one stack frame is returned for a suspended coroutine. )rZ_task_get_stack)rSrcr!r!r" get_stackszTask.get_stack)rcfilecCst|||S)anPrint the stack or traceback for this task's coroutine. This produces output similar to that of the traceback module, for the frames retrieved by get_stack(). The limit argument is passed to get_stack(). The file argument is an I/O stream to which the output is written; by default output is written to sys.stderr. )rZ_task_print_stack)rSrcrer!r!r" print_stacks zTask.print_stackcCs4d|_|rdS|jdk r*|jr*dSd|_dS)aRequest that this task cancel itself. This arranges for a CancelledError to be thrown into the wrapped coroutine on the next cycle through the event loop. The coroutine then has a chance to clean up or even deny the request using try/except/finally. Unlike Future.cancel, this does not guarantee that the task will be cancelled: the exception might be caught and acted upon, delaying cancellation of the task or preventing cancellation completely. The task may also return a value or raise a different exception. Immediately after this method is called, Task.cancelled() will not return True (unless the task was already cancelled). A task will be marked as cancelled when the wrapped coroutine terminates with a CancelledError exception (even if cancel() was not called). FNT)Z_log_tracebackr%rLcancelrKrYr!r!r"rgs  z Task.cancelc s|rtd|d||jr>t|tjs8t}d|_|j}d|_t|j |zfz"|dkrp| d}n | |}Wnt k r}z*|jrd|_tnt|jW5d}~XYntjk rtYnttfk r}zt|W5d}~XYntk rL}zt|W5d}~XYnpXt|dd}|dk r@t||j k rtd|d|d}|j j|j||jdn|r||krtd |}|j j|j||jdn8d|_|j|j|jd||_|jr>|jr>d|_n*td |d |}|j j|j||jdn||dkr`|j j|j|jdn\t !|rtd |d |}|j j|j||jdn$td |}|j j|j||jdW5t |j |d}XdS)Nz_step(): already done: z, F_asyncio_future_blockingzTask z got Future z attached to a different loopr@zTask cannot await on itself: z-yield was used instead of yield from in task z with z;yield was used instead of yield from for generator in task zTask got bad yield: )"r%rZInvalidStateErrorrK isinstanceCancelledErrorrMrLrrPrsendthrow StopIterationrBrgr`r]KeyboardInterrupt SystemExitrb BaseExceptiongetattrrr$r,rQrRrOrhadd_done_callback _Task__wakeupinspectZ isgenerator)rSexcrTr_Zblockingnew_excrUr!r"Z__steps               z Task.__stepc CsJz |Wn,tk r8}z||W5d}~XYn X|d}dSr1)r_rprR)rSfuturerur!r!r"Z__wakeup[s  z Task.__wakeup)N)N)N)__name__ __module__ __qualname____doc__rF classmethodrrrCrXrZr[r\r2r`rbrdrfrgrRrs __classcell__r!r!rUr"rbs&     !Tr)r5cCs t}||}t|||S)z]Schedule the execution of a coroutine object in a spawn task. Return a Task object. )rrrr6)rTr5r r4r!r!r"rxs  r)r timeout return_whencst|st|r(tdt|j|s4td|tt t fkrPtd|dkrbt nt jdtddfdd t|D}t|||IdHS) aWait for the Futures and coroutines given by fs to complete. The fs iterable must not be empty. Coroutines will be wrapped in Tasks. Returns two sets of Future: (done, pending). Usage: done, pending = await asyncio.wait(fs) Note: This does not raise TimeoutError! Futures that aren't done when the timeout occurs are returned in the second set. zexpect a list of futures, not z#Set of coroutines/Futures is empty.zInvalid return_when value: N[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.r7r8csh|]}t|dqSrr r'frr!r"r)szwait..)risfuturerrErGtyperx ValueErrorrrrrrr:r;r<set_wait)fsr r~rr!rr"rs rcGs|s|ddSr1)r%r`)waiterargsr!r!r"_release_waitersrrc s|dkrt}ntjdtdd|dkr4|IdHS|dkrt||d}|rX|St||dIdHz |Wn.t j k r}zt |W5d}~XYn Xt | }| |t|}tt|}t||d}||zz|IdHWnPt j k rF|r$|YWdS||t||dIdHYnX|r^|W*S||t||dIdHt W5|XdS)aWait for the single Future or coroutine to complete, with timeout. Coroutine will be wrapped in Task. Returns result of the Future or coroutine. When a timeout occurs, it cancels the task and raises TimeoutError. To avoid the task cancellation, wrap it in shield(). If the wait is cancelled, the task is also cancelled. This function is a coroutine. Nrr7r8rr)rrr:r;r<r r%r__cancel_and_waitrrj TimeoutError create_future call_laterr functoolspartialrrrgremove_done_callback)futr~r rurtimeout_handlecbr!r!r"rsL              rc s|d|dk r"||tt|fdd}|D]}||q@zIdHW5dk rp|D]}||qtXtt}}|D]"}|r| |q| |q||fS)zVInternal helper for wait(). The fs argument must be a collection of Futures. NcsZd8dks4tks4tkrV|sV|dk rVdk rDsVddS)Nrr)rr cancelledrargr%r`rZcounterrrrr!r"_on_completions z_wait.._on_completion) rrrlenrrrgrrr%add)rr~rr rrr%Zpendingr!rr"rs(    rc sF|}tt|}||z||IdHW5||XdS)z.cs*D]}|dqdSr1)r put_nowaitclearr)rr%todor!r" _on_timeoutXs  z!as_completed.._on_timeoutcs4sdS||s0dk r0dSr1)removerrgr)r%rrr!r"r^s    z$as_completed.._on_completioncs$IdH}|dkrtj|Sr1)rrrr_r)r%r!r" _wait_for_onefsz#as_completed.._wait_for_one)rrrrErGrrxZqueuesrrr/r:r;r<rrrrranger)rr r~rrrr_r!)rr%r rrr"r7s*       rccs dVdS)zSkip one event loop run cycle. This is a private helper for 'asyncio.sleep()', used when the 'delay' is set to 0. It uses a bare 'yield' expression (which Task.__step knows how to handle) instead of creating a Future object. Nr!r!r!r!r"__sleep0us rcsr|dkrtIdH|S|dkr*t}ntjdtdd|}||tj ||}z|IdHWS| XdS)z9Coroutine that completes after a given time (in seconds).rNrr7r8) rrrr:r;r<rrrZ_set_result_unless_cancelledrg)Zdelayr_r rwhr!r!r"r s$  r cCst|r6|dkrt}||}|jr2|jd=|St|rb|dk r^|t|k r^t d|St |r|t t ||dStddS)zmWrap a coroutine or an awaitable in a future. If the argument is a Future, it is returned directly. Nr?zRThe future belongs to a different loop than the one specified as the loop argumentrz:An asyncio.Future, a coroutine or an awaitable is required)rrErr/rrDrrr$rrtZ isawaitabler _wrap_awaitablerG)Zcoro_or_futurer r4r!r!r"r s    r ccs|EdHS)zHelper for asyncio.ensure_future(). Wraps awaitable (an object with __await__) into a coroutine that will later be wrapped in a Task by ensure_future(). N) __await__)Z awaitabler!r!r"rsrcs.eZdZdZddfdd ZddZZS)_GatheringFuturezHelper for gather(). This overrides cancel() to cancel all the children and act more like Task.cancel(), which doesn't immediately mark itself as cancelled. Nrcstj|d||_d|_dS)NrF)rBrC _children_cancel_requested)rSchildrenr rUr!r"rCsz_GatheringFuture.__init__cCs6|r dSd}|jD]}|rd}q|r2d|_|S)NFT)r%rrgr)rSZretZchildr!r!r"rgs z_GatheringFuture.cancel)rxryrzr{rCrgr}r!r!rUr"rsrF)r return_exceptionscs|s<|dkrt}ntjdtdd|gSfdd}i}gdd|D]f}||krt||d}|dkrt |}||k rd |_ d 7|||<| |n||} |qdt |dS) aReturn a future aggregating results from the given coroutines/futures. Coroutines will be wrapped in a future and scheduled in the event loop. They will not necessarily be scheduled in the same order as passed in. All futures must share the same event loop. If all the tasks are done successfully, the returned future's result is the list of results (in the order of the original sequence, not necessarily the order of results arrival). If *return_exceptions* is True, exceptions in the tasks are treated the same as successful results, and gathered in the result list; otherwise, the first raised exception will be immediately propagated to the returned future. Cancellation: if the outer Future is cancelled, all children (that have not completed yet) are also cancelled. If any child is cancelled, this is treated as if it raised CancelledError -- the outer Future is *not* cancelled in this case. (This is to prevent the cancellation of one child to cause other children to be cancelled.) If *return_exceptions* is False, cancelling gather() after it has been marked done won't cancel any submitted awaitables. For instance, gather can be marked done after propagating an exception to the caller, therefore, calling ``gather.cancel()`` after catching an exception (raised by one of the awaitables) from gather won't cancel any other awaitables. Nrr7r8csd7r$|s |dSsd|rFt}|dS|}|dk rd|dSkrg}D]8}|rt}n|}|dkr|}||qtjrĈtn  |dS)Nr) r%rrarrjrbr_appendrr`)rruZresultsresrZ nfinishedZnfutsouterrr!r"_done_callbacks4    zgather.._done_callbackrrFr)rr/r:r;r<rr`r rr$rFrrrr)r rZcoros_or_futuresrZ arg_to_futargrr!rr"r s:  1     r cst|dk rtjdtddt||dr0St}|fddfdd }|S) a.Wait for a future, shielding it from cancellation. The statement res = await shield(something()) is exactly equivalent to the statement res = await something() *except* that if the coroutine containing it is cancelled, the task running in something() is not cancelled. From the POV of something(), the cancellation did not happen. But its caller is still cancelled, so the yield-from expression still raises CancelledError. Note: If something() is cancelled by other means this will still cancel shield(). If you want to completely ignore cancellation (not recommended) you can combine shield() with a try/except clause, as follows: try: res = await shield(something()) except CancelledError: res = None Nrr7r8rcs\r|s|dS|r.n*|}|dk rJ|n|dSr1)rrargrbr`r_)innerrurr!r"_inner_done_callbackus  z$shield.._inner_done_callbackcssdSr1)r%rr)rrr!r"_outer_done_callbacksz$shield.._outer_done_callback) r:r;r<r r%rr$rrr)rr rr!)rrrr"r Ps     r cs:tstdtjfdd}|S)zsSubmit a coroutine object to a given event loop. Return a concurrent.futures.Future to access the result. zA coroutine object is requiredc slzttdWnNttfk r2Yn6tk rf}zrT|W5d}~XYnXdS)Nr)rZ _chain_futurer rornrpZset_running_or_notify_cancelrb)rurTrwr r!r"callbacks z*run_coroutine_threadsafe..callback)rrErG concurrentrFutureZcall_soon_threadsafe)rTr rr!rr"r s    r cCst|dS)z3Register a new task in asyncio as executed by loop.N)r+rr4r!r!r"rsrcCs4t|}|dk r(td|d|d|t|<dS)NzCannot enter into task z while another task z is being executed.rrr,r r4rr!r!r"rs rcCs2t|}||k r(td|d|dt|=dS)Nz Leaving task z! does not match the current task .rrr!r!r"rs rcCst|dS)zUnregister a task.N)r+discardrr!r!r"rsr)rrrrr+r)N)N)N)N)Br{__all__Zconcurrent.futuresrrNrrt itertoolstypesr:weakrefrrrrrrcount__next__rHrrr0r6Z _PyFuturerZ_PyTaskZ_asyncio ImportErrorZ_CTaskrrrrrrrrrr coroutinerr r rrrr r r ZWeakSetr+rrrrrZ_py_register_taskZ_py_unregister_taskZ_py_enter_taskZ_py_leave_taskZ_c_register_taskZ_c_unregister_taskZ _c_enter_taskZ _c_leave_taskr!r!r!r"s                #H,>  x?$__pycache__/subprocess.cpython-38.pyc000064400000016300152343727170013607 0ustar00U e5d@sdZddlZddlZddlmZddlmZddlmZddlmZddlm Z ej Z ej Z ej Z Gd d d ej ejZGd d d Zddddejfd dZddddejdddZdS))create_subprocess_execcreate_subprocess_shellN)events) protocols)streams)tasks)loggercsXeZdZdZfddZddZddZdd Zd d Zd d Z ddZ ddZ Z S)SubprocessStreamProtocolz0Like StreamReaderProtocol, but for a subprocess.csHtj|d||_d|_|_|_d|_d|_g|_|j |_ dS)NloopF) super__init___limitstdinstdoutstderr _transport_process_exited _pipe_fds_loopZ create_future _stdin_closed)selflimitr  __class__*/usr/lib64/python3.8/asyncio/subprocess.pyrsz!SubprocessStreamProtocol.__init__cCsn|jjg}|jdk r&|d|j|jdk rB|d|j|jdk r^|d|jdd|S)Nzstdin=zstdout=zstderr=z<{}> )r__name__rappendrrformatjoin)rinforrr__repr__s    z!SubprocessStreamProtocol.__repr__cCs||_|d}|dk rDtj|j|jd|_|j||j d|d}|dk rtj|j|jd|_ |j ||j d|d}|dk rtj ||d|jd|_ dS)Nrrr r)protocolreaderr ) rget_pipe_transportr StreamReaderrrrZ set_transportrr r StreamWriterr)r transportZstdout_transportZstderr_transportZstdin_transportrrrconnection_made)s,       z(SubprocessStreamProtocol.connection_madecCs:|dkr|j}n|dkr |j}nd}|dk r6||dS)Nrr&)rrZ feed_data)rfddatar(rrrpipe_data_receivedAsz+SubprocessStreamProtocol.pipe_data_receivedcCs|dkrN|j}|dk r||||dkr>|jdn |j|dS|dkr^|j}n|dkrn|j}nd}|dk r|dkr|n ||||j kr|j || dS)Nrrr&) rcloseZconnection_lostrZ set_resultZ set_exceptionrrZfeed_eofrremove_maybe_close_transport)rr.excpiper(rrrpipe_connection_lostKs*      z-SubprocessStreamProtocol.pipe_connection_lostcCsd|_|dS)NT)rr3rrrrprocess_exitedfsz'SubprocessStreamProtocol.process_exitedcCs(t|jdkr$|jr$|jd|_dS)Nr)lenrrrr1r7rrrr3js z/SubprocessStreamProtocol._maybe_close_transportcCs||jkr|jSdSN)rr)rstreamrrr_get_close_waiteros z*SubprocessStreamProtocol._get_close_waiter) r __module__ __qualname____doc__rr$r-r0r6r8r3r< __classcell__rrrrr s   r c@sjeZdZddZddZeddZddZd d Zd d Z d dZ ddZ ddZ ddZ dddZdS)ProcesscCs8||_||_||_|j|_|j|_|j|_||_dSr:)rZ _protocolrrrrZget_pidpid)rr,r'r rrrruszProcess.__init__cCsd|jjd|jdS)N)rrrBr7rrrr$~szProcess.__repr__cCs |jSr:)rZget_returncoder7rrr returncodeszProcess.returncodecs|jIdHS)z?Wait until the process exit and return the process return code.N)rZ_waitr7rrrwaitsz Process.waitcCs|j|dSr:)r send_signal)rsignalrrrrGszProcess.send_signalcCs|jdSr:)r terminater7rrrrIszProcess.terminatecCs|jdSr:)rkillr7rrrrJsz Process.killc s|j}|j||r,td|t|z|jIdHWn8tt fk rx}z|rhtd||W5d}~XYnX|rtd||j dS)Nz%%r communicate: feed stdin (%s bytes)z%r communicate: stdin got %rz%r communicate: close stdin) r get_debugrwriter debugr9ZdrainBrokenPipeErrorConnectionResetErrorr1)rinputrMr4rrr _feed_stdins     zProcess._feed_stdincsdSr:rr7rrr_noopsz Process._noopcs|j|}|dkr|j}n|dks(t|j}|jrV|dkrDdnd}td||| IdH}|jr|dkrzdnd}td||| |S)Nr&rrrz%r communicate: read %sz%r communicate: close %s) rr)rAssertionErrorrrrKr rMreadr1)rr.r,r;nameoutputrrr _read_streams    zProcess._read_streamNcs|dk r||}n|}|jdk r2|d}n|}|jdk rP|d}n|}tj||||jdIdH\}}}|IdH||fS)Nrr&r ) rQrRrrWrrZgatherrrF)rrPrrrrrr communicates      zProcess.communicate)N)rr=r>rr$propertyrErFrGrIrJrQrRrWrXrrrrrAts  rAc sbdkrtntjdtddfdd}j||f|||d|IdH\}} t|| S)NZThe loop argument is deprecated since Python 3.8 and scheduled for removal in Python 3.10.r& stacklevelcs tdSNr%r rr%rrsz)create_subprocess_shell..rrr)rget_event_loopwarningswarnDeprecationWarningZsubprocess_shellrA) cmdrrrr rkwdsprotocol_factoryr,r'rr%rrs$ r)rrrr rc sfdkrtntjdtddfdd}j||f||||d|IdH\} } t| | S)NrZr&r[cs tdSr]r^rr%rrr_sz(create_subprocess_exec..r`)rrarbrcrdZsubprocess_execrA) Zprogramrrrr rargsrfrgr,r'rr%rrs( r)__all__ subprocessrbrrrrlogr PIPEZSTDOUTZDEVNULLZFlowControlMixinZSubprocessProtocolr rAZ_DEFAULT_LIMITrrrrrrs.     bV __pycache__/base_events.cpython-38.opt-1.pyc000064400000143154152343727170014664 0ustar00U e5d@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZz ddlZWnek rdZYnXddlmZddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddl m!Z!dZ"dZ#dZ$e%e dZ&dZ'e(Z)ddZ*ddZ+ddZ,d+ddZ-d,ddZ.dd Z/e%e d!rd"d#Z0nd$d#Z0Gd%d&d&ej1Z2Gd'd(d(ej3Z4Gd)d*d*ej5Z6dS)-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) transports)trsock)logger) BaseEventLoopdg?AF_INET6iQcCs0|j}tt|ddtjr$t|jSt|SdS)N__self__)Z _callback isinstancegetattrr Taskreprrstr)handlecbr+/usr/lib64/python3.8/asyncio/base_events.py_format_handleJs rcCs(|tjkrdS|tjkrdSt|SdS)Nzz) subprocessPIPESTDOUTr)fdrrr _format_pipeSs   r!cCsLttdstdn4z|tjtjdWntk rFtdYnXdS)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"OSErrorsockrrr_set_reuseport\s   r+c CsttdsdS|dtjtjhks(|dkr,dS|tjkr>tj}n|tjkrPtj}ndS|dkrbd}nXt|trz|dkrzd}n@t|tr|dkrd}n(z t |}Wnt t fk rYdSX|tj krtj g}tr|tjn|g}t|tr|d}d|krdS|D]t}zVt||trJ|tjkrJ|||d||||ffWS|||d||ffWSWntk rzYnXq dS)N inet_ptonrZidna%)r#r$ IPPROTO_TCPZ IPPROTO_UDP SOCK_STREAM SOCK_DGRAMrbytesrint TypeErrorr% AF_UNSPECAF_INET _HAS_IPv6appendrdecoder,r() hostportfamilytypeprotoZflowinfoZscopeidZafsafrrr _ipaddr_infogsN          rAcCst}|D]*}|d}||kr(g||<|||q t|}g}|dkr|||dd|d|dd|d=|ddtjtj |D|S)z-Interleave list of addrinfo tuples by family.rrNcss|]}|dk r|VqdSNr).0arrr sz(_interleave_addrinfos..) collections OrderedDictr9listvaluesextend itertoolschain from_iterable zip_longest)Z addrinfosZfirst_address_family_countZaddrinfos_by_familyaddrr=Zaddrinfos_listsZ reorderedrrr_interleave_addrinfoss"  rPcCs4|s"|}t|ttfr"dSt|dSrB) cancelled exceptionr SystemExitKeyboardInterruptrZ _get_loopstop)futexcrrr_run_until_complete_cbs rX TCP_NODELAYcCs@|jtjtjhkr<|jtjkr<|jtjkr<|tjtj ddSNr) r=r$r7rr>r1r?r0r&rYr)rrr _set_nodelays   r[cCsdSrBrr)rrrr[sc@sTeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ dS)_SendfileFallbackProtocolcCsht|tjstd||_||_||_|j |_ | | ||j r^|jj |_nd|_dS)Nz.transport should be _FlowControlMixin instance)rr Z_FlowControlMixinr5 _transportZ get_protocol_protoZ is_reading_should_resume_readingZ_protocol_paused_should_resume_writing pause_reading set_protocol_loop create_future_write_ready_fut)selftransprrr__init__s    z"_SendfileFallbackProtocol.__init__cs2|jrtd|j}|dkr$dS|IdHdS)NzConnection closed by peer)r] is_closingConnectionErrorre)rfrVrrrdrains  z_SendfileFallbackProtocol.draincCs tddS)Nz?Invalid state: connection should have been established already. RuntimeError)rf transportrrrconnection_madesz)_SendfileFallbackProtocol.connection_madecCs@|jdk r0|dkr$|jtdn |j||j|dS)NzConnection is closed by peer)reZ set_exceptionrjr^connection_lost)rfrWrrrrps  z)_SendfileFallbackProtocol.connection_lostcCs |jdk rdS|jj|_dSrB)rer]rcrdrfrrr pause_writings z'_SendfileFallbackProtocol.pause_writingcCs$|jdkrdS|jdd|_dS)NF)re set_resultrqrrrresume_writings  z(_SendfileFallbackProtocol.resume_writingcCs tddSNz'Invalid state: reading should be pausedrl)rfdatarrr data_receivedsz'_SendfileFallbackProtocol.data_receivedcCs tddSrurlrqrrr eof_receivedsz&_SendfileFallbackProtocol.eof_receivedcsF|j|j|jr|j|jdk r2|j|jrB|jdSrB) r]rbr^r_resume_readingrecancelr`rtrqrrrrestores   z!_SendfileFallbackProtocol.restoreN) __name__ __module__ __qualname__rhrkrorprrrtrwrxr{rrrrr\s r\c@sxeZdZddZddZddZddZd d Zd d Zd dZ ddZ e ddZ ddZ ddZddZddZdS)ServercCs@||_||_d|_g|_||_||_||_||_d|_d|_ dS)NrF) rc_sockets _active_count_waiters_protocol_factory_backlog _ssl_context_ssl_handshake_timeout_serving_serving_forever_fut)rfloopsocketsprotocol_factoryZ ssl_contextbacklogssl_handshake_timeoutrrrrhszServer.__init__cCsd|jjd|jdS)N) __class__r|rrqrrr__repr__ szServer.__repr__cCs|jd7_dSrZ)rrqrrr_attach#szServer._attachcCs.|jd8_|jdkr*|jdkr*|dS)Nrr)rr_wakeuprqrrr_detach'szServer._detachcCs,|j}d|_|D]}|s||qdSrB)rdoners)rfwaiterswaiterrrrr-s zServer._wakeupc CsJ|jr dSd|_|jD].}||j|j|j||j||j|jqdS)NT) rrZlistenrrc_start_servingrrr)rfr*rrrr4s  zServer._start_servingcCs|jSrB)rcrqrrrget_loop>szServer.get_loopcCs|jSrB)rrqrrr is_servingAszServer.is_servingcCs"|jdkrdStdd|jDS)Nrcss|]}t|VqdSrB)r ZTransportSocket)rCsrrrrEHsz!Server.sockets..)rtuplerqrrrrDs zServer.socketscCsn|j}|dkrdSd|_|D]}|j|qd|_|jdk rX|jsX|jd|_|jdkrj|dS)NFr) rrcZ _stop_servingrrrrzrr)rfrr*rrrcloseJs   z Server.closecs"|tjd|jdIdHdS)Nrr)rr sleeprcrqrrr start_serving]szServer.start_servingc s|jdk rtd|d|jdkr4td|d||j|_zLz|jIdHWn6tjk rz|| IdHW5XYnXW5d|_XdS)Nzserver z, is already being awaited on serve_forever()z is closed) rrmrrrcrdrZCancelledErrorr wait_closedrqrrr serve_forevercs     zServer.serve_forevercs<|jdks|jdkrdS|j}|j||IdHdSrB)rrrcrdr9)rfrrrrrxs   zServer.wait_closedN)r|r}r~rhrrrrrrrpropertyrrrrrrrrrrs   rc @sPeZdZddZddZddZddd d Zd d Zd dZddddddZ ddddddddddZ dddZ dddZ dddZ dddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zejfd7d8Zd9d:Zd;d<Zdd=d>d?Z dd=d@dAZ!dd=dBdCZ"dDdEZ#dFdGZ$dHdIZ%dd=dJdKZ&dLdMZ'dNdOZ(dPdQZ)dRdRdRdRdSdTdUZ*ddVdWZ+dddXdYdZZ,d[d\Z-d]d^Z.d_d`Z/ddadbZ0dddRdRdRdddddddc dddeZ1ddfdgZ2dddXdhdiZ3djdkZ4dldmZ5ddddndodpZ6ddRdRdRe7ddddqdrdsZ8dRe9j:dRdRdSdtduZ;dvdwZddxddddddy dzd{Z?ddd|d}d~Z@ddZAddZBddZCeDjEeDjEeDjEdddRdddd ddZFeDjEeDjEeDjEdddRdddd ddZGddZHddZIddZJddZKddZLddZMddZNddZOddZPddZQddZRdS)rcCsd|_d|_d|_t|_g|_d|_d|_d|_ t dj |_ d|_|td|_d|_d|_d|_d|_t|_d|_dS)NrF monotonicg?)_timer_cancelled_count_closed _stoppingrFdeque_ready _scheduled_default_executorZ _internal_fds _thread_idtimeget_clock_infoZ resolution_clock_resolution_exception_handler set_debugrZ_is_debug_modeslow_callback_duration_current_handle _task_factory"_coroutine_origin_tracking_enabled&_coroutine_origin_tracking_saved_depthweakrefZWeakSet _asyncgens_asyncgens_shutdown_calledrqrrrrhs$  zBaseEventLoop.__init__c Cs.d|jjd|d|d|d S)Nrz running=z closed=z debug=r)rr| is_running is_closed get_debugrqrrrrs,zBaseEventLoop.__repr__cCs tj|dS)z,Create a Future object attached to the loop.r)rZFuturerqrrrrdszBaseEventLoop.create_futureN)namecCsN||jdkr2tj|||d}|jrJ|jd=n|||}t|||S)zDSchedule a coroutine object. Return a task object. N)rr) _check_closedrr r_source_tracebackZ_set_task_name)rfcororZtaskrrr create_tasks    zBaseEventLoop.create_taskcCs"|dk rt|std||_dS)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)callabler5r)rffactoryrrrset_task_factorys zBaseEventLoop.set_task_factorycCs|jS)zsz4BaseEventLoop.shutdown_asyncgens..)Zreturn_exceptionsrz;an error occurred during closing of asynchronous generator )messagerRZasyncgen) rlenrrHclearr gatherzipr Exceptioncall_exception_handler)rfZ closing_agensZresultsresultrrrrshutdown_asyncgens s"     z BaseEventLoop.shutdown_asyncgenscCs(|rtdtdk r$tddS)Nz"This event loop is already runningz7Cannot run the event loop while another loop is running)rrmrZ_get_running_looprqrrr_check_running&s  zBaseEventLoop._check_runningc Cs||||jt|_t}tj |j |j dz t |||j rLq^qLW5d|_ d|_t d|dtj |XdS)zRun until stop() is called.) firstiter finalizerFN)rr_set_coroutine_origin_tracking_debug threading get_identrsysget_asyncgen_hooksset_asyncgen_hooksrrrrZ_set_running_loop _run_once)rfZold_agen_hooksrrr run_forever-s$     zBaseEventLoop.run_foreverc Cs||t| }tj||d}|r4d|_|tz|jd=|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)rrrr _call_soonrrfrr rrrrrrs  zBaseEventLoop.call_sooncCsDt|st|r$td|dt|s@td|d|dS)Nzcoroutines cannot be used with z()z"a callable object was expected by z(), got )rZ iscoroutineZiscoroutinefunctionr5r)rfrmethodrrrrs  zBaseEventLoop._check_callbackcCs.t||||}|jr|jd=|j||S)Nr)rZHandlerrr9)rfrrr rrrrrs  zBaseEventLoop._call_sooncCs,|jdkrdSt}||jkr(tddS)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)rrrrm)rfZ thread_idrrrrs  zBaseEventLoop._check_threadcGsB||jr||d||||}|jr6|jd=||S)z"Like call_soon(), but thread-safe.rr)rrrrrrrrrrrs z"BaseEventLoop.call_soon_threadsafecGsZ||jr||d|dkr@|j}|dkr@tj}||_tj|j|f||dS)Nrun_in_executorr) rrrr concurrentrThreadPoolExecutorZ wrap_futureZsubmit)rfr funcrrrrrs  zBaseEventLoop.run_in_executorcCs&t|tjjstdtd||_dS)Nz{Using the default executor that is not an instance of ThreadPoolExecutor is deprecated and will be prohibited in Python 3.9)rrrrrrDeprecationWarningrr rrrset_default_executorsz"BaseEventLoop.set_default_executorc Cs|d|g}|r$|d||r8|d||rL|d||r`|d|d|}td||}t||||||} ||} d|d | d d d | }| |jkrt|n t|| S) N:zfamily=ztype=zproto=zflags=, zGet address info %szGetting address info z took g@@z.3fzms: ) r9joinrrrr$ getaddrinforinfo) rfr;r<r=r>r?flagsmsgt0addrinfodtrrr_getaddrinfo_debugs&      z BaseEventLoop._getaddrinfo_debugrr=r>r?r&c s2|jr|j}ntj}|d|||||||IdHSrB)rr+r$r$r)rfr;r<r=r>r?r&Z getaddr_funcrrrr$2szBaseEventLoop.getaddrinfocs|dtj||IdHSrB)rr$ getnameinfo)rfZsockaddrr&rrrr-<s zBaseEventLoop.getnameinfo)fallbackc s|jr|dkrtd|||||z|||||IdHWStjk rl}z |s\W5d}~XYnX|||||IdHS)Nrzthe socket must be non-blocking)rZ gettimeoutr%_check_sendfile_params_sock_sendfile_nativerSendfileNotAvailableError_sock_sendfile_fallback)rfr*fileoffsetcountr.rWrrr sock_sendfile@s zBaseEventLoop.sock_sendfilecstd|ddS)Nz-syscall sendfile is not available for socket z and file {file!r} combinationrr1rfr*r3r4r5rrrr0Ns z#BaseEventLoop._sock_sendfile_nativec s|r|||rt|tjntj}t|}d}zt|rNt|||}|dkrNqt|d|}|d|j|IdH} | szq| ||d| IdH|| 7}q2|WS|dkrt|dr|||XdS)Nrseek) r9minrZ!SENDFILE_FALLBACK_READBUFFER_SIZE bytearrayr# memoryviewrreadintoZ sock_sendall) rfr*r3r4r5 blocksizebuf total_sentviewreadrrrr2Us,  z%BaseEventLoop._sock_sendfile_fallbackcCsdt|ddkrtd|jtjks,td|dk rbt|tsLtd||dkrbtd|t|tsztd||dkrtd|dS)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%r>r$r1rr4r5formatr8rrrr/os2   z$BaseEventLoop._check_sendfile_paramsc s@g}|||\}}}}} d} ztj|||d} | d|dk r|D]r\}}}}} z| | WqWqHtk r} z0d| d| j} t| j| } || W5d} ~ XYqHXqH|| | | IdH| WStk r} z"|| | dk r | W5d} ~ XYn | dk r4| YnXdS)z$Create, bind and connect one socket.Nr=r>r?Fz*error while attempting to bind on address : ) r9r$ setblockingbindr(strerrorlowererrnopop sock_connectr)rfrZ addr_infoZlocal_addr_infosZ my_exceptionsr=Ztype_r?_rr*ZladdrrWr'rrr _connect_socks:        zBaseEventLoop._connect_sock) sslr=r?r&r* local_addrrrhappy_eyeballs_delay interleavec  sl| dk r|std| dkr0|r0|s,td|} | dk rD|sDtd| dk rX| dkrXd} |dk sj|dk r|dk rztdj||f|tj||dIdH}|std| dk r܈j| |tj||dIdHstdnd| rt|| }g| dkrH|D]D}z |IdH}WqvWntk r@YqYnXqn.tjfd d |D| d IdH\}}}|dkr d d Dt dkrdnJt dt fdd Dr҈dtd d dd Dn.|dkrtd|jtjkr td|j|||| | dIdH\}}jrd|d}td|||||||fS)aConnect to a TCP server. Create a streaming transport connection to a given Internet host and port: socket family AF_INET or socket.AF_INET6 depending on host (or family if specified), socket type SOCK_STREAM. protocol_factory must be a callable returning a protocol instance. This method is a coroutine which will try to establish the connection in the background. When successful, the coroutine returns a (transport, protocol) pair. Nz+server_hostname is only meaningful with sslz:You must set server_hostname when using ssl without a host1ssl_handshake_timeout is only meaningful with sslr8host/port and sock can not be specified at the same timer=r>r?r&r!getaddrinfo() returned empty listc3s |]}tj|VqdSrB) functoolspartialrP)rCr))r laddr_infosrfrrrEs z2BaseEventLoop.create_connection..rcSsg|]}|D]}|q qSrr)rCsubrWrrrrsz3BaseEventLoop.create_connection..rc3s|]}t|kVqdSrBrrCrW)modelrrrEszMultiple exceptions: {}r"css|]}t|VqdSrBr]r^rrrrE sz5host and port was not specified and no sock specified"A Stream Socket was expected, got )rr$z%r connected to %s:%r: (%r, %r))r%_ensure_resolvedr$r1r(rPrPr Zstaggered_racerrallrEr#r>_create_connection_transportrget_extra_inforr)rfrr;r<rQr=r?r&r*rRrrrSrTinfosr)rOrnrr)rr[r_rfrcreate_connections               zBaseEventLoop.create_connectionc s|d|}|}|rHt|tr*dn|} |j||| ||||d} n||||} z|IdHWn| YnX| |fS)NFrrr)rHrdrboolrrr) rfr*rrQrrrrrrrnrrrrc%s* z*BaseEventLoop._create_connection_transportc s|rtdt|dtjj}|tjjkr:td||tjjkrz|||||IdHWStj k r}z |sxW5d}~XYnX|std|| ||||IdHS)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 closingZ_sendfile_compatiblez(sendfile is not supported for transport NzHfallback is disabled and native sendfile is not supported for transport ) rirmrrZ _SendfileModeZ UNSUPPORTEDZ TRY_NATIVE_sendfile_nativerr1_sendfile_fallback)rfrnr3r4r5r.rDrWrrrsendfile?s4   zBaseEventLoop.sendfilecstddS)Nz!sendfile syscall is not supportedr7)rfrgr3r4r5rrrrinszBaseEventLoop._sendfile_nativec s|r|||rt|dnd}t|}d}t|}z|rXt|||}|dkrX|WbSt|d|} |d|j| IdH} | s|W0S| IdH| | d| || 7}q6W5|dkrt|dr||||IdHXdS)Ni@rr9) r9r:r;r\r#r{r<rr=rkwrite) rfrgr3r4r5r>r?r@r?rArBrrrrjrs* z BaseEventLoop._sendfile_fallbackrgc stdkrtdt|tjs*td|t|ddsFtd|d|}tj|||||||dd}| | || |j |} | |j } z|IdHWn.tk r|| | YnX|jS) zzUpgrade transport to TLS. Return a new transport that *protocol* should start using immediately. Nz"Python ssl module is not availablez@sslcontext is expected to be an instance of ssl.SSLContext, got Z_start_tls_compatibleFz transport z is not supported by start_tls())rr)rQrmrZ SSLContextr5rrdr Z SSLProtocolrarbrrory BaseExceptionrrzZ_app_transport) rfrnrrrrrrZ ssl_protocolZ conmade_cbZ resume_cbrrr start_tlssB      zBaseEventLoop.start_tls)r=r?r& reuse_address reuse_portallow_broadcastr*c s| dk r| jtjkr"td| s>s>|s>|s>|s>|s>| r~t|||||| d} ddd| D} td| d| d d} nss|d krtd ||fd ff}nttd r|tj krfD]}|dk rt |t st dqڈrxd dkrxz"t t jr.tWnFtk rFYn2tk rv}ztd|W5d}~XYnX||ffff}ni}d fdffD]\}}|dk r|j||tj|||dIdH}|std|D]:\}}}}}||f}||krddg||<||||<qqfdd|D}|sHtdg}|tk rv|rftdntjdtdd|D]\\}}\}}d} d} zxtj|tj|d} |rt| | r| tjtjd| d r| |r| s| | |IdH|} Wn^tk rJ}z | dk r0| !|"|W5d}~XYn&| dk rb| !YnXq|qz|d |}|#}|$| || |}|j%r̈rt&d||nt'd||z|IdHWn|!YnX||fS)zCreate datagram connection.NzA UDP Socket was expected, got )rR remote_addrr=r?r&rorprqr"css$|]\}}|r|d|VqdS)=Nr)rCkvrrrrEsz9BaseEventLoop.create_datagram_endpoint..zKsocket modifier keyword arguments can not be used when sock is specified. ()Frzunexpected address family)NNAF_UNIXzstring is expected)rz2Unable to check or remove stale UNIX socket %r: %rrrWrXcs8g|]0\}}r|ddksr,|ddks||fqS)rNrr)rCkeyZ addr_pairrRrrrrrs   z:BaseEventLoop.create_datagram_endpoint..zcan not get address informationz~Passing `reuse_address=True` is no longer supported, as the usage of SO_REUSEPORT in UDP poses a significant security concern.zdThe *reuse_address* parameter has been deprecated as of 3.5.10 and is scheduled for removal in 3.11.r) stacklevelrFz@Datagram endpoint local_addr=%r remote_addr=%r created: (%r, %r)z2Datagram endpoint remote_addr=%r created: (%r, %r))(r>r$r2r%dictr#itemsrHr#rwrrr5statS_ISSOCKosst_moderemoveFileNotFoundErrorr(rerrorra_unsetrrrr+r&r'Z SO_BROADCASTrIrNrr9rdrrr%r) rfrrRrrr=r?r&rorprqr*ZoptsZproblemsZr_addrZaddr_pairs_inforOerrZ addr_infosidxreZfamrOZprorryrZ local_addressZremote_addressrWrrrnrrzrcreate_datagram_endpoints$                  z&BaseEventLoop.create_datagram_endpointc s\|dd\}}t|||||f|dd} | dk r<| gS|j||||||dIdHSdS)Nrr,)rAr$) rfrr=r>r?r&rr;r<r%rrrraLs zBaseEventLoop._ensure_resolvedcs8|j||f|tj||dIdH}|s4td|d|S)N)r=r>r&rz getaddrinfo(z) returned empty list)rar$r1r()rfr;r<r=r&rerrr_create_server_getaddrinfoXs  z(BaseEventLoop._create_server_getaddrinfor) r=r&r*rrQrorprrc  st|trtd| dk r*|dkr*td|dk s<dk r"|dk rLtd| dkrhtjdkoftjdk} g} |dkr|dg}n$t|tst|t j j s|g}n|}fdd |D}t j |d iIdH}ttj|}d }z|D]}|\}}}}}zt|||}Wn8tjk rHjr@tjd |||d dYqYnX| || rl|tjtjd | rzt|tr|tjkrttdr|tj tj!d z|"|Wqt#k r}z t#|j$d||j%&fdW5d}~XYqXqd }W5|s| D]}|qXn4|dkr4td|j'tj(krPtd||g} | D]}|)d qZt*| |||| }| r|+t j,ddIdHjrt-d||S)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 NoneNrUrVposixcygwinr.csg|]}j|dqS))r=r&)r)rCr;r=r&r<rfrrrs z/BaseEventLoop.create_server..rFz:create_server() failed to create socket.socket(%r, %r, %r)Texc_info IPPROTO_IPV6z0error while attempting to bind on address %r: %sz)Neither host/port nor sock were specifiedr`rrz %r is serving).rrhr5r%rrrplatformrrFabcIterabler rsetrKrLrMrr$rrrwarningr9r&r'Z SO_REUSEADDRr+r8rr#rZ IPV6_V6ONLYrIr(rLrJrKr>r1rHrrrr%)rfrr;r<r=r&r*rrQrorprrrZhostsZfsreZ completedresr@Zsocktyper?Z canonnameZsarrrrr create_server`s         zBaseEventLoop.create_server)rQrcsv|jtjkrtd||dk r.|s.td|j|||dd|dIdH\}}|jrn|d}td|||||fS) aHandle an accepted connection. This is used by servers that accept connections outside of asyncio but that use asyncio to handle connections. This method is a coroutine. When completed, the coroutine returns a (transport, protocol) pair. r`NrUr.T)rrr$z%r handled: (%r, %r)) r>r$r1r%rcrrdrr)rfrr*rQrrnrrrrconnect_accepted_sockets$   z%BaseEventLoop.connect_accepted_socketcsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz Read pipe %r connected: (%r, %r))rdrrrrrfilenorfrrrrrnrrrconnect_read_pipeszBaseEventLoop.connect_read_pipecsd|}|}||||}z|IdHWn|YnX|jr\td|||||fS)Nz!Write pipe %r connected: (%r, %r))rdrrrrrrrrrrconnect_write_pipesz BaseEventLoop.connect_write_pipecCs|g}|dk r"|dt||dk rJ|tjkrJ|dt|n8|dk rf|dt||dk r|dt|td|dS)Nzstdin=zstdout=stderr=zstdout=zstderr= )r9r!rrrrr#)rfr'rrrr%rrr_log_subprocessszBaseEventLoop._log_subprocess) rrruniversal_newlinesrrencodingerrorstextc st|ttfstd|r"td|s.td|dkr>td| rJtd| dk rZtd| dk rjtd|} d}|jrd |}||||||j| |d ||||f| IdH}|jr|dk rtd |||| fS) 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) rr3rr%rrrrr%)rfrcmdrrrrrrrrrrr debug_logrnrrrsubprocess_shellsB zBaseEventLoop.subprocess_shellc s|r td|rtd|dkr(td| r4td| dk rDtd| dk rTtd|f| }|}d}|jrd|}||||||j||d ||||f| IdH}|jr|dk rtd ||||fS) Nrzshell must be Falserrrrrzexecute program Fr)r%rrrrr%)rfrZprogramrrrrrrrrrrrZ popen_argsrrrnrrrsubprocess_execCs@   zBaseEventLoop.subprocess_execcCs|jS)zKReturn an exception handler, or None if the default one is in use. )rrqrrrget_exception_handleresz#BaseEventLoop.get_exception_handlercCs(|dk rt|std|||_dS)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 )rr5r)rfZhandlerrrrset_exception_handlerjs z#BaseEventLoop.set_exception_handlerc Cs|d}|sd}|d}|dk r6t|||jf}nd}d|kr`|jdk r`|jjr`|jj|d<|g}t|D]}|dkr|qn||}|dkrd t|}d }|| 7}n2|dkrd t|}d }|| 7}nt |}| |d |qnt j d ||ddS)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()`. rz!Unhandled exception in event looprRNFZsource_tracebackZhandle_traceback>rrRr.z+Object created at (most recent call last): z+Handle created at (most recent call last): rG r)getr> __traceback__rrsortedr# traceback format_listrstriprr9rr) rfr rrRrZ log_linesryvaluetbrrrdefault_exception_handler{s<   z'BaseEventLoop.default_exception_handlerc Cs|jdkrVz||Wqttfk r2Yqtk rRtjdddYqXnz|||Wnttfk rYnttk r}zVz|d||dWn:ttfk rYn"tk rtjdddYnXW5d}~XYnXdS)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 handlerTrz$Unhandled error in exception handler)rrRr zeException in default exception handler while handling an unexpected error in custom exception handler)rrrSrTrmrr)rfr rWrrrrs4  z$BaseEventLoop.call_exception_handlercCs|jr dS|j|dS)z3Add a Handle to _scheduled (TimerHandle) or _ready.N) _cancelledrr9rfrrrr _add_callbackszBaseEventLoop._add_callbackcCs|||dS)z6Like _add_callback() but called from a signal handler.N)rrrrrr_add_callback_signalsafes z&BaseEventLoop._add_callback_signalsafecCs|jr|jd7_dS)z3Notification that a TimerHandle has been cancelled.rN)rrrrrr_timer_handle_cancelledsz%BaseEventLoop._timer_handle_cancelledc Cst|j}|tkr`|j|tkr`g}|jD]}|jrsd                  ;   Do__pycache__/constants.cpython-38.opt-2.pyc000064400000001107152343727170014372 0ustar00U e5dx@s2ddlZdZdZdZdZdZGdddejZdS) N gN@ic@s$eZdZeZeZeZdS) _SendfileModeN)__name__ __module__ __qualname__enumautoZ UNSUPPORTEDZ TRY_NATIVEZFALLBACKr r )/usr/lib64/python3.8/asyncio/constants.pyrsr)r Z!LOG_THRESHOLD_FOR_CONNLOST_WRITESZACCEPT_RETRY_DELAYZDEBUG_STACK_DEPTHZSSL_HANDSHAKE_TIMEOUTZ!SENDFILE_FALLBACK_READBUFFER_SIZEEnumrr r r r s __pycache__/locks.cpython-38.opt-2.pyc000064400000023050152343727170013472 0ustar00U e5d|C@sdZddlZddlZddlZddlmZddlmZddlmZddlmZGdd d Z Gd d d Z Gd d d e Z GdddZ Gddde Z Gddde ZGdddeZdS))LockEvent Condition SemaphoreBoundedSemaphoreN)events)futures) exceptions) coroutinesc@s$eZdZddZddZddZdS)_ContextManagercCs ||_dSN)_lock)selflockr%/usr/lib64/python3.8/asyncio/locks.py__init__"sz_ContextManager.__init__cCsdSr rrrrr __enter__%sz_ContextManager.__enter__cGsz|jW5d|_XdSr )rreleaserargsrrr__exit__*sz_ContextManager.__exit__N)__name__ __module__ __qualname__rrrrrrrr sr c@sReZdZddZddZejddZej e_ ddZ d d Z d d Z d dZ dS)_ContextManagerMixincCs tddS)Nz9"yield from" should be used as context manager expression) RuntimeErrorrrrrr2sz_ContextManagerMixin.__enter__cGsdSr rrrrrr6sz_ContextManagerMixin.__exit__ccs&tjdtdd|EdHt|S)NzD'with (yield from lock)' is deprecated use 'async with lock' instead stacklevel)warningswarnDeprecationWarningacquirer rrrr__iter__;s z_ContextManagerMixin.__iter__cs|IdHt|Sr )r%r rrrrZ __acquire_ctxUsz"_ContextManagerMixin.__acquire_ctxcCstjdtdd|S)Nz='with await lock' is deprecated use 'async with lock' insteadrr )r"r#r$!_ContextManagerMixin__acquire_ctx __await__rrrrr(Ys z_ContextManagerMixin.__await__cs|IdHdSr )r%rrrr __aenter__`sz_ContextManagerMixin.__aenter__cs |dSr )r)rexc_typeexctbrrr __aexit__fsz_ContextManagerMixin.__aexit__N)rrrrrtypes coroutiner&r Z _is_coroutiner'r(r)r-rrrrr1s rcsJeZdZddddZfddZddZd d Zd d Zd dZZ S)rNloopcCs:d|_d|_|dkr t|_n||_tjdtdddSNF[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.rr )_waiters_lockedrget_event_loop_loopr"r#r$rr1rrrrs z Lock.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS NlockedZunlocked , waiters:)super__repr__r5r4lenrresZextra __class__rrrAs  z Lock.__repr__cCs|jSr )r5rrrrr:sz Lock.lockedc s|js.|jdks$tdd|jDr.d|_dS|jdkrBt|_|j}|j|z"z|IdHW5|j|XWn&t j k r|js| YnXd|_dS)Ncss|]}|VqdSr ) cancelled).0wrrr szLock.acquire..T) r5r4all collectionsdequer7 create_futureappendremover CancelledError_wake_up_firstrfutrrrr%s&    z Lock.acquirecCs"|jrd|_|ntddS)NFzLock is not acquired.)r5rRrrrrrrs  z Lock.releasecCsJ|js dSztt|j}Wntk r2YdSX|sF|ddSNT)r4nextiter StopIterationdone set_resultrSrrrrRszLock._wake_up_first) rrrrrAr:r%rrR __classcell__rrrErrjs 6  rcsJeZdZddddZfddZddZd d Zd d Zd dZZ S)rNr0cCs>t|_d|_|dkr$t|_n||_tjdt dddSr2) rLrMr4_valuerr6r7r"r#r$r8rrrrs  zEvent.__init__csLt}|jrdnd}|jr2|dt|j}d|ddd|dS) NsetZunsetr;r<rr=r>r?)r@rAr\r4rBrCrErrrA s  zEvent.__repr__cCs|jSr r\rrrris_setsz Event.is_setcCs.|js*d|_|jD]}|s|dqdSrU)r\r4rYrZrSrrrr]s  z Event.setcCs d|_dS)NFr^rrrrclear"sz Event.clearc sF|jr dS|j}|j|z|IdHWdS|j|XdSrU)r\r7rNr4rOrPrSrrrwait(s   z Event.wait) rrrrrAr_r]r`rar[rrrErrs    rcsNeZdZdddddZfddZddZd d Zdd d ZddZZ S)rNr0cCs~|dkrt|_n||_tjdtdd|dkr>t|d}n|j|jk rRtd||_|j |_ |j |_ |j |_ t |_dS)Nr3rr r0z"loop argument must agree with lock)rr6r7r"r#r$r ValueErrorrr:r%rrLrMr4)rrr1rrrrEs    zCondition.__init__csNt}|rdnd}|jr4|dt|j}d|ddd|dSr9)r@rAr:r4rBrCrErrrA[s  zCondition.__repr__cs|std|z@|j}|j |z|IdHWWdS|j |XW5d}z|IdHWqWq^tjk rd}Yq^Xq^|rtjXdS)Nzcannot wait on un-acquired lockFT) r:rrr%r rQr7rNr4rOrP)rrGrTrrrrabs$      zCondition.waitcs$|}|s |IdH|}q|Sr )ra)rZ predicateresultrrrwait_fors zCondition.wait_forrcCsJ|stdd}|jD]*}||kr*qF|s|d7}|dqdS)Nz!cannot notify on un-acquired lockrrF)r:rr4rYrZ)rnidxrTrrrnotifys  zCondition.notifycCs|t|jdSr )rgrBr4rrrr notify_allszCondition.notify_all)N)r) rrrrrArardrgrhr[rrrErr;s   % rcsLeZdZdddddZfddZdd Zd d Zd d ZddZZ S)rrNr0cCsN|dkrtd||_t|_|dkr4t|_n||_tj dt dddS)Nrz$Semaphore initial value must be >= 0r3rr ) rbr\rLrMr4rr6r7r"r#r$rvaluer1rrrrs  zSemaphore.__init__csVt}|rdn d|j}|jr<|dt|j}d|ddd|dS) Nr:zunlocked, value:r;r<rr=r>r?)r@rAr:r\r4rBrCrErrrAs  zSemaphore.__repr__cCs,|jr(|j}|s|ddSqdSr )r4popleftrYrZ)rZwaiterrrr _wake_up_nexts   zSemaphore._wake_up_nextcCs |jdkS)Nrr^rrrrr:szSemaphore.lockedcst|jdkrb|j}|j|z|IdHWq||jdkrX|sX|YqXq|jd8_dS)NrrT)r\r7rNr4rOZcancelrGrlrSrrrr%s    zSemaphore.acquirecCs|jd7_|dS)Nr)r\rlrrrrrszSemaphore.release)r) rrrrrArlr:r%rr[rrrErrs  rcs0eZdZdddfdd ZfddZZS) rrNr0cs.|rtjdtdd||_tj||ddS)Nr3rr r0)r"r#r$ _bound_valuer@rrirErrr szBoundedSemaphore.__init__cs"|j|jkrtdtdS)Nz(BoundedSemaphore released too many times)r\rmrbr@rrrErrrs zBoundedSemaphore.release)r)rrrrrr[rrrErrs r)__all__rLr.r"rr r r r rrrrrrrrrrs    "9DzN__pycache__/windows_events.cpython-38.opt-1.pyc000064400000057751152343727170015453 0ustar00U e5di@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddl mZddl mZdd l mZdd l mZdd l mZdd lmZd ZdZdZdZdZdZdZGddde jZGddde jZGdddeZGdddeZ Gddde!Z"Gdddej#Z$Gdd d ej%Z&Gd!d"d"Z'Gd#d$d$e j(Z)e$Z*Gd%d&d&e j+Z,Gd'd(d(e j+Z-e-Z.dS))z.Selector and proactor event loops for Windows.N)events)base_subprocess)futures) exceptions)proactor_events)selector_events)tasks) windows_utils)logger)SelectorEventLoopProactorEventLoop IocpProactorDefaultEventLoopPolicyWindowsSelectorEventLoopPolicyWindowsProactorEventLoopPolicyiigMbP?g?cs^eZdZdZddfdd ZfddZdd Zfd d Zfd d ZfddZ Z S)_OverlappedFuturezSubclass of Future which represents an overlapped operation. Cancelling it will immediately cancel the overlapped operation. Nloopcs&tj|d|jr|jd=||_dSNr)super__init___source_traceback_ov)selfovr __class__./usr/lib64/python3.8/asyncio/windows_events.pyr1sz_OverlappedFuture.__init__csHt}|jdk rD|jjr dnd}|dd|d|jjdd|S)NpendingZ completedrz overlapped=)r _repr_inforr"insertaddressrinfostaterr r!r%7s    z_OverlappedFuture._repr_infoc Csr|jdkrdSz|jWnJtk rf}z,d||d}|jrJ|j|d<|j|W5d}~XYnXd|_dS)Nz&Cancelling an overlapped future failedmessage exceptionfuturesource_traceback)rcancelOSErrorr_loopcall_exception_handler)rexccontextr r r!_cancel_overlapped>s  z$_OverlappedFuture._cancel_overlappedcs|tSN)r6rr0rrr r!r0Nsz_OverlappedFuture.cancelcst||dSr7)r set_exceptionr6rr-rr r!r9Rs z_OverlappedFuture.set_exceptioncst|d|_dSr7)r set_resultrrresultrr r!r;Vs z_OverlappedFuture.set_result) __name__ __module__ __qualname____doc__rr%r6r0r9r; __classcell__r r rr!r+s   rcsneZdZdZddfdd ZddZfdd Zd d Zd d ZfddZ fddZ fddZ Z S)_BaseWaitHandleFuturez2Subclass of Future which represents a wait handle.Nrcs8tj|d|jr|jd=||_||_||_d|_dS)NrrT)rrrr_handle _wait_handle _registered)rrhandle wait_handlerrr r!r^sz_BaseWaitHandleFuture.__init__cCst|jdtjkSNr)_winapiZWaitForSingleObjectrDZ WAIT_OBJECT_0r8r r r!_pollls z_BaseWaitHandleFuture._pollcsdt}|d|jd|jdk rB|r4dnd}|||jdk r`|d|jd|S)Nzhandle=r#ZsignaledZwaitingz wait_handle=)rr%appendrDrKrEr(rr r!r%qs    z _BaseWaitHandleFuture._repr_infocCs d|_dSr7)rrfutr r r!_unregister_wait_cb{sz)_BaseWaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt|Wn`tk r}zB|jtjkrzd||d}|jrd|j|d<|j |WYdSW5d}~XYnX| ddSNFz$Failed to unregister the wait handler+r/) rFrE _overlappedZUnregisterWaitr1winerrorERROR_IO_PENDINGrr2r3rOrrHr4r5r r r!_unregister_waits$   z&_BaseWaitHandleFuture._unregister_waitcs|tSr7)rUrr0r8rr r!r0sz_BaseWaitHandleFuture.cancelcs|t|dSr7)rUrr9r:rr r!r9sz#_BaseWaitHandleFuture.set_exceptioncs|t|dSr7)rUrr;r<rr r!r;sz _BaseWaitHandleFuture.set_result) r>r?r@rArrKr%rOrUr0r9r;rBr r rr!rC[s   rCcsFeZdZdZddfdd ZddZfdd Zfd d ZZS) _WaitCancelFuturezoSubclass of Future which represents a wait for the cancellation of a _WaitHandleFuture using an event. Nrcstj||||dd|_dS)Nr)rr_done_callback)rreventrHrrr r!rsz_WaitCancelFuture.__init__cCs tddS)Nz'_WaitCancelFuture must not be cancelled) RuntimeErrorr8r r r!r0sz_WaitCancelFuture.cancelcs$t||jdk r ||dSr7)rr;rWr<rr r!r;s  z_WaitCancelFuture.set_resultcs$t||jdk r ||dSr7)rr9rWr:rr r!r9s  z_WaitCancelFuture.set_exception) r>r?r@rArr0r;r9rBr r rr!rVs  rVcs6eZdZddfdd ZfddZddZZS) _WaitHandleFutureNrcs<tj||||d||_d|_tdddd|_d|_dS)NrTF)rr _proactorZ_unregister_proactorrQZ CreateEvent_event _event_fut)rrrGrHproactorrrr r!rs z_WaitHandleFuture.__init__csF|jdk r"t|jd|_d|_|j|jd|_t|dSr7) r\rJ CloseHandler]r[ _unregisterrrrOrMrr r!rOs   z%_WaitHandleFuture._unregister_wait_cbc Cs|js dSd|_|j}d|_zt||jWn`tk r}zB|jtjkr~d||d}|jrh|j|d<|j |WYdSW5d}~XYnX|j |j|j |_dSrP)rFrErQZUnregisterWaitExr\r1rRrSrr2r3r[ _wait_cancelrOr]rTr r r!rUs(    z"_WaitHandleFuture._unregister_wait)r>r?r@rrOrUrBr r rr!rZs rZc@s<eZdZdZddZddZddZdd Zd d ZeZ d S) PipeServerzXClass representing a pipe server. This is much like a bound, listening socket. cCs,||_t|_d|_d|_|d|_dSNT)_addressweakrefWeakSet_free_instances_pipe_accept_pipe_future_server_pipe_handle)rr'r r r!rs  zPipeServer.__init__cCs|j|d}|_|S)NF)rhrj)rtmpr r r!_get_unconnected_pipesz PipeServer._get_unconnected_pipec Csr|r dStjtjB}|r&|tjO}t|j|tjtjBtj Btj t j t j tj tj}t |}|j||Sr7)closedrJZPIPE_ACCESS_DUPLEXZFILE_FLAG_OVERLAPPEDZFILE_FLAG_FIRST_PIPE_INSTANCEZCreateNamedPiperdZPIPE_TYPE_MESSAGEZPIPE_READMODE_MESSAGEZ PIPE_WAITZPIPE_UNLIMITED_INSTANCESr ZBUFSIZEZNMPWAIT_WAIT_FOREVERNULL PipeHandlergadd)rfirstflagshpiper r r!rjs(     zPipeServer._server_pipe_handlecCs |jdkSr7)rdr8r r r!rmszPipeServer.closedcCsR|jdk r|jd|_|jdk rN|jD] }|q*d|_d|_|jdSr7)rir0rdrgcloserhclear)rrtr r r!rus     zPipeServer.closeN) r>r?r@rArrlrjrmru__del__r r r r!rbs  rbc@seZdZdZdS)_WindowsSelectorEventLoopz'Windows version of selector event loop.N)r>r?r@rAr r r r!rx,srxcsHeZdZdZd fdd ZfddZddZd d Zdd d ZZ S)r z2Windows version of proactor event loop using IOCP.Ncs|dkrt}t|dSr7)rrr)rr^rr r!r3szProactorEventLoop.__init__c sXz||jtW5|jdk rR|jj}|j|dk rL|j|d|_XdSr7) Z_self_reading_futurerr0r[r` call_soonZ_loop_self_readingr run_foreverrrrr r!rz8s    zProactorEventLoop.run_forevercs8|j|}|IdH}|}|j||d|id}||fS)Naddrextra)r[ connect_pipe_make_duplex_pipe_transport)rprotocol_factoryr'frtprotocoltransr r r!create_pipe_connectionKs  z(ProactorEventLoop.create_pipe_connectioncs.tdfdd gS)Nc s d}zn|rN|}j|r4|WdS}j||did}|dkrdWdSj|}Wnt k r}zF|r| dkr d||d|nj rt jd|ddW5d}~XYn2tjk r|r|YnX|_|dS) Nr|r}rzPipe accept failed)r,r-rtzAccept pipe failed on pipe %rT)exc_info)r=rgdiscardrmrurrlr[ accept_piper1filenor3Z_debugr ZwarningrCancelledErrorriadd_done_callback)rrtrr4r'loop_accept_piperrZserverr r!rVsH  z>ProactorEventLoop.start_serving_pipe..loop_accept_pipe)N)rbry)rrr'r rr!start_serving_pipeSs( z$ProactorEventLoop.start_serving_pipec s|} t||||||||f| |d| } z| IdHWnDttfk rTYn,tk r~| | IdHYnX| S)N)waiterr~) create_future_WindowsSubprocessTransport SystemExitKeyboardInterrupt BaseExceptionruZ_wait) rrargsshellstdinstdoutstderrbufsizer~kwargsrZtranspr r r!_make_subprocess_transports* z,ProactorEventLoop._make_subprocess_transport)N)N) r>r?r@rArrzrrrrBr r rr!r 0s 0r c@seZdZdZd;ddZddZddZd d ZdddZ d?ddZ d@ddZ dAddZddZddZdd Zd!d"Zd#d$ZdBd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2ZdCd3d4Zd5d6Zd7d8Zd9d:Zd S)Drz#Proactor implementation using IOCP.rcCsDd|_g|_ttjtd||_i|_t |_ g|_ t |_ dSrI) r2_resultsrQCreateIoCompletionPortINVALID_HANDLE_VALUErn_iocp_cachererfrF _unregistered_stopped_serving)rZ concurrencyr r r!rs zIocpProactor.__init__cCs|jdkrtddS)NzIocpProactor is closed)rrYr8r r r! _check_closeds zIocpProactor._check_closedcCsFdt|jdt|jg}|jdkr0|dd|jjd|fS)Nzoverlapped#=%sz result#=%srmz<%s %s> )lenrrrrLrr>join)rr)r r r!__repr__s     zIocpProactor.__repr__cCs ||_dSr7)r2)rrr r r!set_loopszIocpProactor.set_loopNcCs |js|||j}g|_|Sr7)rrK)rtimeoutrkr r r!selects  zIocpProactor.selectcCs|j}|||Sr7)r2rr;)rvaluerNr r r!_results  zIocpProactor._resultrcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7 getresultr1rRrQZERROR_NETNAME_DELETEDZERROR_OPERATION_ABORTEDConnectionResetErrorrrkeyrr4r r r! finish_recvs  z&IocpProactor.recv..finish_recv) _register_with_iocprQ Overlappedrn isinstancesocketZWSARecvrZReadFileBrokenPipeErrorr _registerrconnnbytesrrrrr r r!recvs    zIocpProactor.recvcCs~||tt}z4t|tjr6||||n|||Wnt k rf| dYSXdd}| |||S)Nrc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z+IocpProactor.recv_into..finish_recv) rrQrrnrrZ WSARecvIntorZ ReadFileIntorrr)rrbufrrrrr r r! recv_intos    zIocpProactor.recv_intocCs`||tt}z||||Wntk rH|dYSXdd}||||S)N)rNc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z*IocpProactor.recvfrom..finish_recv) rrQrrnZ WSARecvFromrrrrrr r r!recvfroms   zIocpProactor.recvfromcCs>||tt}|||||dd}||||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r! finish_sends  z(IocpProactor.sendto..finish_send)rrQrrnZ WSASendTorr)rrrrrr|rrr r r!sendtos    zIocpProactor.sendtocCsZ||tt}t|tjr4||||n|||dd}| |||S)Nc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!rs  z&IocpProactor.send..finish_send) rrQrrnrrZWSASendrZ WriteFiler)rrrrrrrr r r!sends    zIocpProactor.sendcsv||jtt}|fdd}dd}|||}||}t j ||j d|S)NcsD|td}tjtj|   fS)Nz@P) rstructZpackr setsockoptr SOL_SOCKETrQZSO_UPDATE_ACCEPT_CONTEXT settimeoutZ gettimeoutZ getpeername)rrrrrlistenerr r! finish_accept*sz*IocpProactor.accept..finish_acceptcs4z|IdHWn tjk r.|YnXdSr7)rrru)r.rr r r! accept_coro3s z(IocpProactor.accept..accept_coror) r_get_accept_socketfamilyrQrrnZAcceptExrrr Z ensure_futurer2)rrrrrr.coror rr!accept$s     zIocpProactor.acceptc sjtjkr4t||j}|d|S| zt j WnBt k r}z$|j tjkrtddkrW5d}~XYnXtt}||fdd}|||S)Nrrcs|tjtjdSrI)rrrrrQZSO_UPDATE_CONNECT_CONTEXTrrrrr r!finish_connectVs z,IocpProactor.connect..finish_connect)typerZ SOCK_DGRAMrQZ WSAConnectrr2rr;rZ BindLocalrr1rRerrnoZ WSAEINVALZ getsocknamerrnZ ConnectExr)rrr'rNerrr rr!connect@s"       zIocpProactor.connectc Csb||tt}|d@}|d?d@}||t||||dddd}||||S)Nr rc SsRz |WStk rL}z$|jtjtjfkr:t|jnW5d}~XYnXdSr7rrr r r!finish_sendfileis  z.IocpProactor.sendfile..finish_sendfile) rrQrrnZ TransmitFilermsvcrtZ get_osfhandler) rZsockfileoffsetcountrZ offset_lowZ offset_highrr r r!sendfile_s      zIocpProactor.sendfilecsJ|tt}|}|r0|Sfdd}|||S)Ncs |Sr7)rrrtr r!finish_accept_pipesz4IocpProactor.accept_pipe..finish_accept_pipe)rrQrrnZConnectNamedPiperrr)rrtrZ connectedrr rr!rts    zIocpProactor.accept_pipec srt}zt|}WqhWn0tk rF}z|jtjkr6W5d}~XYnXt|dt}t |IdHqt |S)N) CONNECT_PIPE_INIT_DELAYrQZ ConnectPiper1rRZERROR_PIPE_BUSYminCONNECT_PIPE_MAX_DELAYr sleepr ro)rr'ZdelayrGr4r r r!rs  zIocpProactor.connect_pipecCs|||dS)zWait for a handle. Return a Future object. The result of the future is True if the wait completed, or False if the wait did not complete (on timeout). F)_wait_for_handle)rrGrr r r!wait_for_handleszIocpProactor.wait_for_handlecCs||dd}||_|Src)rrW)rrXZ done_callbackrNr r r!raszIocpProactor._wait_cancelcs||dkrtj}nt|d}tt}t||j |j |}|r\t ||||j dnt |||||j djr~jd=fdd}|d|f|j|j <S)N@@rrcsSr7)rKrrr r!finish_wait_for_handlesz=IocpProactor._wait_for_handle..finish_wait_for_handler)rrJINFINITEmathceilrQrrnZRegisterWaitWithQueuerr'rVr2rZrr)rrGrZ _is_cancelmsrrHrr rr!rs*   zIocpProactor._wait_for_handlecCs0||jkr,|j|t||jdddSrI)rFrprQrrrrobjr r r!rs  z IocpProactor._register_with_iocpc Cs|t||jd}|jr$|jd=|jsrz|dd|}Wn,tk rf}z||W5d}~XYn X||||||f|j|j <|Sr) rrr2rr"r1r9r;rr')rrrcallbackrrrr r r!rs zIocpProactor._registercCs||j|dS)a Unregister an overlapped object. Call this method when its future has been cancelled. The event can already be signalled (pending in the proactor event queue). It is also safe if the event is never signalled (because it was cancelled). N)rrrLr{r r r!r`szIocpProactor._unregistercCst|}|d|SrI)rr)rrsr r r!rs  zIocpProactor._get_accept_socketc Cs|dkrt}n0|dkr tdnt|d}|tkr>tdt|j|}|dkrXqZd}|\}}}}z|j|\}} } } WnXt k r|j r|j dd||||fd|dtj fkrt|Yq>YnX| |jkr|q>|s>z| ||| } Wn:tk r@} z|| |j|W5d} ~ XYq>X|| |j|q>|jD]} |j| jdq`|jdS)Nrznegative timeoutrztimeout too bigz8GetQueuedCompletionStatus() returned an unexpected eventz)err=%s transferred=%s key=%#x address=%#x)r,status)r ValueErrorrrrQZGetQueuedCompletionStatusrrpopKeyErrorr2Z get_debugr3rrJr_rr0Zdoner1r9rrLr;rr'rv)rrrrerrZ transferredrr'rrrrrrr r r!rKsL            zIocpProactor._pollcCs|j|dSr7)rrprr r r! _stop_serving9szIocpProactor._stop_servingc Cs|jdkrdSt|jD]\}\}}}}|r6qt|trBqz |Wqtk r}z6|j dk rd||d}|j r|j |d<|j |W5d}~XYqXqd}t } | |} |jr| t krtd|t | t |} ||qg|_t|jd|_dS)NzCancelling a future failedr+r/g?z,%r is running after closing for %.1f seconds)rlistritemsZ cancelledrrVr0r1r2rr3time monotonicr debugrKrrJr_) rr'rNrrrr4r5Z msg_updateZ start_timeZnext_msgr r r!ru?s@           zIocpProactor.closecCs |dSr7)rur8r r r!rwnszIocpProactor.__del__)r)N)r)r)r)rN)r)N)N)r>r?r@rArrrrrrrrrrrrrrrrrrarrrr`rrKrrurwr r r r!rs8        "    7/rc@seZdZddZdS)rc  sPtj|f|||||d|_fdd}jjtjj} | |dS)N)rrrrrcsj}|dSr7)_procZpollZ_process_exited)r returncoder8r r!rys z4_WindowsSubprocessTransport._start..callback) r Popenrr2r[rintrDr) rrrrrrrrrrr r8r!_startts z"_WindowsSubprocessTransport._startN)r>r?r@rr r r r!rrsrc@seZdZeZdS)rN)r>r?r@r _loop_factoryr r r r!rsrc@seZdZeZdS)rN)r>r?r@r rr r r r!rsr)/rArQrJrrrrrrrerrrrrrr r logr __all__rnrZERROR_CONNECTION_REFUSEDZERROR_CONNECTION_ABORTEDrrZFuturerrCrVrZobjectrbZBaseSelectorEventLooprxZBaseProactorEventLoopr rZBaseSubprocessTransportrr ZBaseDefaultEventLoopPolicyrrrr r r r!sR         0J4;e`__pycache__/unix_events.cpython-38.opt-1.pyc000064400000114055152343727170014733 0ustar00U e5dۿ@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZddl mZddl mZddl mZdd l mZdd l mZdd l mZdd l mZdd l mZddlmZdZe jdkredddZGdddejZGdddej Z!Gdddej"ej#Z$Gdddej%Z&GdddZ'ddZ(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),z2Selector event loop for Unix with signal handling.N) base_events)base_subprocess) constants) coroutines)events) exceptions)futures)selector_events)tasks) transports)logger)SelectorEventLoopAbstractChildWatcherSafeChildWatcherFastChildWatcherMultiLoopChildWatcherThreadedChildWatcherDefaultEventLoopPolicyZwin32z+Signals are not really supported on WindowscCsdS)zDummy signal handler.N)signumframerr+/usr/lib64/python3.8/asyncio/unix_events.py_sighandler_noop*srcseZdZdZd)fdd ZfddZddZd d Zd d Zd dZ ddZ d*ddZ d+ddZ d,ddZ ddZd-dddddddZd.dddddddd Zd!d"Zd#d$Zd%d&Zd'd(ZZS)/_UnixSelectorEventLoopzdUnix event loop. Adds signal handling and UNIX Domain Socket support to SelectorEventLoop. Ncst|i|_dSN)super__init___signal_handlers)selfselector __class__rrr5s z_UnixSelectorEventLoop.__init__csZtts.t|jD]}||qn(|jrVtjd|dt |d|j dS)NzClosing the loop z@ on interpreter shutdown stage, skipping signal handlers removalsource) rclosesys is_finalizinglistrremove_signal_handlerwarningswarnResourceWarningclearrsigr!rrr%9s z_UnixSelectorEventLoop.closecCs|D]}|sq||qdSr)_handle_signal)rdatarrrr_process_self_dataGsz)_UnixSelectorEventLoop._process_self_datac GsLt|st|rtd|||zt|j Wn2t t fk rt}zt t |W5d}~XYnXt|||d}||j|<zt|tt|dWnt k rF}zz|j|=|jsztdWn4t t fk r}ztd|W5d}~XYnX|jtjkr4t d|dnW5d}~XYnXdS)zAdd a handler for a signal. UNIX only. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. z3coroutines cannot be used with add_signal_handler()NFset_wakeup_fd(-1) failed: %ssig  cannot be caught)rZ iscoroutineZiscoroutinefunction TypeError _check_signalZ _check_closedsignal set_wakeup_fdZ_csockfileno ValueErrorOSError RuntimeErrorstrrZHandlerr siginterruptr infoerrnoEINVAL)rr/callbackargsexchandleZnexcrrradd_signal_handlerNs2    z)_UnixSelectorEventLoop.add_signal_handlercCs8|j|}|dkrdS|jr*||n ||dS)z2Internal helper that is the actual signal handler.N)rgetZ _cancelledr)Z_add_callback_signalsafe)rr/rGrrrr0{s   z%_UnixSelectorEventLoop._handle_signalc Cs||z |j|=Wntk r,YdSX|tjkr@tj}ntj}zt||WnBtk r}z$|jtj krt d|dnW5d}~XYnX|jszt dWn2t tfk r}zt d|W5d}~XYnXdS)zwRemove a handler for a signal. UNIX only. Return True if a signal handler was removed, False if not. Fr5r6Nr3r4T)r8rKeyErrorr9SIGINTdefault_int_handlerSIG_DFLr=rBrCr>r:r<r rA)rr/handlerrFrrrr)s(    z,_UnixSelectorEventLoop.remove_signal_handlercCs6t|tstd||tkr2td|dS)zInternal helper to validate a signal. Raise ValueError if the signal number is invalid or uncatchable. Raise RuntimeError if there is a problem setting up the handler. zsig must be an int, not zinvalid signal number N) isinstanceintr7r9 valid_signalsr<r.rrrr8s  z$_UnixSelectorEventLoop._check_signalcCst|||||Sr)_UnixReadPipeTransportrpipeprotocolwaiterextrarrr_make_read_pipe_transportsz0_UnixSelectorEventLoop._make_read_pipe_transportcCst|||||Sr)_UnixWritePipeTransportrSrrr_make_write_pipe_transportsz1_UnixSelectorEventLoop._make_write_pipe_transportc st} | std|} t||||||||f| |d| } | | |j| z| IdHWnDt t fk rYn,t k r| | IdHYnXW5QRX| S)NzRasyncio.get_child_watcher() is not activated, subprocess support is not installed.)rVrW)rget_child_watcher is_activer> create_future_UnixSubprocessTransportadd_child_handlerZget_pid_child_watcher_callback SystemExitKeyboardInterrupt BaseExceptionr%Z_wait) rrUrEshellstdinstdoutstderrbufsizerWkwargswatcherrVtransprrr_make_subprocess_transports8   z1_UnixSelectorEventLoop._make_subprocess_transportcCs||j|dSr)call_soon_threadsafeZ_process_exited)rpid returncoderkrrrr`sz._UnixSelectorEventLoop._child_watcher_callback)sslsockserver_hostnamessl_handshake_timeoutc s |r|dkr6tdn |dk r&td|dk r6td|dk r|dk rNtdt|}ttjtjd}z |d|||IdHWq|YqXn@|dkrtd|j tjks|j tjkrtd||d|j |||||d IdH\}}||fS) Nz/you have to pass server_hostname when using sslz+server_hostname is only meaningful with ssl1ssl_handshake_timeout is only meaningful with ssl3path and sock can not be specified at the same timerFzno path and sock were specified.A UNIX Domain Stream Socket was expected, got )rs) r<osfspathsocketAF_UNIX SOCK_STREAM setblockingZ sock_connectr%familytypeZ_create_connection_transport) rprotocol_factorypathrprqrrrs transportrUrrrcreate_unix_connectionsR      z-_UnixSelectorEventLoop.create_unix_connectiondT)rqbacklogrprs start_servingc st|trtd|dk r&|s&td|dk rH|dk r@tdt|}ttjtj}|ddkrz t t |j rt |WnBt k rYn0tk r}ztd||W5d}~XYnXz||Wnltk r0} z8|| jtjkrd|d} ttj| dnW5d} ~ XYn|YnXn<|dkrZtd |jtjksv|jtjkrtd ||d t||g||||} |r| tjd|d IdH| S) Nz*ssl argument must be an SSLContext or Nonertrur)rz2Unable to check or remove stale UNIX socket %r: %rzAddress z is already in usez-path was not specified, and no sock specifiedrvF)loop)rOboolr7r<rwrxryrzr{statS_ISSOCKst_moderemoveFileNotFoundErrorr=r errorZbindr%rBZ EADDRINUSEr}r~r|rZServerZ_start_servingr sleep) rrrrqrrprsrerrrFmsgZserverrrrcreate_unix_serversn           z)_UnixSelectorEventLoop.create_unix_serverc sz tjWn,tk r6}ztdW5d}~XYnXz |}Wn2ttjfk rv}ztdW5d}~XYnXzt|j }Wn,t k r}ztdW5d}~XYnX|r|n|} | sdS| } | | d||||| d| IdHS)Nzos.sendfile() is not availableznot a regular filer) rwsendfileAttributeErrorrSendfileNotAvailableErrorr;ioUnsupportedOperationfstatst_sizer=r]_sock_sendfile_native_impl) rrqfileoffsetcountrFr;rZfsize blocksizefutrrr_sock_sendfile_nativeJs2    z,_UnixSelectorEventLoop._sock_sendfile_nativec Cs,|} |dk r|||r4||||dS|rd||}|dkrd||||||dSzt| |||} WnDttfk r|dkr| ||| | |j || |||||| Ynbt k rj} z|dk r| j t jkrt| tk rtdt j} | | _| } |dkrBtd} |||||| n|||||| W5d} ~ XYnttfk rYntk r} z|||||| W5d} ~ XYnjX| dkr||||||nD|| 7}|| 7}|dkr | ||| | |j || |||||| dS)Nrzsocket is not connectedzos.sendfile call failed)r; remove_writer cancelled_sock_sendfile_update_fileposZ set_resultrwrBlockingIOErrorInterruptedError_sock_add_cancellation_callbackZ add_writerrr=rBZENOTCONNr~ConnectionError __cause__rrZ set_exceptionrarbrc)rrZ registered_fdrqr;rrr total_sentfdZsentrFnew_excrrrrras               z1_UnixSelectorEventLoop._sock_sendfile_native_implcCs|dkrt||tjdSNr)rwlseekSEEK_SET)rr;rrrrrrsz4_UnixSelectorEventLoop._sock_sendfile_update_fileposcsfdd}||dS)Ncs&|r"}|dkr"|dS)Nr3)rr;r)rrrrqrrcbszB_UnixSelectorEventLoop._sock_add_cancellation_callback..cb)Zadd_done_callback)rrrqrrrrrsz6_UnixSelectorEventLoop._sock_add_cancellation_callback)N)NN)NN)N)N)N)__name__ __module__ __qualname____doc__rr%r2rHr0r)r8rXrZrlr`rrrrrr __classcell__rrr!rr/sH -       . CFrcseZdZdZdfdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e jfddZdddZddZddZZS) rRiNcst|||jd<||_||_||_||_d|_d|_ t |jj }t |st |st |sd|_d|_d|_tdt |jd|j|jj||j|jj|j|j|dk r|jtj|ddS)NrTFz)Pipe transport is for pipes/sockets only.)rr_extra_loop_piper;_fileno _protocol_closing_pausedrwrrrS_ISFIFOrS_ISCHRr< set_blocking call_soonconnection_made _add_reader _read_readyr _set_result_unless_cancelled)rrrTrUrVrWmoder!rrrs:      z_UnixReadPipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dq|dn |jdk r|dn |dd d |S) Nclosedclosingfd= _selectorpollingidleopen<{}> )r"rrappendrrgetattrrr _test_selector_event selectorsZ EVENT_READformatjoin)rrAr rrrr__repr__s(         z_UnixReadPipeTransport.__repr__c Cszt|j|j}WnDttfk r,Yntk rX}z||dW5d}~XYn^X|rl|j |nJ|j rt d|d|_|j |j|j |jj|j |jddS)Nz"Fatal read error on pipe transport%r was closed by peerT)rwreadrmax_sizerrr= _fatal_errorrZ data_receivedr get_debugr rAr_remove_readerrZ eof_received_call_connection_lost)rr1rFrrrrs  z"_UnixReadPipeTransport._read_readycCs>|js |jrdSd|_|j|j|jr:td|dS)NTz%r pauses reading)rrrrrrr debugrrrr pause_readings   z$_UnixReadPipeTransport.pause_readingcCsB|js |jsdSd|_|j|j|j|jr>td|dS)NFz%r resumes reading) rrrrrrrr rrrrrresume_readings   z%_UnixReadPipeTransport.resume_readingcCs ||_dSrrrrUrrr set_protocol sz#_UnixReadPipeTransport.set_protocolcCs|jSrrrrrr get_protocolsz#_UnixReadPipeTransport.get_protocolcCs|jSrrrrrr is_closingsz!_UnixReadPipeTransport.is_closingcCs|js|ddSr)r_closerrrrr%sz_UnixReadPipeTransport.closecCs,|jdk r(|d|t|d|jdSNzunclosed transport r#rr,r%r_warnrrr__del__s z_UnixReadPipeTransport.__del__Fatal error on pipe transportcCsZt|tr4|jtjkr4|jrLtjd||ddn|j||||j d| |dSNz%r: %sTexc_info)message exceptionrrU) rOr=rBZEIOrrr rcall_exception_handlerrrrrFrrrrrs z#_UnixReadPipeTransport._fatal_errorcCs(d|_|j|j|j|j|dSNT)rrrrrrrrFrrrr-sz_UnixReadPipeTransport._closecCs4z|j|W5|jd|_d|_d|_XdSrrr%rrZconnection_lostrrrrr2s  z,_UnixReadPipeTransport._call_connection_lost)NN)r)rrrrrrrrrrrrr%r*r+rrrrrrrr!rrRs rRcseZdZd%fdd ZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZejfddZddZd&dd Zd'd!d"Zd#d$ZZS)(rYNc st||||jd<||_||_||_t|_d|_ d|_ t |jj }t|}t|}t|} |s|s| sd|_d|_d|_tdt |jd|j|jj|| s|rtjds|j|jj|j|j|dk r|jtj|ddS)NrTrFz?Pipe transport is only for pipes, sockets and character devicesZaix)rrrrr;rr bytearray_buffer _conn_lostrrwrrrrrrr<rrrrr&platform startswithrrr r) rrrTrUrVrWrZis_charZis_fifoZ is_socketr!rrr?s:        z _UnixWritePipeTransport.__init__cCs|jjg}|jdkr |dn|jr0|d|d|jt|jdd}|jdk r|dk rt ||jt j }|r|dn |d| }|d|n |jdk r|dn |dd d |S) Nrrrrrrzbufsize=rrr)r"rrrrrrrr rrZ EVENT_WRITEget_write_buffer_sizerr)rrAr rrhrrrrds,         z _UnixWritePipeTransport.__repr__cCs t|jSr)lenrrrrrr|sz-_UnixWritePipeTransport.get_write_buffer_sizecCs6|jrtd||jr*|tn|dS)Nr)rrr rArrBrokenPipeErrorrrrrrs   z#_UnixWritePipeTransport._read_readyc Cs4t|trt|}|sdS|js&|jrN|jtjkr|}d}td|Yn.X|dkrLdSt|}|jrlt d||z|j |\}}Wn.t k r|jrtjd|ddYnX|||f|dS)N8Unknown child process pid %d, will report returncode 255r$process %s exited with returncode %s'Child watcher got an unexpected pid: %rTr) rwwaitpidWNOHANGChildProcessErrorr rr$rrrr&poprJ)rr'rnr#rorDrErrrr(s4    zSafeChildWatcher._do_waitpid) rrrrr%rrr_rr)r(rrrr!rrs rcsTeZdZdZfddZfddZddZdd Zd d Zd d Z ddZ Z S)raW'Fast' child watcher implementation. This implementation reaps every terminated processes by calling os.waitpid(-1) directly, possibly breaking other code spawning processes and waiting for their termination. There is no noticeable overhead when handling a big number of children (O(1) each time a child terminates). cs$tt|_i|_d|_dSr)rr threadingZLock_lock_zombies_forksrr!rrrs  zFastChildWatcher.__init__cs"|j|jtdSr)r&r-r;rr%rr!rrr%s  zFastChildWatcher.closec Cs0|j |jd7_|W5QRSQRXdS)Nr)r:r<rrrrrszFastChildWatcher.__enter__c Cs^|jB|jd8_|js"|js0W5QRdSt|j}|jW5QRXtd|dS)Nrz5Caught subprocesses termination from unknown pids: %s)r:r<r;r?r-r r)rrrrZcollateral_victimsrrrrs  zFastChildWatcher.__exit__c Gsf|jFz|j|}Wn.tk rF||f|j|<YW5QRdSXW5QRX|||f|dSr)r:r;r8rJr&)rrnrDrErorrrr_'sz"FastChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr.r/rrrrr5s z%FastChildWatcher.remove_child_handlerc Csztdtj\}}Wntk r,YdSX|dkr:dSt|}|jz|j|\}}WnNtk r|j r||j |<|j rt d||YW5QRqd}YnX|j rt d||W5QRX|dkrt d||q|||f|qdS)Nr3rz,unknown process %s exited with returncode %sr3z8Caught subprocess termination from unknown pid: %d -> %d)rwr5r6r7r$r:r&r8rJr<r;rrr rr)rrnr#rorDrErrrr)<s@    z FastChildWatcher._do_waitpid_all) rrrrrr%rrr_rr)rrrr!rrs  rc@sheZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZdS)ra~A watcher that doesn't require running loop in the main thread. This implementation registers a SIGCHLD signal handler on instantiation (which may conflict with other code that install own handler for this signal). The solution is safe but it has a significant overhead when handling a big number of processes (*O(n)* each time a SIGCHLD is received). cCsi|_d|_dSr)r&_saved_sighandlerrrrrrzszMultiLoopChildWatcher.__init__cCs |jdk Sr)r=rrrrr\~szMultiLoopChildWatcher.is_activecCsT|j|jdkrdSttj}||jkr:tdnttj|jd|_dS)Nz+SIGCHLD handler was changed by outside code) r&r-r=r9 getsignalr+r,r r)rrNrrrr%s     zMultiLoopChildWatcher.closecCs|SrrrrrrrszMultiLoopChildWatcher.__enter__cCsdSrrrexc_typeZexc_valZexc_tbrrrrszMultiLoopChildWatcher.__exit__cGs&t}|||f|j|<||dSr)rget_running_loopr&r()rrnrDrErrrrr_sz'MultiLoopChildWatcher.add_child_handlercCs*z|j|=WdStk r$YdSXdSr.r/rrrrrs z*MultiLoopChildWatcher.remove_child_handlercCsN|jdk rdSttj|j|_|jdkrsz6ThreadedChildWatcher._join_threads..N)r(rFvaluesr)rthreadsrLrrrrGsz"ThreadedChildWatcher._join_threadscCs|SrrrrrrrszThreadedChildWatcher.__enter__cCsdSrrr?rrrrszThreadedChildWatcher.__exit__cCs6ddt|jD}|r2||jdt|ddS)NcSsg|]}|r|qSr)rHrJrrrrM sz0ThreadedChildWatcher.__del__..z0 has registered but not finished child processesr#)r(rFrNr"r,)rrrOrrrrs  zThreadedChildWatcher.__del__cGsFt}tj|jdt|j||||fdd}||j|<|dS)Nzwaitpid-T)targetnamerErI) rrAr9ZThreadr(nextrErFstart)rrnrDrErrLrrrr_s  z&ThreadedChildWatcher.add_child_handlercCsdSrrrrrrrsz)ThreadedChildWatcher.remove_child_handlercCsdSrrrrrrrsz ThreadedChildWatcher.attach_loopcCszt|d\}}Wn(tk r<|}d}td|Yn Xt|}|r\td|||rttd||n|j |||f||j |dS)Nrr1r2r3rB) rwr5r7r rr$rrrCrmrFr8)rrr'rDrErnr#rorrrr("s& z ThreadedChildWatcher._do_waitpidN)rrrrrr\r%rGrrr*r+rr_rrr(rrrrrs  rcsHeZdZdZeZfddZddZfddZdd Z d d Z Z S) _UnixDefaultEventLoopPolicyz:UNIX event loop policy with a watcher for child processes.cstd|_dSr)rr_watcherrr!rrrAs z$_UnixDefaultEventLoopPolicy.__init__c CsHtj8|jdkr:t|_tttjr:|j|j j W5QRXdSr) rr:rUrrOr9current_thread _MainThreadr_localrrrrr _init_watcherEs z)_UnixDefaultEventLoopPolicy._init_watchercs6t||jdk r2tttjr2|j|dS)zSet the event loop. As a side effect, if a child watcher was set before, then calling .set_event_loop() from the main thread will call .attach_loop(loop) on the child watcher. N)rset_event_looprUrOr9rVrWrrr!rrrZMs   z*_UnixDefaultEventLoopPolicy.set_event_loopcCs|jdkr||jS)z~Get the watcher for child processes. If not yet set, a ThreadedChildWatcher object is automatically created. N)rUrYrrrrr[[s z-_UnixDefaultEventLoopPolicy.get_child_watchercCs|jdk r|j||_dS)z$Set the watcher for child processes.N)rUr%)rrjrrrset_child_watcheres  z-_UnixDefaultEventLoopPolicy.set_child_watcher) rrrrrZ _loop_factoryrrYrZr[r[rrrr!rrT=s   rT)2rrBrrDrwrr9ryrr r&r9r*rrrrrrr r r r logr __all__r ImportErrorrZBaseSelectorEventLooprZ ReadTransportrRZ_FlowControlMixinZWriteTransportrYZBaseSubprocessTransportr^rr$r%rrrrZBaseDefaultEventLoopPolicyrTrrrrrrs`             NO5Ji}Y3__pycache__/base_tasks.cpython-38.opt-2.pyc000064400000003632152343727170014502 0ustar00U e5d @sDddlZddlZddlmZddlmZddZddZd d ZdS) N) base_futures) coroutinescCsnt|}|jrd|d<|dd|t|j}|dd|d|jdk rj|dd |j|S) NZ cancellingrrzname=%rzcoro=<>z wait_for=) rZ_future_repr_infoZ _must_cancelinsertZget_namerZ_format_coroutine_coroZ _fut_waiter)taskinfocoror */usr/lib64/python3.8/asyncio/base_tasks.py_task_repr_infos   rcCsg}t|jdr|jj}n0t|jdr0|jj}nt|jdrF|jj}nd}|dk r|dk r|dk rt|dkrlq|d8}|||j}qR|nH|jdk r|jj }|dk r|dk r|dkrq|d8}||j |j }q|S)Ncr_framegi_frameag_framerr) hasattrr rrrappendf_backreverse _exception __traceback__tb_frametb_next)r limitZframesftbr r r_task_get_stacks6          rc Csg}t}|j|dD]Z}|j}|j}|j}|j} ||krN||t|t |||j } | ||| | fq|j } |st d||dn2| dk rt d|d|dnt d|d|dtj||d| dk rt| j| D]} t | |ddqdS) N)rz No stack for )filezTraceback for z (most recent call last):z Stack for )rend)setZ get_stackf_linenof_code co_filenameco_nameadd linecache checkcachegetline f_globalsrrprint traceback print_listformat_exception_only __class__) r rrextracted_listcheckedrlinenocofilenamenamelineexcr r r_task_print_stack<s,  r9)r(r-r rrrrr9r r r rs   #__pycache__/base_subprocess.cpython-38.opt-2.pyc000064400000022006152343727170015541 0ustar00U e5d"@sxddlZddlZddlZddlmZddlmZddlmZGdddejZ Gdd d ej Z Gd d d e ej Z dS) N) protocols) transports)loggercseZdZd0fdd 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 s&t| d|_||_||_d|_d|_d|_g|_t |_ i|_ d|_ |tjkr`d|j d<|tjkrtd|j d<|tjkrd|j d<z"|jf||||||d| Wn|YnX|jj|_|j|jd<|jrt|ttfr|} 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__//usr/lib64/python3.8/asyncio/base_subprocess.pyr sL            z BaseSubprocessTransport.__init__cCs|jjg}|jr|d|jdk r6|d|j|jdk rT|d|jn |jdk rj|dn |d|jd}|dk r|d|j|jd}|jd }|dk r||kr|d |jn6|dk r|d |j|dk r |d |jd d |S)Nclosedzpid=z returncode=Zrunningz not startedrzstdin=rrzstdout=stderr=zstdout=zstderr=z<{}> ) r-__name__rappendrrrgetpipeformatjoin)r'infor r r r.r.r/__repr__7s,           z BaseSubprocessTransport.__repr__cKstdSN)NotImplementedError)r'rr r r r r r+r.r.r/rTszBaseSubprocessTransport._startcCs ||_dSr:r)r'r)r.r.r/ set_protocolWsz$BaseSubprocessTransport.set_protocolcCs|jSr:r<r'r.r.r/ get_protocolZsz$BaseSubprocessTransport.get_protocolcCs|jSr:)rr>r.r.r/ is_closing]sz"BaseSubprocessTransport.is_closingcCs|jr dSd|_|jD]}|dkr(q|jq|jdk r|jdkr|jdkr|j rlt d|z|j Wnt k rYnXdS)NTz$Close running child process: kill %r)rrvaluesr5rrrZpollrr!rZwarningkillProcessLookupError)r'protor.r.r/r`s$     zBaseSubprocessTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rResourceWarningr)r'Z_warnr.r.r/__del__{szBaseSubprocessTransport.__del__cCs|jSr:)rr>r.r.r/get_pidszBaseSubprocessTransport.get_pidcCs|jSr:)rr>r.r.r/get_returncodesz&BaseSubprocessTransport.get_returncodecCs||jkr|j|jSdSdSr:)rr5)r'fdr.r.r/get_pipe_transports  z*BaseSubprocessTransport.get_pipe_transportcCs|jdkrtdSr:)rrCr>r.r.r/ _check_procs z#BaseSubprocessTransport._check_proccCs||j|dSr:)rLr send_signal)r'signalr.r.r/rMsz#BaseSubprocessTransport.send_signalcCs||jdSr:)rLr terminater>r.r.r/rOsz!BaseSubprocessTransport.terminatecCs||jdSr:)rLrrBr>r.r.r/rBszBaseSubprocessTransport.killc s`zj}j}|jdk rB|fdd|jIdH\}}|jd<|jdk rv|fdd|jIdH\}}|jd<|jdk r|fdd|jIdH\}}|jd<|j j j D]\}}|j|f|qd_ WnZt t fk rYn`tk r<}z"|dk r,|s,||W5d}~XYn X|dk r\|s\|ddS)Ncs tdS)Nr)WriteSubprocessPipeProtor.r>r.r/z8BaseSubprocessTransport._connect_pipes..rcs tdS)NrReadSubprocessPipeProtor.r>r.r/rQrRrcs tdS)NrrSr.r>r.r/rQrRr)rrr Zconnect_write_piperr Zconnect_read_piper call_soonrconnection_mader SystemExitKeyboardInterrupt BaseException cancelledZ set_exception set_result) r'r*procr(_r5callbackdataexcr.r>r/r&s@          z&BaseSubprocessTransport._connect_pipescGs2|jdk r|j||fn|jj|f|dSr:)rr3rrU)r'cbr_r.r.r/_calls zBaseSubprocessTransport._callcCs||jj|||dSr:)rbrZpipe_connection_lost _try_finish)r'rJr`r.r.r/_pipe_connection_lostsz-BaseSubprocessTransport._pipe_connection_lostcCs||jj||dSr:)rbrZpipe_data_received)r'rJr_r.r.r/_pipe_data_receivedsz+BaseSubprocessTransport._pipe_data_receivedcCsp|jrtd||||_|jjdkr2||j_||jj | |j D]}| sN| |qNd|_ dS)Nz%r exited with return code %r)rr!rr8rr returncoderbrZprocess_exitedrcrrZr[)r'rfr*r.r.r/_process_exiteds    z'BaseSubprocessTransport._process_exitedcs0|jdk r|jS|j}|j||IdHSr:)rrZ create_futurerr3)r'r*r.r.r/_waits    zBaseSubprocessTransport._waitcCs>|jdkrdStdd|jDr:d|_||jddS)Ncss|]}|dk o|jVqdSr:) disconnected).0pr.r.r/ sz6BaseSubprocessTransport._try_finish..T)rallrrArrb_call_connection_lostr>r.r.r/rcs z#BaseSubprocessTransport._try_finishcCs*z|j|W5d|_d|_d|_XdSr:)rrrconnection_lostr'r`r.r.r/rns z-BaseSubprocessTransport._call_connection_lost)NN)r2 __module__ __qualname__rr9rr=r?r@rwarningswarnrGrHrIrKrLrMrOrBr&rbrdrergrhrcrn __classcell__r.r.r,r/r s2+&  rc@s<eZdZddZddZddZddZd d Zd d Zd S)rPcCs||_||_d|_d|_dS)NF)r\rJr5ri)r'r\rJr.r.r/rsz!WriteSubprocessPipeProto.__init__cCs ||_dSr:)r5)r'Z transportr.r.r/rVsz(WriteSubprocessPipeProto.connection_madecCs d|jjd|jd|jdS)N)r-r2rJr5r>r.r.r/r9 sz!WriteSubprocessPipeProto.__repr__cCs d|_|j|j|d|_dS)NT)rir\rdrJrpr.r.r/ro sz(WriteSubprocessPipeProto.connection_lostcCs|jjdSr:)r\r pause_writingr>r.r.r/rxsz&WriteSubprocessPipeProto.pause_writingcCs|jjdSr:)r\rresume_writingr>r.r.r/rysz'WriteSubprocessPipeProto.resume_writingN) r2rqrrrrVr9rorxryr.r.r.r/rPs rPc@seZdZddZdS)rTcCs|j|j|dSr:)r\rerJ)r'r_r.r.r/ data_receivedsz%ReadSubprocessPipeProto.data_receivedN)r2rqrrrzr.r.r.r/rTsrT)rrrsrrlogrZSubprocessTransportrZ BaseProtocolrPZProtocolrTr.r.r.r/s   v __pycache__/sslproto.cpython-38.pyc000064400000052164152343727170013314 0ustar00U e5dJj@sddlZddlZz ddlZWnek r4dZYnXddlmZddlmZddlmZddlmZddl m Z dd Z d Z d Z d Zd ZGdddeZGdddejejZGdddejZdS)N) base_events) constants) protocols) transports)loggercCs"|r tdt}|sd|_|S)Nz(Server side SSL needs a valid SSLContextF) ValueErrorsslZcreate_default_contextZcheck_hostname) server_sideserver_hostname sslcontextr (/usr/lib64/python3.8/asyncio/sslproto.py_create_transport_contexts rZ UNWRAPPEDZ DO_HANDSHAKEZWRAPPEDZSHUTDOWNc@s~eZdZdZdZdddZeddZedd Zed d Z ed d Z dddZ dddZ ddZ dddZdddZdS)_SSLPipeaAn SSL "Pipe". An SSL pipe allows you to communicate with an SSL/TLS protocol instance through memory buffers. It can be used to implement a security layer for an existing connection where you don't have access to the connection's file descriptor, or for some reason you don't want to use it. An SSL pipe can be in "wrapped" and "unwrapped" mode. In unwrapped mode, data is passed through untransformed. In wrapped mode, application level data is encrypted to SSL record level data and vice versa. The SSL record level is the lowest level in the SSL protocol suite and is what travels as-is over the wire. An SslPipe initially is in "unwrapped" mode. To start SSL, call do_handshake(). To shutdown SSL again, call unwrap(). iNcCsH||_||_||_t|_t|_t|_d|_ d|_ d|_ d|_ dS)a The *context* argument specifies the ssl.SSLContext to use. The *server_side* argument indicates whether this is a server side or client side transport. The optional *server_hostname* argument can be used to specify the hostname you are connecting to. You may only specify this parameter if the _ssl module supports Server Name Indication (SNI). NF) _context _server_side_server_hostname _UNWRAPPED_stater Z MemoryBIO _incoming _outgoing_sslobj _need_ssldata _handshake_cb _shutdown_cb)selfcontextr r r r r__init__8s   z_SSLPipe.__init__cCs|jS)z*The SSL context passed to the constructor.)rrr r rrNsz_SSLPipe.contextcCs|jS)z^The internal ssl.SSLObject instance. Return None if the pipe is not wrapped. )rrr r r ssl_objectSsz_SSLPipe.ssl_objectcCs|jS)zgWhether more record level data is needed to complete a handshake that is currently in progress.)rrr r r need_ssldata[sz_SSLPipe.need_ssldatacCs |jtkS)zj Whether a security layer is currently in effect. Return False during handshake. )r_WRAPPEDrr r rwrappedasz_SSLPipe.wrappedcCsb|jtkrtd|jj|j|j|j|jd|_ t |_||_ |j ddd\}}t |dks^t|S)aLStart the SSL handshake. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the handshake is complete. The callback will be called with None if successful, else an exception instance. z"handshake in progress or completed)r r T)only_handshaker)rr RuntimeErrorrZwrap_biorrrrr _DO_HANDSHAKEr feed_ssldatalenAssertionErrorrcallbackssldataappdatar r r do_handshakejs z_SSLPipe.do_handshakecCsj|jtkrtd|jtkr$td|jttfks6tt|_||_|d\}}|gksf|dgksft|S)a1Start the SSL shutdown sequence. Return a list of ssldata. A ssldata element is a list of buffers The optional *callback* argument can be used to install a callback that will be called when the shutdown is complete. The callback will be called without arguments. zno security layer presentzshutdown in progressr$) rrr& _SHUTDOWNr"r'r*rr(r+r r rshutdowns  z_SSLPipe.shutdowncCs2|j|d\}}|gks.|dgks.tdS)zSend a potentially "ragged" EOF. This method will raise an SSL_ERROR_EOF exception if the EOF is unexpected. r$N)rZ write_eofr(r*)rr-r.r r rfeed_eofs z_SSLPipe.feed_eofFc Cs|jtkr"|r|g}ng}g|fSd|_|r8|j|g}g}z|jtkrz|jt|_|j rl| d|rz||fWS|jtkr|j |j }| ||sqqnJ|jt kr|jd|_t|_|jr|n|jtkr| |j Wnztjtjfk rl}zRt|dd}|tjtjtjfkrP|jtkrN|j rN| ||tjk|_W5d}~XYnX|jjr| |j ||fS)aFeed SSL record level data into the pipe. The data must be a bytes instance. It is OK to send an empty bytes instance. This can be used to get ssldata for a handshake initiated by this endpoint. Return a (ssldata, appdata) tuple. The ssldata element is a list of buffers containing SSL data that needs to be sent to the remote SSL. The appdata element is a list of buffers containing plaintext data that needs to be forwarded to the application. The appdata list may contain an empty buffer indicating an SSL "close_notify" alert. This alert must be acknowledged by calling shutdown(). FNerrno)rrrrwriter'rr/r"rreadmax_sizeappendr0Zunwraprr SSLErrorCertificateErrorgetattrSSL_ERROR_WANT_READSSL_ERROR_WANT_WRITESSL_ERROR_SYSCALLrpending)rdatar%r.r-chunkexc exc_errnor r rr(sZ               z_SSLPipe.feed_ssldatarc Cs4d|krt|ksnt|jtkrT|t|krD||dg}ng}|t|fSg}t|}d|_z(|t|kr||j||d7}Wnhtj k r}zHt |dd}|j dkrtj }|_ |tj tjtjfkrڂ|tj k|_W5d}~XYnX|jjr||j|t|ks,|jr`q,q`||fS)a Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. rNFr3ZPROTOCOL_IS_SHUTDOWN)r)r*rr memoryviewrrr4r r8r:reasonr;r3r<r=rr>r7r5)rr?offsetr-ZviewrArBr r r feed_appdatas6        z_SSLPipe.feed_appdata)N)N)N)F)r)__name__ __module__ __qualname____doc__r6rpropertyrr r!r#r/r1r2r(rFr r r rr$s         Krc@seZdZejjZddZd"ddZddZ dd Z d d Z d d Z e jfddZddZddZddZd#ddZddZeddZddZddZd d!ZdS)$_SSLProtocolTransportcCs||_||_d|_dS)NF)_loop _ssl_protocol_closed)rloopZ ssl_protocolr r rr!sz_SSLProtocolTransport.__init__NcCs|j||S)z#Get optional transport information.)rN_get_extra_infornamedefaultr r rget_extra_info'sz$_SSLProtocolTransport.get_extra_infocCs|j|dSN)rN_set_app_protocol)rprotocolr r r set_protocol+sz"_SSLProtocolTransport.set_protocolcCs|jjSrV)rN _app_protocolrr r r get_protocol.sz"_SSLProtocolTransport.get_protocolcCs|jSrV)rOrr r r is_closing1sz _SSLProtocolTransport.is_closingcCsd|_|jdS)a Close the transport. Buffered data will be flushed asynchronously. No more data will be received. After all buffered data is flushed, the protocol's connection_lost() method will (eventually) called with None as its argument. TN)rOrN_start_shutdownrr r rclose4sz_SSLProtocolTransport.closecCs&|js"|d|t|d|dS)Nzunclosed transport )source)rOResourceWarningr^)rZ_warnr r r__del__?sz_SSLProtocolTransport.__del__cCs |jj}|dkrtd|S)Nz*SSL transport has not been initialized yet)rN _transportr& is_reading)rZtrr r rrcDsz _SSLProtocolTransport.is_readingcCs|jjdS)zPause the receiving end. No data will be passed to the protocol's data_received() method until resume_reading() is called. N)rNrb pause_readingrr r rrdJsz#_SSLProtocolTransport.pause_readingcCs|jjdS)zResume the receiving end. Data received will once again be passed to the protocol's data_received() method. N)rNrbresume_readingrr r rreRsz$_SSLProtocolTransport.resume_readingcCs|jj||dS)aSet the high- and low-water limits for write flow control. These two values control when to call the protocol's pause_writing() and resume_writing() methods. If specified, the low-water limit must be less than or equal to the high-water limit. Neither value can be negative. The defaults are implementation-specific. If only the high-water limit is given, the low-water limit defaults to an implementation-specific value less than or equal to the high-water limit. Setting high to zero forces low to zero as well, and causes pause_writing() to be called whenever the buffer becomes non-empty. Setting low to zero causes resume_writing() to be called only once the buffer is empty. Use of zero for either limit is generally sub-optimal as it reduces opportunities for doing I/O and computation concurrently. N)rNrbset_write_buffer_limits)rZhighZlowr r rrfZsz-_SSLProtocolTransport.set_write_buffer_limitscCs |jjS)z,Return the current size of the write buffer.)rNrbget_write_buffer_sizerr r rrgosz+_SSLProtocolTransport.get_write_buffer_sizecCs |jjjSrV)rNrb_protocol_pausedrr r rrhssz&_SSLProtocolTransport._protocol_pausedcCs<t|tttfs$tdt|j|s,dS|j|dS)zWrite some data bytes to the transport. This does not block; it buffers the data and arranges for it to be sent out asynchronously. z+data: expecting a bytes-like instance, got N) isinstancebytes bytearrayrC TypeErrortyperGrN_write_appdatarr?r r rr4xs z_SSLProtocolTransport.writecCsdS)zAReturn True if this transport supports write_eof(), False if not.Fr rr r r can_write_eofsz#_SSLProtocolTransport.can_write_eofcCs|jd|_dS)zClose the transport immediately. Buffered data will be lost. No more data will be received. The protocol's connection_lost() method will (eventually) be called with None as its argument. TN)rN_abortrOrr r raborts z_SSLProtocolTransport.abort)N)NN)rGrHrIrZ _SendfileModeZFALLBACKZ_sendfile_compatiblerrUrYr[r\r^warningswarnrarcrdrerfrgrKrhr4rprrr r r rrLs$     rLc@seZdZdZd,ddZddZd-d d Zd d Zd dZddZ ddZ ddZ ddZ d.ddZ ddZddZddZdd Zd!d"Zd#d$Zd/d&d'Zd(d)Zd*d+ZdS)0 SSLProtocolzSSL protocol. Implementation of SSL on top of a socket using incoming and outgoing buffers which are ssl.MemoryBIO objects. FNTc Cstdkrtd|dkr tj}n|dkr6td||sDt||}||_|rZ|sZ||_nd|_||_t |d|_ t |_ d|_||_||_||t|j||_d|_d|_d|_d|_d|_||_||_dS)Nzstdlib ssl module not availablerz7ssl_handshake_timeout should be a positive number, got )r F)r r&rZSSL_HANDSHAKE_TIMEOUTrrrr _sslcontextdict_extra collectionsdeque_write_backlog_write_buffer_size_waiterrMrWrL_app_transport_sslpipe_session_established _in_handshake _in_shutdownrb_call_connection_made_ssl_handshake_timeout) rrP app_protocolr Zwaiterr r Zcall_connection_madeZssl_handshake_timeoutr r rrs@   zSSLProtocol.__init__cCs||_t|tj|_dSrV)rZrirZBufferedProtocol_app_protocol_is_buffer)rrr r rrWs zSSLProtocol._set_app_protocolcCsD|jdkrdS|js:|dk r.|j|n |jdd|_dSrV)r}Z cancelledZ set_exceptionZ set_resultrrAr r r_wakeup_waiters   zSSLProtocol._wakeup_waitercCs&||_t|j|j|j|_|dS)zXCalled when the low-level connection is made. Start the SSL handshake. N)rbrrvrrr_start_handshake)r transportr r rconnection_mades zSSLProtocol.connection_madecCsn|jr d|_|j|jj|n|jdk r2d|j_d|_d|_t|ddrT|j | |d|_d|_ dS)zCalled when the low-level connection is lost or closed. The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed). FNT_handshake_timeout_handle) rrM call_soonrZconnection_lostr~rOrbr:rcancelrrrr r rrs    zSSLProtocol.connection_lostcCs|jdS)z\Called when the low-level transport's buffer goes over the high-water mark. N)rZ pause_writingrr r rrszSSLProtocol.pause_writingcCs|jdS)z^Called when the low-level transport's buffer drains below the low-water mark. N)rZresume_writingrr r rrszSSLProtocol.resume_writingc Cs"|jdkrdSz|j|\}}WnLttfk r<Yn4tk rn}z||dWYdSd}~XYnX|D]}|j|qt|D]}|rz&|jrt |j |n |j |WnPttfk rYn8tk r }z||dWYdSd}~XYnXq| qqdS)zXCalled when some SSL data is received. The argument is a bytes object. NzSSL error in data receivedz/application protocol failed to receive SSL data)rr( SystemExitKeyboardInterrupt BaseException _fatal_errorrbr4rrZ_feed_data_to_buffered_protorZ data_receivedr])rr?r-r.er@Zexr r rrs<  zSSLProtocol.data_receivedcCsTzB|jrtd||t|js@|j }|r@t dW5|jXdS)aCalled when the other end of the low-level stream is half-closed. If this returns a false value (including None), the transport will close itself. If it returns a true value, closing the transport is up to the protocol. z%r received EOFz?returning true from eof_received() has no effect when using sslN) rbr^rM get_debugrdebugrConnectionResetErrorrrZ eof_receivedZwarning)rZ keep_openr r rr-s    zSSLProtocol.eof_receivedcCs4||jkr|j|S|jdk r,|j||S|SdSrV)rxrbrUrRr r rrQCs    zSSLProtocol._get_extra_infocCs.|jr dS|jr|nd|_|ddS)NTr$)rrrqrnrr r rr]Ks  zSSLProtocol._start_shutdowncCs.|j|df|jt|7_|dS)Nr)r{r7r|r)_process_write_backlogror r rrnTszSSLProtocol._write_appdatacCs\|jr$td||j|_nd|_d|_|jd|j |j |j |_ | dS)Nz%r starts SSL handshakeT)r$r)rMrrrtime_handshake_start_timerr{r7Z call_laterr_check_handshake_timeoutrrrr r rrYs    zSSLProtocol._start_handshakecCs*|jdkr&d|jd}|t|dS)NTz$SSL handshake is taking longer than z! seconds: aborting the connection)rrrConnectionAbortedError)rmsgr r rrhs  z$SSLProtocol._check_handshake_timeoutc Csd|_|j|jj}z|dk r&||}Wnbttfk rJYnJtk r}z,t |t j rld}nd}| ||WYdSd}~XYnX|j r|j |j}td||d|jj||||d|jr|j|j|d|_|j |jdS)NFz1SSL handshake failed on verifying the certificatezSSL handshake failedz%r: SSL handshake took %.1f msg@@)peercertcipher compressionr T)rrrrr Z getpeercertrrrrir r9rrMrrrrrrxupdaterrrrZrr~rrrr)rZ handshake_excZsslobjrrArZdtr r r_on_handshake_completeqs8     z"SSLProtocol._on_handshake_completec CsP|jdks|jdkrdSztt|jD]}|jd\}}|rR|j||\}}n*|rj|j|j}d}n|j|j }d}|D]}|j |q|t|kr||f|jd<|jj st |jj r|jq|jd=|jt|8_q(Wn^ttfk rYnDtk rJ}z$|jr.||n ||dW5d}~XYnXdS)NrrzFatal error on SSL transport)rbrranger)r{rFr/rr1 _finalizer4r!r*Z_pausedrer|rrrrr)rir?rEr-r@rAr r rrs<    z"SSLProtocol._process_write_backlogFatal error on transportcCsVt|tr(|jr@tjd||ddn|j|||j|d|jrR|j|dS)Nz%r: %sT)exc_info)messageZ exceptionrrX) riOSErrorrMrrrZcall_exception_handlerrbZ _force_close)rrArr r rrs  zSSLProtocol._fatal_errorcCsd|_|jdk r|jdSrV)rrbr^rr r rrs zSSLProtocol._finalizecCs(z|jdk r|jW5|XdSrV)rrbrrrr r rrqs zSSLProtocol._abort)FNTN)N)N)r)rGrHrIrJrrWrrrrrrrrQr]rnrrrrrrrqr r r rrus0 .  &   )+ ru)ryrsr ImportErrorrrrrlogrrrr'r"r0objectrZ_FlowControlMixinZ TransportrLZProtocolrur r r rs*       yx__pycache__/base_futures.cpython-38.opt-2.pyc000064400000003156152343727170015053 0ustar00U e5d @sRdZddlZddlmZddlmZdZdZdZd d Z d d Z e Z d dZ dS)N) get_ident)format_helpersZPENDINGZ CANCELLEDZFINISHEDcCst|jdo|jdk S)N_asyncio_future_blocking)hasattr __class__r)objrr,/usr/lib64/python3.8/asyncio/base_futures.pyisfutures r cCst|}|sd}dd}|dkr2||dd}n`|dkr`d||dd||dd}n2|dkrd||dd|d||d d}d |d S) NcSs t|dS)Nr)rZ_format_callback_source)callbackrrr format_cbsz$_format_callbacks..format_cbrrz{}, {}z{}, <{} more>, {}zcb=[])lenformat)cbsizerrrr _format_callbackss&rc Cs|jg}|jtkr|jdk r4|d|jnTt|tf}|tkrPd}n(t|zt |j }W5t |X|d||j r|t|j |jr|jd}|d|dd|d|S) Nz exception=z...zresult=rz created at r:r)Z_statelower _FINISHEDZ _exceptionappendidr _repr_runningadddiscardreprlibreprZ_resultZ _callbacksrZ_source_traceback)Zfutureinfokeyresultframerrr _future_repr_info7s$      r%)__all__r_threadrr rZ_PENDINGZ _CANCELLEDrr rsetrr%rrrr s