Your IP : 3.145.172.254


Current Path : /lib64/python3.6/asyncio/__pycache__/
Upload File :
Current File : //lib64/python3.6/asyncio/__pycache__/coroutines.cpython-36.pyc

3


 \+�@s�dddgZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZdd	lmZdd
l
mZejdZejjo�eejjd��ZyejZejZWnek
r�dZdZYnXy
ejZWnek
r�d
d�ZYnXyddlmZ m!Z"Wne#k
�r*dZ Z"YnXdd�Z$e$�Z%[$dd�Z&Gdd�d�Z'dd�Ze(�Z)dd�Zej*e'fZ+e dk	�r�e+e f7Z+edk	�r�efe+Z+dd�Z,dd�Z-dS)�	coroutine�iscoroutinefunction�iscoroutine�N�)�compat)�	constants)�events)�base_futures)�loggerZ
YIELD_FROMZPYTHONASYNCIODEBUGcCsdS)NF�)�funcrr�"/usr/lib64/python3.6/coroutines.py�<lambda>/sr)�	Coroutine�	AwaitablecCsFGdd�d�}dd�}d}|�}||�}t|�|j|�|j|fkS)	Nc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
z!has_yield_from_bug.<locals>.MyGencSs
d|_dS)N)�	send_args)�selfrrr
�__init__;sz*has_yield_from_bug.<locals>.MyGen.__init__cSs|S)Nr)rrrr
�__iter__=sz*has_yield_from_bug.<locals>.MyGen.__iter__cSsdS)N�*r)rrrr
�__next__?sz*has_yield_from_bug.<locals>.MyGen.__next__cWs
||_dS)N)r)rZwhatrrr
�sendAsz&has_yield_from_bug.<locals>.MyGen.sendN)�__name__�
__module__�__qualname__rrrrrrrr
�MyGen:srcss|EdHdS)Nr)�genrrr
�yield_from_genDsz*has_yield_from_bug.<locals>.yield_from_genr��)rrr)�nextrr)rr�valuer�cororrr
�has_yield_from_bug9s

r#cCs
t|d�S)N)�CoroWrapper)rrrr
�
debug_wrapperPsr%c@s�eZdZd%dd�Zdd�Zdd�Zdd	�Zer8d
d�Zndd�Zd&d
d�Z	dd�Z
edd��Zedd��Z
edd��Zejr�dd�Zedd��Zedd��Zedd��Zedd ��Zed!d"��Zd#d$�ZdS)'r$NcCsZtj|�stj|�st|��||_||_tjtj	d��|_
t|dd�|_t|dd�|_
dS)Nrrr)�inspect�isgeneratorr�AssertionErrorrrr�
extract_stack�sys�	_getframe�_source_traceback�getattrrr)rrrrrr
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_repr�framerrr
�__repr__cs

