o
    i                     @   sR   d dl Z d dlmZmZ ddlmZ ddlmZ ddlm	Z	 G dd de j
ZdS )	    N)Optionalcast   )ClientConnectionResetError)set_exception)tcp_nodelayc                   @   s   e Zd ZdZdejddfddZedefddZ	edefd	d
Z
dddZdddZdddZdddZdejddfddZdee ddfddZdddZdS )BaseProtocol)_loop_paused_drain_waiterZ_connection_lost_reading_paused	transportloopreturnNc                 C   s"   || _ d| _d | _d| _d | _d S NF)r	   r
   r   r   r   )selfr    r   O/home/kim/smarthome/.venv/lib/python3.10/site-packages/aiohttp/base_protocol.py__init__   s
   
zBaseProtocol.__init__c                 C   s
   | j duS )z&Return True if the connection is open.N)r   r   r   r   r   	connected   s   
zBaseProtocol.connectedc                 C   s   | j S )Nr
   r   r   r   r   writing_paused    s   zBaseProtocol.writing_pausedc                 C   s   | j rJ d| _ d S NTr   r   r   r   r   pause_writing$   s   

zBaseProtocol.pause_writingc                 C   sB   | j sJ d| _ | j}|d urd | _| s|d  d S d S d S r   )r
   r   done
set_resultr   waiterr   r   r   resume_writing(   s   
zBaseProtocol.resume_writingc              
   C   sJ   | j s!| jd ur#z| j  W n tttfy   Y nw d| _ d S d S d S r   )r   r   pause_readingAttributeErrorNotImplementedErrorRuntimeErrorr   r   r   r   r    2      
zBaseProtocol.pause_readingc              
   C   sJ   | j r!| jd ur#z| j  W n tttfy   Y nw d| _ d S d S d S r   )r   r   resume_readingr!   r"   r#   r   r   r   r   r%   :   r$   zBaseProtocol.resume_readingr   c                 C   s    t tj|}t|d || _d S r   )r   asyncio	Transportr   r   )r   r   trr   r   r   connection_madeB   s   

zBaseProtocol.connection_madeexcc                 C   s^   d | _ | jsd S | j}|d u rd S d | _| rd S |d u r%|d  d S t|td| d S NzConnection lost)r   r
   r   r   r   r   ConnectionError)r   r*   r   r   r   r   connection_lostG   s    zBaseProtocol.connection_lostc                    sP   | j d u r
td| jsd S | j}|d u r| j }|| _t|I d H  d S r+   )r   r   r
   r   r	   Zcreate_futurer&   shieldr   r   r   r   _drain_helper[   s   

zBaseProtocol._drain_helper)r   N)__name__
__module____qualname__	__slots__r&   ZAbstractEventLoopr   propertyboolr   r   r   r   r    r%   ZBaseTransportr)   r   BaseExceptionr-   r/   r   r   r   r   r   	   s    	




r   )r&   typingr   r   Zclient_exceptionsr   Zhelpersr   Ztcp_helpersr   Protocolr   r   r   r   r   <module>   s    