§ \�dºãó¼—dZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z Gd„d ej ¦«Z Gd „d ¦«Zdd œd „Zd„ZdS))ÚRunnerÚrunéNé)Ú coroutines)Úevents)Ú exceptions)Útaskscó—eZdZdZdZdZdS)Ú_StateÚcreatedÚ initializedÚclosedN)Ú__name__Ú __module__Ú __qualname__ÚCREATEDÚ INITIALIZEDÚCLOSED©óú ..\python\lib\asyncio\runners.pyr r s€€€€€Ø€GØ€KØ €F€F€Frr cóP—eZdZdZdddœd„Zd„Zd„Zd„Zd„Zdd œd „Z d „Z d „Z dS) 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. N)Ú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ó.—| ¦«|S©N)Ú _lazy_init©r#s rÚ __enter__zRunner.__enter__:s€Ø �ŠÑÔÐØˆ rcó.—| ¦«dSr&)Úclose)r#Úexc_typeÚexc_valÚexc_tbs rÚ__exit__zRunner.__exit__>s€Ø � Š ‰ Œ ˆ ˆ ˆ rcó —|jtjurdS |j}t |¦«| | ¦«¦«| | ¦«¦«|jrtj d¦«|  ¦«d|_tj |_dS#|jrtj d¦«|  ¦«d|_tj |_wxYw)zShutdown and close event loop.N) rr rrÚ_cancel_all_tasksÚrun_until_completeÚshutdown_asyncgensÚshutdown_default_executorr"rÚset_event_loopr+r)r#Úloops rr+z Runner.closeAsö€à Œ;�fÔ0Ð 0Ð 0Ø ˆFð (Ø”:ˆDÝ ˜dÑ #Ô #Ð #Ø × #Ò # D×$;Ò$;Ñ$=Ô$=Ñ >Ô >Ð >Ø × #Ò # D×$BÒ$BÑ$DÔ$DÑ EÔ EÐ EàÔ#ð ,ÝÔ% dÑ+Ô+Ð+Ø �JŠJ‰LŒLˆL؈DŒJÝ œ-ˆDŒKˆKˆKøð Ô#ð ,ÝÔ% dÑ+Ô+Ð+Ø �JŠJ‰LŒLˆL؈DŒJÝ œ-ˆDŒKÐ 'Ð 'Ð 'Ð 's —A$CÃA D có8—| ¦«|jS)zReturn embedded event loop.)r'rr(s rÚget_loopzRunner.get_loopQs€à �ŠÑÔÐØŒzÐr©Úcontextcó‚—tj|¦«s"td |¦«¦«‚t j¦«�t d¦«‚| ¦«|€|j}|j   ||¬¦«}tj ¦«tj ¦«urxtjtj¦«tjurNt%j|j|¬¦«} tjtj|¦«n#t$rd}YnwxYwd}d|_ |j  |¦«|�Jtjtj¦«|ur+tjtjtj¦«SSS#t.j$r<|jdkr/t3|dd¦«}|�|¦«dkrt5¦«‚‚wxYw#|�Jtjtj¦«|ur+tjtjtj¦«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 loopr9)Ú main_taskrÚuncancel)rÚ iscoroutineÚ ValueErrorÚformatrÚ_get_running_loopÚ RuntimeErrorr'r rÚ create_taskÚ threadingÚcurrent_threadÚ main_threadÚsignalÚ getsignalÚSIGINTÚdefault_int_handlerÚ functoolsÚpartialÚ _on_sigintr!r2rÚCancelledErrorÚgetattrÚKeyboardInterrupt)r#Úcoror:ÚtaskÚsigint_handlerr=s rrz Runner.runVs5€åÔ% dÑ+Ô+ð PÝÐA×HÒHÈÑNÔNÑOÔOÐ Oå Ô #Ñ %Ô %Ð 1åØIñKôKð Kð �ŠÑÔÐà ˆ?Ø”mˆGØŒz×%Ò% d°GÐ%Ñ<Ô<ˆå Ô $Ñ &Ô &­)Ô*?Ñ*AÔ*AÐ AÐ AÝÔ ¥¤Ñ/Ô/µ6Ô3MÐMÐMå&Ô.¨t¬È$ÐOÑOÔOˆNð &Ý” �fœm¨^Ñ<Ô<Ð<Ð<øÝð &ð &ð &ð"&���ð  &øøøð "ˆNà !ˆÔð IØ”:×0Ò0°Ñ6Ô6ðÐ*ÝÔ$¥V¤]Ñ3Ô3°~ÐEÐEå” �fœm­VÔ-GÑHÔHÐHÐHð+ØEøõÔ(ð ð ð ØÔ$ qÒ(Ð(Ý" 4¨°TÑ:Ô:�ØÐ'¨H¨H©J¬J¸!ªO¨OÝ+Ñ-Ô-Ð-Ø ð  øøøøðÐ*ÝÔ$¥V¤]Ñ3Ô3°~ÐEÐEå” �fœm­VÔ-GÑHÔHÐHÐHð+ØEøøøs,Ã>DÄ D-Ä,D-Ä:F!Æ!A G,Ç,G/Ç/AH>cóÒ—|jtjurtd¦«‚|jtjurdS|j€@t j¦«|_|j s t j |j¦«d|_ n| ¦«|_|j �|j  |j ¦«tj¦«|_tj|_dS)NzRunner is closedT)rr rrBrrrÚnew_event_looprr"r5rÚ set_debugÚ contextvarsÚ copy_contextr r(s rr'zRunner._lazy_initƒsÈ€Ø Œ;�&œ-Ð 'Ð 'ÝÐ1Ñ2Ô2Ð 2Ø Œ;�&Ô,Ð ,Ð ,Ø ˆFØ Ô Ð %ÝÔ.Ñ0Ô0ˆDŒJØÔ'ð ,õÔ% d¤jÑ1Ô1Ð1Ø'+�Ô$øà×+Ò+Ñ-Ô-ˆDŒJØ Œ;Ð "Ø ŒJ× Ò  ¤Ñ -Ô -Ð -Ý#Ô0Ñ2Ô2ˆŒ ÝÔ(ˆŒ ˆ ˆ rcóÞ—|xjdz c_|jdkrE| ¦«s1| ¦«|j d„¦«dSt ¦«‚)Nrcó—dSr&rrrrúz#Runner._on_sigint..›s€°D€r)r!ÚdoneÚcancelrÚcall_soon_threadsaferP)r#ÚsignumÚframer<s rrMzRunner._on_sigint–sn€Ø ÐÔ Ñ"ÐÔØ Ô  AÒ %Ð %¨i¯nªnÑ.>Ô.>Ð %Ø × Ò Ñ Ô Ð à ŒJ× +Ò +¨L¨LÑ 9Ô 9Ð 9Ø ˆFÝÑ!Ô!Ð!r) rrrÚ__doc__r$r)r/r+r8rr'rMrrrrrs¼€€€€€ððð6!%°4ð%ð%ð%ð%ð%ððððððð(ð(ð(ð ððð $(ð+Ið+Ið+Ið+Ið+IðZ)ð)ð)ð&"ð"ð"ð"ð"rr©rcóÄ—tj¦«�td¦«‚t|¬¦«5}| |¦«cddd¦«S#1swxYwYdS)a¥Execute 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 looprb)rrArBrr)ÚmainrÚrunners rrr s®€õ0ÔÑ!Ô!Ð-åØ FñHôHð Hõ �eÐ Ñ Ô ð  Ø�zŠz˜$ÑÔð ð ð ð ñ ô ð ð ð ð ð ð øøøð ð ð ð ð ð s³AÁAÁAcób—tj|¦«}|sdS|D]}| ¦«Œ| tj|ddiަ«|D]V}| ¦«rŒ| ¦«�+| d| ¦«|dœ¦«ŒWdS)NÚreturn_exceptionsTz1unhandled exception during asyncio.run() shutdown)ÚmessageÚ exceptionrR)r Ú all_tasksr]r2ÚgatherÚ cancelledriÚcall_exception_handler)r6Ú to_cancelrRs rr1r1ÁsӀݔ Ñ%Ô%€IØ ð؈àððˆØ � Š ‰ Œ ˆ ˆ à×Ò�EœL¨)ÐLÀtÐLÐLÑMÔMÐMàððˆØ �>Š>Ñ Ô ð Ø Ø �>Š>Ñ Ô Ð 'Ø × 'Ò 'ØNØ!Ÿ^š^Ñ-Ô-Øð)ð)ñ ô ð øð ðr)Ú__all__rWÚenumrKrDrGÚsysÚrrrr ÚEnumr rrr1rrrúrts&ðØ €àÐÐÐØ € € € ØÐÐÐØÐÐÐØ € € € Ø € € € ØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐØÐÐÐÐÐðððððˆTŒYñôðð H"ðH"ðH"ðH"ðH"ñH"ôH"ðH"ðVð ð ð ð ð ðBððððr