a
    nJh
  ã                   @   s’   d Z ddlZddlmZmZmZmZmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZmZmZ dd
lmZ dZG dd„ dƒZdS )zLow level HTTP server.é    N)ÚAnyÚ	AwaitableÚCallableÚDictÚListÚOptionalé   )ÚAbstractStreamWriter)Úget_running_loop)ÚRawRequestMessage)ÚStreamReader)ÚRequestHandlerÚ_RequestFactoryÚ_RequestHandler)ÚBaseRequest)ÚServerc                   @   sÄ   e Zd Zddddœeee eeej e	ddœdd„Z
eee dœdd	„ƒZeejdd
œdd„Zdeee ddœdd„Zeeeededœdd„Zddœdd„Zdee ddœdd„Zedœdd„ZdS )r   NF)Úrequest_factoryÚhandler_cancellationÚloop)Úhandlerr   r   r   ÚkwargsÚreturnc                K   s8   t |ƒ| _i | _|| _d| _|| _|p*| j| _|| _d S )Nr   )	r
   Ú_loopÚ_connectionsÚ_kwargsZrequests_countZrequest_handlerÚ_make_requestr   r   )Úselfr   r   r   r   r   © r   úD/var/www/shaz/venv/lib/python3.9/site-packages/aiohttp/web_server.pyÚ__init__   s    	
zServer.__init__)r   c                 C   s   t | j ¡ ƒS ©N)Úlistr   Úkeys)r   r   r   r   Úconnections!   s    zServer.connections)r   Ú	transportr   c                 C   s   || j |< d S r    ©r   )r   r   r$   r   r   r   Úconnection_made%   s    zServer.connection_made)r   Úexcr   c                 C   s   || j v r| j |= d S r    r%   )r   r   r'   r   r   r   Úconnection_lost*   s    
zServer.connection_lostzasyncio.Task[None])ÚmessageÚpayloadÚprotocolÚwriterÚtaskr   c                 C   s   t |||||| jƒS r    )r   r   )r   r)   r*   r+   r,   r-   r   r   r   r   0   s    zServer._make_requestc                 C   s   | j D ]}| ¡  qd S r    )r   Úclose)r   Úconnr   r   r   Úpre_shutdown:   s    
zServer.pre_shutdown)Útimeoutr   c                 ƒ   s2   ‡ fdd„| j D ƒ}tj|Ž I d H  | j  ¡  d S )Nc                 3   s   | ]}|  ˆ ¡V  qd S r    )Úshutdown)Ú.0r/   ©r1   r   r   Ú	<genexpr>?   ó    z"Server.shutdown.<locals>.<genexpr>)r   ÚasyncioZgatherÚclear)r   r1   Zcorosr   r4   r   r2   >   s    zServer.shutdownc                 C   s\   zt | fd| ji| j¤ŽW S  tyV   dd„ | j ¡ D ƒ}t | fd| ji|¤Ž Y S 0 d S )Nr   c                 S   s   i | ]\}}|d v r||“qS ))ÚdebugZaccess_log_classr   )r3   ÚkÚvr   r   r   Ú
<dictcomp>H   s   þz#Server.__call__.<locals>.<dictcomp>)r   r   r   Ú	TypeErrorÚitems)r   r   r   r   r   Ú__call__C   s    þzServer.__call__)N)N)Ú__name__Ú
__module__Ú__qualname__r   r   r   Úboolr7   ZAbstractEventLoopr   r   Úpropertyr   r   r#   Ú	Transportr&   ÚBaseExceptionr(   r   r   r	   r   r   r0   Úfloatr2   r?   r   r   r   r   r      s>   úøþ ÿþù
r   )Ú__doc__r7   Útypingr   r   r   r   r   r   Úabcr	   Zhelpersr
   Zhttp_parserr   Ústreamsr   Zweb_protocolr   r   r   Zweb_requestr   Ú__all__r   r   r   r   r   Ú<module>   s    