관리-도구
편집 파일: streams.cpython-39.opt-2.pyc
a �����DOg h����������������������@���s&��d�Z�ddlZddlZddlZddlZeed�r6e�d7�Z�ddlmZ�ddlmZ�ddlm Z �dd lm Z �dd lmZ�ddlm Z �ddlmZ�d Zdded�dd�Zd ded�dd�Zeed�r�d!ded�dd�Zd"ded�dd�ZG�dd��dej�ZG�dd��deej�ZG�dd��d�ZG�dd��d�ZdS�)#)�StreamReader�StreamWriter�StreamReaderProtocol�open_connection�start_server�����N�AF_UNIX)�open_unix_connection�start_unix_server����)� coroutines)�events)� exceptions)�format_helpers)� protocols)�logger)�sleepi���)�loop�limitc���������� ����������sx���|d�u�rt����}ntjdtdd��t||d�}t||d���|j��fdd�|�|fi�|��I�d�H�\}}t|��||�}||fS�)N�[The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.������ stacklevel�r���r����r���c����������������������s�����S��N��r�����protocolr����'/usr/lib64/python3.9/asyncio/streams.py�<lambda>5��������z!open_connection.<locals>.<lambda>) r����get_event_loop�warnings�warn�DeprecationWarningr���r����create_connectionr���) �host�portr���r����kwds�reader� transport�_�writerr���r���r���r������s���� ���r���c��������������������sN����d�u�rt�����ntjdtdd������fdd�}�j|||fi�|��I�d�H�S�)Nr���r���r���c���������������������s���t���d�}�t|����d�}|S��Nr���r����r���r����r)���r�����client_connected_cbr���r���r���r����factoryX���s �����zstart_server.<locals>.factory)r���r!���r"���r#���r$���� create_server)r1���r&���r'���r���r���r(���r2���r���r0���r���r���:���s���� �r���c��������������������sv���|d�u�rt����}ntjdtdd��t||d�}t||d���|j��fdd�|�fi�|��I�d�H�\}}t|��||�}||fS�)Nr���r���r���r���r���c����������������������s�����S�r���r���r���r���r���r���r���p���r ���z&open_unix_connection.<locals>.<lambda>) r���r!���r"���r#���r$���r���r���Zcreate_unix_connectionr���)�pathr���r���r(���r)���r*���r+���r,���r���r���r���r���d���s���� ���r���c��������������������sL����d�u�rt�����ntjdtdd������fdd�}�j||fi�|��I�d�H�S�)Nr���r���r���c���������������������s���t���d�}�t|����d�}|S�r-���r.���r/���r0���r���r���r2���~���s �����z"start_unix_server.<locals>.factory)r���r!���r"���r#���r$���Zcreate_unix_server)r1���r4���r���r���r(���r2���r���r0���r���r ���t���s���� �r ���c�������������������@���s>���e�Zd�Zddd�Zdd��Zdd��Zdd ��Zd d��Zdd ��ZdS�)�FlowControlMixinNc�����������������C���s0���|d�u�rt����|�_n||�_d|�_d�|�_d|�_d�S��NF)r���r!����_loop�_paused� _drain_waiter�_connection_lost)�selfr���r���r���r����__init__����s����zFlowControlMixin.__init__c�����������������C���s ���d|�_�|�j���rt�d|���d�S�)NTz%r pauses writing)r8���r7���� get_debugr����debug�r;���r���r���r���� pause_writing����s���� zFlowControlMixin.pause_writingc�����������������C���sF���d|�_�|�j���rt�d|���|�j}|d�urBd�|�_|���sB|�d���d�S�)NFz%r resumes writing)r8���r7���r=���r���r>���r9����done� set_result�r;����waiterr���r���r����resume_writing����s���� zFlowControlMixin.resume_writingc�����������������C���sV���d|�_�|�jsd�S�|�j}|d�u�r"d�S�d�|�_|���r4d�S�|d�u�rH|�d���n |�|��d�S��NT)r:���r8���r9���rA���rB���� set_exception�r;����excrD���r���r���r����connection_lost����s����z FlowControlMixin.connection_lostc���������������������s<���|�j�rtd��|�jsd�S�|�j}|�j���}||�_|I�d�H��d�S�)NzConnection lost)r:����ConnectionResetErrorr8���r9���r7���� create_futurerC���r���r���r���� _drain_helper����s���� zFlowControlMixin._drain_helperc�����������������C���s���t��d�S�r���)�NotImplementedError�r;����streamr���r���r����_get_close_waiter����s����z"FlowControlMixin._get_close_waiter)N) �__name__� __module__�__qualname__r<���r@���rE���rJ���rM���rQ���r���r���r���r���r5�������s��� r5���c�����������������������sb���e�Zd�ZdZd��fdd� Zedd���Zdd��Z��fdd �Zd d��Z dd ��Z dd��Zdd��Z���Z S�)r���Nc��������������������sn���t���j|d��|d�ur,t�|�|�_|j|�_nd�|�_|d�ur@||�_d|�_d�|�_d�|�_ ||�_ d|�_|�j� ��|�_d�S�)Nr���F)�superr<����weakref�ref�_stream_reader_wr�_source_traceback�_strong_reader�_reject_connection�_stream_writer� _transport�_client_connected_cb� _over_sslr7���rL����_closed)r;���Z stream_readerr1���r����� __class__r���r���r<�������s���� zStreamReaderProtocol.__init__c�����������������C���s���|�j�d�u�rd�S�|�����S�r���)rX���r?���r���r���r����_stream_reader����s���� z#StreamReaderProtocol._stream_readerc�����������������C���s����|�j�r6ddi}|�jr|�j|d<�|�j�|��|����d�S�||�_|�j}|d�urT|�|��|�d�d�u|�_ |�j d�ur�t||�||�j�|�_|�� ||�j�}t �|�r�|�j�|��d�|�_d�S�)N�messagezpAn open stream was garbage collected prior to establishing network connection; call "stream.close()" explicitly.Zsource_tracebackZ sslcontext)r[���rY���r7���Zcall_exception_handler�abortr]���rc���� set_transport�get_extra_infor_���r^���r���r\���r���ZiscoroutineZcreate_taskrZ���)r;���r*����contextr)����resr���r���r����connection_made����s0����� �� z$StreamReaderProtocol.connection_madec��������������������sx���|�j�}|d�ur*|d�u�r |����n |�|��|�j���sV|d�u�rJ|�j�d���n|�j�|��t���|��d�|�_d�|�_ d�|�_ d�S�r���)rc����feed_eofrG���r`���rA���rB���rU���rJ���rX���r\���r]���)r;���rI���r)���ra���r���r���rJ��� ��s���� z$StreamReaderProtocol.connection_lostc�����������������C���s���|�j�}|d�ur|�|��d�S�r���)rc���� feed_data)r;����datar)���r���r���r���� data_received��s����z"StreamReaderProtocol.data_receivedc�����������������C���s$���|�j�}|d�ur|����|�jr dS�dS�)NFT)rc���rk���r_���)r;���r)���r���r���r����eof_received ��s����z!StreamReaderProtocol.eof_receivedc�����������������C���s���|�j�S�r���)r`���rO���r���r���r���rQ���+��s����z&StreamReaderProtocol._get_close_waiterc�����������������C���s"���|�j�}|���r|���s|����d�S�r���)r`���rA���� cancelled� exception)r;����closedr���r���r����__del__.��s����zStreamReaderProtocol.__del__)NN)rR���rS���rT���rY���r<����propertyrc���rj���rJ���rn���ro���rQ���rs���� __classcell__r���r���ra���r���r�������s��� r���c�������������������@���sr���e�Zd�Zdd��Zdd��Zedd���Zdd��Zd d ��Zdd��Z d d��Z dd��Zdd��Zdd��Z ddd�Zdd��ZdS�)r���c�����������������C���s4���||�_�||�_||�_||�_|�j���|�_|�j�d���d�S�r���)r]���� _protocol�_readerr7���rL���Z _complete_futrB���)r;���r*���r���r)���r���r���r���r���r<���@��s����zStreamWriter.__init__c�����������������C���s@���|�j�jd|�j��g}|�jd�ur0|�d|�j����d�d�|��S�)N� transport=zreader=�<{}>� )rb���rR���r]���rw����append�format�join�r;����infor���r���r����__repr__J��s���� zStreamWriter.__repr__c�����������������C���s���|�j�S�r����r]���r?���r���r���r���r*���P��s����zStreamWriter.transportc�����������������C���s���|�j��|��d�S�r���)r]����write�r;���rm���r���r���r���r����T��s����zStreamWriter.writec�����������������C���s���|�j��|��d�S�r���)r]���� writelinesr����r���r���r���r����W��s����zStreamWriter.writelinesc�����������������C���s ���|�j����S�r���)r]���� write_eofr?���r���r���r���r����Z��s����zStreamWriter.write_eofc�����������������C���s ���|�j����S�r���)r]���� can_write_eofr?���r���r���r���r����]��s����zStreamWriter.can_write_eofc�����������������C���s ���|�j����S�r���)r]����closer?���r���r���r���r����`��s����zStreamWriter.closec�����������������C���s ���|�j����S�r���)r]���� is_closingr?���r���r���r���r����c��s����zStreamWriter.is_closingc���������������������s���|�j��|��I�d�H��d�S�r���)rv���rQ���r?���r���r���r����wait_closedf��s����zStreamWriter.wait_closedNc�����������������C���s���|�j��||�S�r���)r]���rg���)r;����name�defaultr���r���r���rg���i��s����zStreamWriter.get_extra_infoc���������������������sL���|�j�d�ur |�j����}|d�ur |�|�j���r8td�I�d�H��|�j���I�d�H��d�S�)Nr���)rw���rq���r]���r����r���rv���rM���)r;���rI���r���r���r����drainl��s���� zStreamWriter.drain)N)rR���rS���rT���r<���r����rt���r*���r����r����r����r����r����r����r����rg���r����r���r���r���r���r���6��s��� r���c�������������������@���s����e�Zd�ZdZedfdd�Zdd��Zdd��Zdd ��Zd d��Z dd ��Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��Zd&dd�Zd'dd�Zd d!��Zd"d#��Zd$d%��ZdS�)(r���Nc�����������������C���sv���|dkrt�d��||�_|d�u�r*t���|�_n||�_t��|�_d|�_d�|�_d�|�_ d�|�_ d|�_|�j���rrt �t�d��|�_d�S�)Nr���zLimit cannot be <= 0Fr ���)� ValueError�_limitr���r!���r7���� bytearray�_buffer�_eof�_waiter� _exceptionr]���r8���r=���r���� extract_stack�sys� _getframerY���)r;���r���r���r���r���r���r<������s ���� �zStreamReader.__init__c�����������������C���s����dg}|�j�r"|�t|�j����d���|�jr2|�d��|�jtkrN|�d|�j�����|�jrf|�d|�j����|�jr~|�d|�j����|�jr�|�d|�j����|�j r�|�d��d � d �|��S�)Nr���z bytes�eofzlimit=zwaiter=z exception=rx���Zpausedry���rz���)r����r{����lenr����r�����_DEFAULT_LIMITr����r����r]���r8���r|���r}���r~���r���r���r���r�������s ���� zStreamReader.__repr__c�����������������C���s���|�j�S�r���)r����r?���r���r���r���rq������s����zStreamReader.exceptionc�����������������C���s0���||�_�|�j}|d�ur,d�|�_|���s,|�|��d�S�r���)r����r����rp���rG���rH���r���r���r���rG������s����zStreamReader.set_exceptionc�����������������C���s*���|�j�}|d�ur&d�|�_�|���s&|�d���d�S�r���)r����rp���rB���rC���r���r���r����_wakeup_waiter���s ����zStreamReader._wakeup_waiterc�����������������C���s ���||�_�d�S�r���r����)r;���r*���r���r���r���rf������s����zStreamReader.set_transportc�����������������C���s*���|�j�r&t|�j�|�jkr&d|�_�|�j����d�S�r6���)r8���r����r����r����r]����resume_readingr?���r���r���r����_maybe_resume_transport���s����z$StreamReader._maybe_resume_transportc�����������������C���s���d|�_�|�����d�S�rF���)r����r����r?���r���r���r���rk������s����zStreamReader.feed_eofc�����������������C���s���|�j�o|�j�S�r���)r����r����r?���r���r���r����at_eof���s����zStreamReader.at_eofc�����������������C���sr���|sd�S�|�j��|��|�����|�jd�urn|�jsnt|�j��d|�j�krnz|�j����W�n�tyf���d�|�_Y�n0�d|�_d�S�)Nr���T) r�����extendr����r]���r8���r����r����Z pause_readingrN���r����r���r���r���rl������s���� ��zStreamReader.feed_datac���������������������s^���|�j�d�urt|��d���|�jr.d|�_|�j����|�j���|�_�z|�j�I�d�H��W�d�|�_�nd�|�_�0�d�S�)NzF() called while another coroutine is already waiting for incoming dataF)r�����RuntimeErrorr8���r]���r����r7���rL���)r;���� func_namer���r���r����_wait_for_data���s���� � zStreamReader._wait_for_datac�������������� �������s����d}t�|�}z|��|�I�d�H�}W�n��tjyL�}�z|jW��Y�d�}~S�d�}~0��tjy��}�zP|�j�||j�r�|�jd�|j|��=�n |�j� ���|�� ���t|jd���W�Y�d�}~n d�}~0�0�|S�)N���� r���) r����� readuntilr ����IncompleteReadError�partial�LimitOverrunErrorr����� startswith�consumed�clearr����r�����args)r;����sep�seplen�line�er���r���r����readline ��s���� $zStreamReader.readliner����c���������������������s����t�|�}|dkrtd��|�jd�ur(|�j�d}t�|�j�}||�|kr||�j�||�}|dkrZq�|d�|�}||�jkr|t�d|��|�jr�t |�j�}|�j� ���t�|d���|��d�I�d�H��q,||�jkr�t�d|��|�jd�||���}|�jd�||��=�|�� ���t |�S�)Nr���z,Separator should be at least one-byte string���r ���z2Separator is not found, and chunk exceed the limitr����z2Separator is found, but chunk is longer than limit)r����r����r����r�����findr����r ���r����r�����bytesr����r����r����r����)r;���� separatorr�����offset�buflenZisep�chunkr���r���r���r����(��s<���� � �zStreamReader.readuntilr����c���������������������s����|�j�d�ur|�j��|dkrdS�|dk�rVg�}|��|�j�I�d�H�}|s@qL|�|��q(d�|�S�|�jsr|�jsr|��d�I�d�H��t|�jd�|���}|�jd�|�=�|�� ���|S�)Nr���r ����read) r����r����r����r{���r}���r����r����r����r����r����)r;����nZblocks�blockrm���r���r���r���r�������s"���� zStreamReader.readc���������������������s����|dk�rt�d��|�jd�ur |�j�|dkr,dS�t|�j�|k�rr|�jr`t|�j�}|�j����t�||��|�� d�I�d�H��q,t|�j�|kr�t|�j�}|�j����nt|�jd�|���}|�jd�|�=�|�� ���|S�)Nr���z*readexactly size can not be less than zeror ����readexactly)r����r����r����r����r����r����r����r ���r����r����r����)r;���r����Z incompleterm���r���r���r���r�������s&���� zStreamReader.readexactlyc�����������������C���s���|�S�r���r���r?���r���r���r���� __aiter__���s����zStreamReader.__aiter__c���������������������s���|�����I�d�H�}|dkrt�|S�)Nr ���)r�����StopAsyncIteration)r;����valr���r���r���� __anext__���s����zStreamReader.__anext__)r����)r����)rR���rS���rT���rY���r����r<���r����rq���rG���r����rf���r����rk���r����rl���r����r����r����r����r����r����r����r���r���r���r���r������s$��� [ 2)r���)NN)NN)N)N)�__all__�socketr����r"���rV����hasattr��r���r���r ���r���r����logr���Ztasksr���r����r���r���r���r ����Protocolr5���r���r���r���r���r���r���r����<module>���s>��� �!�' ��DkP