ok

Mini Shell

Direktori : /opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/worker.cpython-38.pyc

U

'�7`V�@sdZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZdd	lmZdd
lmZddlmZzddlZejZWnek
r�dZeZYnXdZGd
d�dej �Z!Gdd�de!�Z"Gdd�de!�Z#dS)z%Async gunicorn worker for aiohttp.web�N)�	FrameType)�Any�	Awaitable�Callable�Optional�Union)�AccessLogFormat)�base)�web�)�
set_result)�Application)�AccessLogger)�GunicornWebWorker�GunicornUVLoopWebWorker�GunicornTokioWebWorkercs�eZdZejZejZe	e	dd��fdd�Z
dd��fdd�Zdd�dd	�Zdd�d
d�Z
dd�d
d�Zd eddd�dd�Zdd�dd�Zeedd�dd�Zeedd�dd�Zee	dd�dd��Zeed�dd�Z�ZS)!rN)�args�kw�returncs$t�j||�d|_d|_d|_dS�Nr)�super�__init__�_task�	exit_code�_notify_waiter)�selfrr��	__class__��A/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/worker.pyr%szGunicornWebWorker.__init__�rcs0t����t��|_t�|j�t���dS)N)�asyncio�get_event_loop�closeZnew_event_loop�loopZset_event_loopr�init_process�rrrrr%,s
zGunicornWebWorker.init_processcCs||j�|���|_z|j�|j�Wn tk
rD|j�d�YnXtj	dkrb|j�|j�
��|j��t�|j
�dS)NzException in gunicorn worker)��)r$Zcreate_task�_runrZrun_until_complete�	Exception�logZ	exception�sys�version_infoZshutdown_asyncgensr#�exitrr&rrr�run5s

zGunicornWebWorker.runc
�s�t|jt�r|j}n,t�|j�r0|��IdH}ntd�|j���|jjrP|j	j
nd}tj||j	|jj
||�|jj�d�}|��IdH|jjr�|�|j�nd}|}|dk	s�t�|j}|dk	s�t�|jD]0}tj||||jjddd�}|��IdHq�t��}z�|j�r�|��|j}	|jj�rF|	|jjk�rFd|_|j	�d|�nB|t��k�rz|j t�!�k�rzd|_|j	�d|�n|�"�IdH�qWnt#k
�r�YnX|�$�IdHdS)	NzUwsgi app should be either Application or async function returning Application, got {})ZloggerZkeepalive_timeout�
access_log�access_log_format�d�_)Zssl_contextZshutdown_timeoutFzMax requests, shutting down: %sz!Parent changed, shutting down: %s)%�
isinstanceZwsgir
r!Ziscoroutinefunction�RuntimeError�format�cfgZ	accesslogr+r0r
Z	AppRunnerZ	keepalive�_get_valid_log_formatr1ZsetupZis_ssl�_create_ssl_context�AssertionError�serverZsocketsZSockSiteZgraceful_timeout�start�os�getpid�aliveZnotifyZrequests_countZmax_requests�infoZppid�getppid�_wait_next_notify�
BaseExceptionZcleanup)
rZappr0Zrunner�ctxr;ZsockZsite�pidZcntrrrr)Bs\���
�zGunicornWebWorker._runzasyncio.Future[bool]cCs>|��|j}|dk	st�|��|_}|j�d|j|�|S)Ng�?)�_notify_waiter_doner$r:Z
create_futurerZ
call_later)rr$�waiterrrrrBzsz#GunicornWebWorker._wait_next_notify)rGrcCs4|dkr|j}|dk	r t|d�||jkr0d|_dS)NT)rr)rrGrrrrF�s

z%GunicornWebWorker._notify_waiter_donecCs�|j�tj|jtjd�|j�tj|jtjd�|j�tj|jtjd�|j�tj|j	tjd�|j�tj
|jtj
d�|j�tj|j
tjd�t�tjd�t�tj
d�dS�NF)r$Zadd_signal_handler�signal�SIGQUIT�handle_quit�SIGTERMZhandle_exit�SIGINT�SIGWINCHZhandle_winch�SIGUSR1Zhandle_usr1�SIGABRT�handle_abort�siginterruptr&rrr�init_signals�sL������zGunicornWebWorker.init_signals)�sig�framercCsd|_|j�|�|��dSrH)r?r7Z
worker_intrF�rrTrUrrrrK�szGunicornWebWorker.handle_quitcCs&d|_d|_|j�|�t�d�dS)NFr)r?rr7Zworker_abortr,r.rVrrrrQ�szGunicornWebWorker.handle_abort�
SSLContext)r7rcCs\tdkrtd��t�|j�}|�|j|j�|j|_|j	rF|�
|j	�|jrX|�|j�|S)z~Creates SSLContext instance for usage in asyncio.create_server.

        See ssl.SSLSocket.__init__ for more details.
        NzSSL is not supported.)
�sslr5rWZssl_versionZload_cert_chainZcertfileZkeyfileZ	cert_reqsZverify_modeZca_certsZload_verify_locationsZciphersZset_ciphers)r7rDrrrr9�sz%GunicornWebWorker._create_ssl_context)�
source_formatrcCs.||jkr|jSt�d|�r&td��n|SdS)Nz%\([^\)]+\)z�Gunicorn's style options in form of `%(name)s` are not supported for the log formatting. Please use aiohttp's format specification to configure access log formatting: http://docs.aiohttp.org/en/stable/logging.html#format-specification)�DEFAULT_GUNICORN_LOG_FORMAT�DEFAULT_AIOHTTP_LOG_FORMAT�re�search�
ValueError)rrYrrrr8�s
�z'GunicornWebWorker._get_valid_log_format)N)�__name__�
__module__�__qualname__rZ
LOG_FORMATr[�GunicornAccessLogFormat�defaultrZrrr%r/r)rBrrFrS�intrrKrQ�staticmethodr9�strr8�
__classcell__rrrrr s$	
8�� 	rcs"eZdZdd��fdd�Z�ZS)rNr cs0ddl}t����t�|���t���dSr)�uvloopr!r"r#�set_event_loop_policy�EventLoopPolicyrr%)rrhrrrr%�sz$GunicornUVLoopWebWorker.init_process�r_r`rar%rgrrrrr�srcs"eZdZdd��fdd�Z�ZS)rNr cs0ddl}t����t�|���t���dSr)�tokior!r"r#rirjrr%)rrlrrrr%�sz#GunicornTokioWebWorker.init_processrkrrrrr�sr)$�__doc__r!r=r\rIr,�typesr�typingrrrrrZgunicorn.configrrbZgunicorn.workersr	Zaiohttpr
ZhelpersrZweb_appr
Zweb_logrrXrW�ImportError�object�__all__ZWorkerrrrrrrr�<module>s0

@

Zerion Mini Shell 1.0