3 \+@sdddgZddlZddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlm Z dd lm Z dd l mZejd Zejj oeejjd ZyejZejZWnek rdZdZYnXy ejZWnek rd dZYnXyddlmZ m!Z"Wne#k r*dZ Z"YnXddZ$e$Z%[$ddZ&GdddZ'ddZe(Z)ddZej*e'fZ+e dk re+e f7Z+edk refe+Z+ddZ,ddZ-dS) coroutineiscoroutinefunction iscoroutineN)compat) constants)events) base_futures)loggerZ YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF)funcr r */usr/lib64/python3.6/asyncio/coroutines.py/sr) Coroutine AwaitablecCsFGddd}dd}d}|}||}t||j||j|fkS) Nc@s,eZdZddZddZddZddZd S) z!has_yield_from_bug..MyGencSs d|_dS)N) send_args)selfr r r __init__;sz*has_yield_from_bug..MyGen.__init__cSs|S)Nr )rr r r __iter__=sz*has_yield_from_bug..MyGen.__iter__cSsdS)N*r )rr r r __next__?sz*has_yield_from_bug..MyGen.__next__cWs ||_dS)N)r)rZwhatr r r sendAsz&has_yield_from_bug..MyGen.sendN)__name__ __module__ __qualname__rrrrr r r r MyGen:srcss|EdHdS)Nr )genr r r yield_from_genDsz*has_yield_from_bug..yield_from_genr)rrr)nextrr)rrvaluercoror r r has_yield_from_bug9s  r#cCs t|dS)N) CoroWrapper)rr r r debug_wrapperPsr%c@seZdZd%ddZddZddZdd Zer8d d Znd d Zd&d dZ ddZ e ddZ e ddZ e ddZejrddZe ddZe ddZe ddZe dd Ze d!d"Zd#d$ZdS)'r$NcCs>||_||_tjtjd|_t|dd|_t|dd|_ dS)Nrrr) rr r extract_stacksys _getframe_source_tracebackgetattrrr)rrr r r r r[s zCoroWrapper.__init__cCs@t|}|jr0|jd}|d|d|df7}d|jj|fS)Nrz, created at %s:%srz<%s %s>)_format_coroutiner) __class__r)r coro_reprframer r r __repr__cs  zCoroWrapper.__repr__cCs|S)Nr )rr r r rjszCoroWrapper.__iter__cCs |jjdS)N)rr)rr r r rmszCoroWrapper.__next__cGs4tj}|j}|jj|jtkr(|d}|jj|S)Nr) r'r(f_backf_codeco_codef_lasti _YIELD_FROMrr)rr!r/Zcallerr r r rus zCoroWrapper.sendcCs |jj|S)N)rr)rr!r r r r}scCs|jj|||S)N)rthrow)rtyper! tracebackr r r r6szCoroWrapper.throwcCs |jjS)N)rclose)rr r r r9szCoroWrapper.closecCs|jjS)N)rgi_frame)rr r r r:szCoroWrapper.gi_framecCs|jjS)N)r gi_running)rr r r r;szCoroWrapper.gi_runningcCs|jjS)N)rgi_code)rr r r r<szCoroWrapper.gi_codecCs,t|jdd}|dk r(tdj|j||S)Ncr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r*r RuntimeErrorformat)rr=r r r __await__s  zCoroWrapper.__await__cCs|jjS)N)r gi_yieldfrom)rr r r rAszCoroWrapper.gi_yieldfromcCs|jjS)N)rr=)rr r r r=szCoroWrapper.cr_awaitcCs|jjS)N)r cr_running)rr r r rBszCoroWrapper.cr_runningcCs|jjS)N)rcr_code)rr r r rCszCoroWrapper.cr_codecCs|jjS)N)rcr_frame)rr r r rDszCoroWrapper.cr_framecCst|dd}t|dd}|dkr,t|dd}|dk r|jd krd|}t|df}|rdjtj|}|dtjd 7}||j7}tj |dS) Nrr:rDrz%r was never yielded fromr)zB Coroutine object created at (most recent call last, truncated to z last lines): r+) r*r4joinr8 format_listrZDEBUG_STACK_DEPTHrstripr error)rrr/msgtbr r r __del__s     zCoroWrapper.__del__)N)NN)rrrrr0rr_YIELD_FROM_BUGrr6r9propertyr:r;r<rZPY35r@rAr=rBrCrDrLr r r r r$Xs(           r$csptr StjrntjfddtsNtdkrD}qft}ntjfdd}t|_|S)Nc ?sv||}tj|s(tj|s(t|tr4|EdH}n>tdk rry |j}Wntk rZYnXt|trr|EdH}|S)N) r ZisfutureinspectZ isgenerator isinstancer$ _AwaitableABCr@AttributeError)argskwresZ await_meth)r r r r"s      zcoroutine..corocs@t||d}|jr |jd=tdd|_tdd|_|S)N)r rrrr+)r$r)r*rr)rSkwdsw)r"r r r wrappers zcoroutine..wrapper)_inspect_iscoroutinefunctionrOisgeneratorfunction functoolswraps_DEBUG_types_coroutine _is_coroutine)r rXr )r"r r rs   cCst|ddtkpt|S)Nr_)r*r_rY)r r r r rscCs t|tS)N)rP_COROUTINE_TYPES)objr r r rsc Cst|d rt|d rt|dt|dt|j}dj|}d}y |j}Wn4tk r~y |j}Wntk rxYnXYnX|rdj|S|Sd}t|t r|j }|j }|dk rdj|}n|}|dkrt j |fi}d}t|dr|jr|j}nt|dr|jr|j}d}t|dr0|jr0|j}nt|d rJ|jrJ|j}d }|rb|jrb|j}d }|}t|t rtj|j  r|j dk rt j|j } | dk r| \}}|dkrd |||f}nd |||f}n:|dk r|j}d|||f}n|r|j}d |||f}|S)NrCr<rrz{}()Fz {} runningrDr:zrz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)hasattrr*r7rr?rBrRr;rPr$r rrZ_format_callbackrCr<rDr: co_filenamerOrZZ_get_function_sourcef_linenoco_firstlineno) r"Z coro_nameZrunningr Z coro_codeZ coro_framefilenamelinenor.sourcer r r r,sx              r,).__all__r[rOZopcodeosr'r8typesrErrrr logr Zopmapr5flagsignore_environmentboolenvirongetr]rr^ CoroutineTypeZ_types_CoroutineTyperRrrYcollections.abcrZ _CoroutineABCrrQ ImportErrorr#rMr%r$objectr_ GeneratorTyper`rr,r r r r sZ         j: