fdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z Gdd ej Z Gd d Zdd d ZdZdS))RunnerrunN) coroutines)events) exceptions)tasksceZdZdZdZdZdS)_Statecreated initializedclosedN)__name__ __module__ __qualname__CREATED INITIALIZEDCLOSED6/opt/alt/python311/lib64/python3.11/asyncio/runners.pyr r sGK FFFrr cNeZdZ ddddZdZdZdZdZddd Zd Z d Z dS) rN)debug loop_factoryc|tj|_||_||_d|_d|_d|_d|_dS)NrF) r r_state_debug _loop_factory_loop_context_interrupt_count_set_event_loop)selfrrs r__init__zRunner.__init__1s>n  )  !$rc.||SN) _lazy_initr#s r __enter__zRunner.__enter__:s  rc.|dSr&)close)r#exc_typeexc_valexc_tbs r__exit__zRunner.__exit__>s rc" |jtjurdS |j}t ||||||jrtj d| d|_tj |_dS#|jrtj d| d|_tj |_wxYwr&) rr rr_cancel_all_tasksrun_until_completeshutdown_asyncgensshutdown_default_executorr"rset_event_loopr+r)r#loops rr+z Runner.closeAs, ;f0 0 0 F (:D d # # #  # #D$;$;$=$= > > >  # #D$B$B$D$D E E E# ,%d+++ JJLLLDJ -DKKK # ,%d+++ JJLLLDJ -DK ' ' ' 's A$CA Dc: ||jSr&)r'rr(s rget_loopzRunner.get_loopQs) zrcontextc tj|s"td|t jt d|||j}|j ||}tj tj urxtjtjtjurNt%j|j|} tjtj|n#t$rd}YnwxYwd}d|_ |j ||Jtjtj|ur+tjtjtjSSS#t.j$r<|jdkr/t3|dd}||dkrt5wxYw#|Jtjtj|ur+tjtjtjwwwxYw)Nz"a coroutine was expected, got {!r}z7Runner.run() cannot be called from a running event loopr9) main_taskruncancel)r iscoroutine ValueErrorformatr_get_running_loop RuntimeErrorr'r r create_task threadingcurrent_thread main_threadsignal getsignalSIGINTdefault_int_handler functoolspartial _on_sigintr!r2rCancelledErrorgetattrKeyboardInterrupt)r#coror:tasksigint_handlerr=s rrz Runner.runVs8=%d++ PAHHNNOO O  # % % 1IKK K  ?mGz%%dG%<<  $ & &)*?*A*A A A //63MMM&.t$OOON & fm^<<<< & & &"&  & "N ! I:0066*$V]33~EE fmV-GHHHH+E(   $q(("4T::'HHJJ!OO+---   *$V]33~EE fmV-GHHHH+Es,?D D.-D.;F""A G--G00AH?c|jtjurtd|jtjurdS|j@t j|_|j s t j |jd|_ n||_|j |j |j tj|_tj|_dS)NzRunner is closedT)rr rrBrrrnew_event_looprr"r5r set_debug contextvars copy_contextr r(s rr'zRunner._lazy_inits ;&- ' '122 2 ;&, , , F   %.00DJ' ,%dj111'+$++--DJ ; " J  - - -#022 ( rc|xjdz c_|jdkrE|s1||jddSt )NrcdSr&rrrrz#Runner._on_sigint..sDr)r!donecancelrcall_soon_threadsaferP)r#signumframer<s rrMzRunner._on_sigintsn "  A % %inn.>.> %       J + +LL 9 9 9 F!!!r) rrrr$r)r/r+r8rr'rMrrrrrs6!%4%%%%%(((  $(+I+I+I+I+IZ)))&"""""rrrc tjtdt|5}||cdddS#1swxYwYdS)Nz8asyncio.run() cannot be called from a running event loopra)rrArBrr)mainrrunners rrrs.!!- FHH H e    zz$                  sAAAcbtj|}|sdS|D]}||tj|ddi|D]V}|r|+|d||dWdS)Nreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)message exceptionrR)r all_tasksr]r2gather cancelledrhcall_exception_handler)r6 to_cancelrRs rr1r1s%%I  EL)LtLLMMM >>     >>   '  ' 'N!^^--))    r)__all__rWenumrKrDrGsysrrrr Enumr rrr1rrrrss&   TY H"H"H"H"H"H"H"H"V     Br