B xc!@sdZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZdd ZeZGd d d Zd d ZeZddZejejejjefZeZddZddZdS)) coroutineiscoroutinefunction iscoroutineN) base_futures) constants)format_helpers)loggercCs"tjjp tjj o ttjdS)NZPYTHONASYNCIODEBUG)sysflagsdev_modeignore_environmentboolosenvirongetrr7/opt/alt/python37/lib64/python3.7/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|S)Nr)rrrr__iter__6szCoroWrapper.__iter__cCs |jdS)N)rsend)rrrr__next__9szCoroWrapper.__next__cCs |j|S)N)rr+)rvaluerrrr+<szCoroWrapper.sendcCs|j|||S)N)rthrow)rtyper- tracebackrrrr.?szCoroWrapper.throwcCs |jS)N)rclose)rrrrr1BszCoroWrapper.closecCs|jjS)N)rgi_frame)rrrrr2EszCoroWrapper.gi_framecCs|jjS)N)r gi_running)rrrrr3IszCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rrrrr4MszCoroWrapper.gi_codecCs|S)Nr)rrrr __await__QszCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rrrrr6TszCoroWrapper.gi_yieldfromcCst|dd}t|dd}|dk r||jdkr||d}t|dd}|rrdt|}|dtjd 7}||7}t |dS) Nrr2r z was never yielded fromrrzB Coroutine object created at (most recent call last, truncated to z last lines): ) rf_lastijoinr0 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr(msgtbrrr__del__Xs     zCoroWrapper.__del__)N)NN)r __module__rrr)r*r,r+r.r1propertyr2r3r4r5r6r?rrrrr#s      rcsjtrStrntfddttsH}ntfdd}t|_|S)zDecorator to mark coroutines. If the coroutine is not yielded from before it is destroyed, an error message is logged. c?sr||}t|s(t|s(t|tr4|EdH}n:y |j}Wntk rRYnXt|tj j rn|EdH}|S)N) rZisfutureinspectZ isgenerator isinstancerr5AttributeError collectionsabc Awaitable)argskwZresZ await_meth)rrrcorovs     zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)N)rr rr)rrrrr)rHkwdsw)rJrrrwrappers zcoroutine..wrapper) rBrisgeneratorfunction functoolswrapstypesr_DEBUG _is_coroutine)rrMr)rJrrrhs    rcCst|pt|ddtkS)z6Return True if func is a decorated coroutine function.rSN)rBrrrS)rrrrrs rcCs@t|tkrdSt|tr8ttdkr4tt|dSdSdS)z)Return True if obj is a coroutine object.TdFN)r/_iscoroutine_typecacherC_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_callbackrhasattrrrr/)rJ coro_name)is_corowrapperrrget_namesz#_format_coroutine..get_namec Ss<y|jStk r6y|jStk r0dSXYnXdS)NF) cr_runningrDr3)rJrrr is_runningsz%_format_coroutine..is_runningcr_coder4z runningr2cr_framezrz done, defined at r!z running, defined at z running at )rCrrZr`r4r2ra co_filenamerrBrNrZ_get_function_sourcef_linenoco_firstlineno) rJr]r_Z coro_coder[Z coro_framefilenamelinenosourcer'r)r\rr%sF         r%)__all__Zcollections.abcrErOrBrr r0rQr7rrrlogr rrRrrobjectrSr CoroutineType GeneratorTyperF CoroutinerVsetrUrr%rrrrs,    E5