zCoroWrapper.__repr__cCs|S)Nr)rrrr
rjszCoroWrapper.__iter__cCs|jjd�S)N)rr)rrrr
rmszCoroWrapper.__next__cGsBtj�}|j}|jdkst�|jj|jtkr6|d}|jj	|�S)Nr)
r*r+�f_back�f_lastir(�f_code�co_code�_YIELD_FROMrr)rr!r2Zcallerrrr
ruszCoroWrapper.sendcCs|jj|�S)N)rr)rr!rrr
r}scCs|jj|||�S)N)r�throw)r�typer!�	tracebackrrr
r9�szCoroWrapper.throwcCs
|jj�S)N)r�close)rrrr
r<�szCoroWrapper.closecCs|jjS)N)r�gi_frame)rrrr
r=�szCoroWrapper.gi_framecCs|jjS)N)r�
gi_running)rrrr
r>�szCoroWrapper.gi_runningcCs|jjS)N)r�gi_code)rrrr
r?�szCoroWrapper.gi_codecCs,t|jdd�}|dk	r(tdj|j|���|S)N�cr_awaitz;Cannot await on coroutine {!r} while it's awaiting for {!r})r-r�RuntimeError�format)rr@rrr
�	__await__�szCoroWrapper.__await__cCs|jjS)N)r�gi_yieldfrom)rrrr
rD�szCoroWrapper.gi_yieldfromcCs|jjS)N)rr@)rrrr
r@�szCoroWrapper.cr_awaitcCs|jjS)N)r�
cr_running)rrrr
rE�szCoroWrapper.cr_runningcCs|jjS)N)r�cr_code)rrrr
rF�szCoroWrapper.cr_codecCs|jjS)N)r�cr_frame)rrrr
rG�szCoroWrapper.cr_framecCs�t|dd�}t|dd�}|dkr,t|dd�}|dk	r�|jd
kr�d|}t|df�}|r�djtj|��}|dtj�d	�7}||j�7}tj	|�dS)Nrr=rGrz%r was never yielded fromr,�zB
Coroutine object created at (most recent call last, truncated to z last lines):
r.)
r-r5�joinr;�format_listrZDEBUG_STACK_DEPTH�rstripr
�error)rrr2�msg�tbrrr
�__del__�szCoroWrapper.__del__)N)NN)rrrrr3rr�_YIELD_FROM_BUGrr9r<�propertyr=r>r?rZPY35rCrDr@rErFrGrOrrrr
r$Xs(


r$cspt��r�Stj��r��ntj���fdd���tsNtdkrD�}qft��}ntj����fdd��}t|_|S)z�Decorator to mark coroutines.

    If the coroutine is not yielded from before it is destroyed,
    an error message is logged.
    c?sv�||�}tj|�s(tj|�s(t|t�r4|EdH}n>tdk	rry
|j}Wntk
rZYnXt|t�rr|�EdH}|S)N)	r	Zisfuturer&r'�
isinstancer$�
_AwaitableABCrC�AttributeError)�args�kw�resZ
await_meth)rrr
r"�s



zcoroutine.<locals>.coroNcs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)N)rrrrr.)r$r,r-rr)rU�kwds�w)r"rrr
�wrapper�szcoroutine.<locals>.wrapper)�_inspect_iscoroutinefunctionr&�isgeneratorfunction�	functools�wraps�_DEBUG�_types_coroutine�
_is_coroutine)rrZr)r"rr
r�s


cCst|dd�tkpt|�S)z6Return True if func is a decorated coroutine function.raN)r-rar[)rrrr
r�scCs
t|t�S)z)Return True if obj is a coroutine object.)rR�_COROUTINE_TYPES)�objrrr
rsc
Cs&t|�st�t|d�r�t|d�r�t|dt|dt|�j��}dj|�}d}y
|j}Wn4tk
r�y
|j	}Wntk
r�YnXYnX|r�dj|�S|Sd}t
|t�r�|j}|j
}|dk	r�dj|�}n|}|dkr�tj|fi�}d}t|d�o�|j�r|j}nt|d��r|j�r|j}d}t|d��r>|j�r>|j}nt|d	��rX|j�rX|j}d
}|�rp|j�rp|j}d}|}t
|t��r�tj|j��r�|jdk	�r�tj|j�}	|	dk	�r�|	\}}|dk�r�d|||f}nd
|||f}n:|dk	�r|j}d|||f}n|�r"|j}d|||f}|S)NrFr?rrz{}()Fz
{} runningrGr=z<empty co_filename>rz%s done, defined at %s:%sz%s running, defined at %s:%sz%s running at %s:%s)rr(�hasattrr-r:rrBrErTr>rRr$rrrZ_format_callbackrFr?rGr=�co_filenamer&r\Z_get_function_source�f_lineno�co_firstlineno)
r"Z	coro_nameZrunningrZ	coro_codeZ
coro_frame�filename�linenor1�sourcerrr
r/sz







r/).�__all__r]r&Zopcode�osr*r;�typesrHrrrr	�logr
Zopmapr8�flags�ignore_environment�bool�environ�getr_rr`�
CoroutineTypeZ_types_CoroutineTyperTrr[�collections.abcrZ
_CoroutineABCrrS�ImportErrorr#rPr%r$�objectra�
GeneratorTyperbrr/rrrr
�<module>sZ




j: