U kg]"@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/lib/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