o [d]"@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"tjjptjj ottjdS)NPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr)/usr/lib/python3.10/asyncio/coroutines.py_is_debug_modes rc@seZdZdddZddZddZdd Zd d Zdd d ZddZ e ddZ e ddZ e ddZ ddZe ddZddZdS) CoroWrapperNcCsZt|st|sJ|||_||_ttd|_ t |dd|_ t |dd|_ dS)Nr__name__ __qualname__) inspect isgeneratorrgenfuncr extract_stackr _getframe_source_tracebackgetattrrr)selfrrrrr__init__'s zCoroWrapper.__init__cCsJt|}|jr|jd}|d|dd|d7}d|jjd|dS) Nz , created at r:r< >)_format_coroutiner __class__r)r! coro_reprframerrr__repr__/s  zCoroWrapper.__repr__cC|SNrr!rrr__iter__7zCoroWrapper.__iter__cCs |jdSr.rsendr/rrr__next__: zCoroWrapper.__next__cCs |j|Sr.r2)r!valuerrrr3=r5zCoroWrapper.sendcCs|j|||Sr.)rthrow)r!typer6 tracebackrrrr7@szCoroWrapper.throwcCs |jSr.)rcloser/rrrr:Cs zCoroWrapper.closecC|jjSr.)rgi_framer/rrrr<FzCoroWrapper.gi_framecCr;r.)r gi_runningr/rrrr>Jr=zCoroWrapper.gi_runningcCr;r.)rgi_coder/rrrr?Nr=zCoroWrapper.gi_codecCr-r.rr/rrr __await__Rr1zCoroWrapper.__await__cCr;r.)r gi_yieldfromr/rrrrAUr=zCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dur@|jdkrB|d}t|dd}|r9dt|}|dtjd 7}||7}t |dSdSdS) Nrr<r#z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) r f_lastijoinr9 format_listrDEBUG_STACK_DEPTHrstripr error)r!rr+msgtbrrr__del__Ys     zCoroWrapper.__del__r.)NN)r __module__rr"r,r0r4r3r7r:propertyr<r>r?r@rArKrrrrr$s$       rcsztjdtddtrStrn tfddt t s,}n tfdd}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?sz|i|}t|st|st|tr|EdH}|Sz|j}Wn ty-Y|Swt|tj j r;|EdH}|Sr.) risfuturerr isinstancerr@AttributeError collectionsabc Awaitable)argskwres await_methrrrcorozs      zcoroutine..corocsDt|i|d}|jr|jd=tdd|_tdd|_|S)NrZr#rr)rrr rr)rVkwdswr[rrrwrappers zcoroutine..wrapper) warningswarnDeprecationWarningrrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rr_rr^rris"    rcCst|p t|ddtuS)z6Return True if func is a decorated coroutine function.rhN)rrr rhrZrrrrs rcCs<t|tvrdSt|trttdkrtt|dSdS)z)Return True if obj is a coroutine object.TdF)r8_iscoroutine_typecacherQ_COROUTINE_TYPESlenadd)objrrrrs   rc spt|sJt|tfdd}dd}d}t|dr#|jr#|j}n t|dr.|jr.|j}||}|s?||r=|dS|Sd}t|drM|jrM|j}n t|d rX|jrX|j}|jp\d }d }r|j durt |j st |j }|durz|\}}|dur|d |d |} | S|d|d |} | S|dur|j}|d|d |} | S|j}|d |d |} | S)Ncs`r t|jdiSt|dr|jr|j}nt|dr"|jr"|j}n dt|jd}|dS)Nrrrr%z without __name__>z())r_format_callbackrhasattrrrr8)r[ coro_nameis_corowrapperrrget_names z#_format_coroutine..get_namec Ss<z|jWStyz|jWYStyYYdSww)NF) cr_runningrRr>)r[rrr is_runnings   z%_format_coroutine..is_runningcr_coder?z runningr<cr_framezrz done, defined at r$z running, defined at z running at )rrQrrprwr?r<rx co_filenamerrrcr_get_function_sourcef_linenoco_firstlineno) r[rtrv coro_coderq coro_framefilenamelinenosourcer*rrrrr(sP           r() __all__collections.abcrSrdrrr r9rfr`rBrrrlogr rrgrrobjectrhr CoroutineType GeneratorTyperT Coroutinerksetrjrr(rrrrs2    E8