U e5d]"�@s�dZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z ddl m Z ddlmZdd �Ze�ZGd d �d �Zd d �Ze�Zdd�ZejejejjefZe�Zdd�Zdd�ZdS))� coroutine�iscoroutinefunction� iscoroutine�N�)� base_futures)� constants)�format_helpers)�loggercCs"tjjp tjj o ttj�d��S)NZPYTHONASYNCIODEBUG)�sys�flags�dev_mode�ignore_environment�bool�os�environ�get�rr�*/usr/lib64/python3.8/asyncio/coroutines.py�_is_debug_modes �rc@s�eZdZddd�Zdd�Zdd�Zdd �Zd d �Zdd d �Zdd�Z e dd��Z e dd��Z e dd��Z dd�Ze dd��Zdd�ZdS)� CoroWrapperNcCsZt�|�st�|�st|��||_||_t�t� d��|_ t |dd�|_ t |dd�|_ dS)Nr�__name__� __qualname__)�inspect� isgeneratorr�AssertionError�gen�funcr� extract_stackr � _getframe�_source_traceback�getattrrr)�selfrrrrr�__init__'s zCoroWrapper.__init__cCsJt|�}|jr4|jd}|d|d�d|d��7}d|jj�d|�d�S) N�����z , created at r�:r�<� �>)�_format_coroutiner� __class__r)r!� coro_repr�framerrr�__repr__/s  zCoroWrapper.__repr__cCs|S�Nr�r!rrr�__iter__7szCoroWrapper.__iter__cCs |j�d�Sr-�r�sendr.rrr�__next__:szCoroWrapper.__next__cCs |j�|�Sr-r0)r!�valuerrrr1=szCoroWrapper.sendcCs|j�|||�Sr-)r�throw)r!�typer3� tracebackrrrr4@szCoroWrapper.throwcCs |j��Sr-)r�closer.rrrr7CszCoroWrapper.closecCs|jjSr-)r�gi_framer.rrrr8FszCoroWrapper.gi_framecCs|jjSr-)r� gi_runningr.rrrr9JszCoroWrapper.gi_runningcCs|jjSr-)r�gi_coder.rrrr:NszCoroWrapper.gi_codecCs|Sr-rr.rrr� __await__RszCoroWrapper.__await__cCs|jjSr-)r� gi_yieldfromr.rrrr<UszCoroWrapper.gi_yieldfromcCs�t|dd�}t|dd�}|dk r||jdkr||�d�}t|dd�}|rrd�t�|��}|dtj�d �7}||��7}t� |�dS) Nrr8r#z was never yielded fromrr�zB Coroutine object created at (most recent call last, truncated to z last lines): ) r �f_lasti�joinr6� format_listrZDEBUG_STACK_DEPTH�rstripr �error)r!rr+�msg�tbrrr�__del__Ys     zCoroWrapper.__del__)N)NN)r� __module__rr"r,r/r2r1r4r7�propertyr8r9r:r;r<rErrrrr$s"      rcsztjdtdd�t���r�St���r.��nt����fdd���t� ���t sX�}nt�����fdd��}t |_ |S)z�Decorator 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|t�r4|EdH}n:z |j}Wntk rRYnXt|tj j �rn|�EdH}|Sr-) rZisfuturerr� isinstancerr;�AttributeError� collections�abc� Awaitable)�args�kw�resZ await_meth�rrr�corozs �   zcoroutine..corocs@t�||��d�}|jr |jd=t�dd�|_t�dd�|_|S)NrRr#rr)rrr rr)rO�kwds�w�rSrrr�wrapper�s zcoroutine..wrapper) �warnings�warn�DeprecationWarningrr�isgeneratorfunction� functools�wraps�typesr�_DEBUG� _is_coroutine)rrWrrVrris"�    rcCst�|�pt|dd�tkS)z6Return True if func is a decorated coroutine function.r`N)rrr r`rRrrrr�s �rcCs@t|�tkrdSt|t�r8tt�dkr4t�t|��dSdSdS)z)Return True if obj is a coroutine object.T�dFN)r5�_iscoroutine_typecacherJ�_COROUTINE_TYPES�len�add)�objrrrr�s   rc stt|�s t�t|t���fdd�}dd�}d}t|d�rF|jrF|j}nt|d�r\|jr\|j}||�}|s~||�rz|�d�S|Sd}t|d�r�|jr�|j}nt|d �r�|jr�|j}|j p�d }d }��r0|j dk �r0t � |j ��s0t �|j �}|dk r�|\}}|dk�r|�d |�d |��} n|�d|�d |��} n@|dk �rV|j}|�d|�d |��} n|j}|�d |�d |��} | S)Ncs`�rt�|jdi�St|d�r,|jr,|j}n*t|d�rD|jrD|j}ndt|�j�d�}|�d�S)Nrrrr%z without __name__>z())rZ_format_callbackr�hasattrrrr5)rS� coro_name�Zis_corowrapperrr�get_name�sz#_format_coroutine..get_namec SsHz|jWStk rBz |jWYStk r<YYdSXYnXdS)NF)� cr_runningrKr9)rSrrr� is_running�s z%_format_coroutine..is_running�cr_coder:z runningr8�cr_framezrz done, defined at r$z running, defined at z running at )rrrJrrgrmr:r8rn� co_filenamerrr[rZ_get_function_source�f_lineno�co_firstlineno) rSrjrlZ coro_coderhZ coro_frame�filename�lineno�sourcer*rrirr(�sL      � �   r() �__all__Zcollections.abcrLr\rrr r6r^rXr=rrr�logr rr_rr�objectr`r� CoroutineType� GeneratorTyperM� Coroutinerc�setrbrr(rrrr�s2    E8