Your IP : 3.145.81.47


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/socketserver.cpython-35.opt-2.pyc



���]Z`�@sfdZddlZddlZddlZddlZyddlZWnek
rfddlZYnXddlm	Zdddddd	d
ddd
ddgZ
eed�r�e
jddddg�eed�r�ej
Zn	ejZGdd�d�ZGdd�de�ZGdd�de�ZGdd�d�ZGdd�d�ZGdd�dee�ZGdd�dee�ZGdd	�d	ee�ZGdd
�d
ee�Zeed�r#Gdd�de�ZGd d�de�ZGd!d�dee�ZGd"d�dee�ZGd#d�d�ZGd$d�de�ZGd%d
�d
e�ZdS)&z0.4�N)�	monotonic�
BaseServer�	TCPServer�	UDPServer�ForkingUDPServer�ForkingTCPServer�ThreadingUDPServer�ThreadingTCPServer�BaseRequestHandler�StreamRequestHandler�DatagramRequestHandler�ThreadingMixIn�ForkingMixIn�AF_UNIX�UnixStreamServer�UnixDatagramServer�ThreadingUnixStreamServer�ThreadingUnixDatagramServer�PollSelectorc@s�eZdZdZdd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �ZdS)!rNcCs.||_||_tj�|_d|_dS)NF)�server_address�RequestHandlerClass�	threading�Event�_BaseServer__is_shut_down�_BaseServer__shutdown_request)�selfrr�r�1/opt/alt/python35/lib64/python3.5/socketserver.py�__init__�s		zBaseServer.__init__cCsdS)Nr)rrrr�server_activate�szBaseServer.server_activateg�?cCs�|jj�zct��S}|j|tj�x6|jsg|j|�}|rZ|j�|j	�q2WWdQRXWdd|_|jj
�XdS)NF)r�clear�_ServerSelector�register�	selectors�
EVENT_READr�select�_handle_request_noblock�service_actions�set)rZ
poll_interval�selector�readyrrr�
serve_forever�s

	zBaseServer.serve_forevercCsd|_|jj�dS)NT)rr�wait)rrrr�shutdown�s	zBaseServer.shutdowncCsdS)Nr)rrrrr'�szBaseServer.service_actionsc
Cs�|jj�}|dkr'|j}n!|jdk	rHt||j�}|dk	rat�|}t��o}|j|tj�xR|j	|�}|r�|j
�S|dk	r�|t�}|dkr�|j�Sq�WWdQRXdS)Nr)�socket�
gettimeout�timeout�min�timer!r"r#r$r%r&�handle_timeout)rr0�deadliner)r*rrr�handle_requests"


zBaseServer.handle_requestcCs�y|j�\}}Wntk
r.dSYnX|j||�r�y|j||�Wq�|j||�|j|�Yq�Xn
|j|�dS)N)�get_request�OSError�verify_request�process_request�handle_error�shutdown_request)r�request�client_addressrrrr&,s
	z"BaseServer._handle_request_noblockcCsdS)Nr)rrrrr3@szBaseServer.handle_timeoutcCsdS)NTr)rr<r=rrrr8GszBaseServer.verify_requestcCs!|j||�|j|�dS)N)�finish_requestr;)rr<r=rrrr9OszBaseServer.process_requestcCsdS)Nr)rrrr�server_closeXszBaseServer.server_closecCs|j|||�dS)N)r)rr<r=rrrr>`szBaseServer.finish_requestcCs|j|�dS)N)�
close_request)rr<rrrr;dszBaseServer.shutdown_requestcCsdS)Nr)rr<rrrr@hszBaseServer.close_requestcCsPtdd�tddd�t|�ddl}|j�tdd�dS)N�-�(z4Exception happened during processing of request from�end� r)�print�	traceback�	print_exc)rr<r=rFrrrr:ls

zBaseServer.handle_error)�__name__�
__module__�__qualname__r0rrr+r-r'r5r&r3r8r9r?r>r;r@r:rrrrr�s -
	c@s�eZdZejZejZdZdZ	ddd�Z
dd�Zdd	�Zd
d�Z
dd
�Zdd�Zdd�Zdd�ZdS)r�FTc	Cshtj|||�tj|j|j�|_|rdy|j�|j�Wn|j��YnXdS)N)rrr.�address_family�socket_type�server_bindrr?)rrrZbind_and_activaterrrr�s

zTCPServer.__init__cCsN|jr%|jjtjtjd�|jj|j�|jj�|_dS)N�)�allow_reuse_addressr.�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�bindr�getsockname)rrrrrN�s	zTCPServer.server_bindcCs|jj|j�dS)N)r.�listen�request_queue_size)rrrrr�szTCPServer.server_activatecCs|jj�dS)N)r.�close)rrrrr?�szTCPServer.server_closecCs
|jj�S)N)r.�fileno)rrrrrY�szTCPServer.filenocCs
|jj�S)N)r.�accept)rrrrr6�szTCPServer.get_requestcCs:y|jtj�Wntk
r(YnX|j|�dS)N)r-r.�SHUT_WRr7r@)rr<rrrr;�s

zTCPServer.shutdown_requestcCs|j�dS)N)rX)rr<rrrr@�szTCPServer.close_requestN)rHrIrJr.�AF_INETrL�SOCK_STREAMrMrWrPrrNrr?rYr6r;r@rrrrrzs/		

c@sUeZdZdZejZdZdd�Zdd�Z	dd�Z
d	d
�ZdS)rFi cCs.|jj|j�\}}||jf|fS)N)r.�recvfrom�max_packet_size)r�dataZclient_addrrrrr6szUDPServer.get_requestcCsdS)Nr)rrrrrszUDPServer.server_activatecCs|j|�dS)N)r@)rr<rrrr;
szUDPServer.shutdown_requestcCsdS)Nr)rr<rrrr@szUDPServer.close_requestN)rHrIrJrPr.�
SOCK_DGRAMrMr_r6rr;r@rrrrr�s	c@sReZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dS)ri,NrBcCs|jdkrdSx|t|j�|jkr�y,tjdd�\}}|jj|�Wqtk
r{|jj�Yqtk
r�PYqXqWx||jj	�D]k}y/tj|tj
�\}}|jj|�Wq�tk
r�|jj|�Yq�tk
rYq�Xq�WdS)NrOr���)�active_children�len�max_children�os�waitpid�discard�ChildProcessErrorr r7�copy�WNOHANG)r�pid�_rrr�collect_childrens$




zForkingMixIn.collect_childrencCs|j�dS)N)rn)rrrrr3<szForkingMixIn.handle_timeoutcCs|j�dS)N)rn)rrrrr'CszForkingMixIn.service_actionscCs�tj�}|rN|jdkr-t�|_|jj|�|j|�dSy.|j||�|j|�tjd�Wn:z!|j	||�|j|�Wdtjd�XYnXdS)NrrO)
rf�forkrcr(�addr@r>r;�_exitr:)rr<r=rlrrrr9Js 

zForkingMixIn.process_request)
rHrIrJr0rcrernr3r'r9rrrrrs"c@s.eZdZdZdd�Zdd�ZdS)r
Fc	CsMy!|j||�|j|�Wn%|j||�|j|�YnXdS)N)r>r;r:)rr<r=rrr�process_request_threadjsz%ThreadingMixIn.process_request_threadcCs;tjd|jd||f�}|j|_|j�dS)N�target�args)r�Threadrr�daemon_threads�daemon�start)rr<r=�trrrr9wszThreadingMixIn.process_requestN)rHrIrJrvrrr9rrrrr
cs
c@seZdZdS)rN)rHrIrJrrrrrsc@seZdZdS)rN)rHrIrJrrrrr�sc@seZdZdS)rN)rHrIrJrrrrr�sc@seZdZdS)r	N)rHrIrJrrrrr	�sc@seZdZejZdS)rN)rHrIrJr.rrLrrrrr�sc@seZdZejZdS)rN)rHrIrJr.rrLrrrrr�sc@seZdZdS)rN)rHrIrJrrrrr�sc@seZdZdS)rN)rHrIrJrrrrr�sc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r
c
CsE||_||_||_|j�z|j�Wd|j�XdS)N)r<r=�server�setup�handle�finish)rr<r=rzrrrr�s			
zBaseRequestHandler.__init__cCsdS)Nr)rrrrr{�szBaseRequestHandler.setupcCsdS)Nr)rrrrr|�szBaseRequestHandler.handlecCsdS)Nr)rrrrr}�szBaseRequestHandler.finishN)rHrIrJrr{r|r}rrrrr
�s
c@s@eZdZd	ZdZdZdZdd�Zdd�ZdS)
rrOrNFcCs�|j|_|jdk	r.|jj|j�|jrS|jjtjtjd�|jj	d|j
�|_|jj	d|j�|_
dS)NT�rb�wb)r<�
connectionr0�
settimeout�disable_nagle_algorithmrQr.�IPPROTO_TCP�TCP_NODELAY�makefile�rbufsize�rfile�wbufsize�wfile)rrrrr{�s	
zStreamRequestHandler.setupcCsS|jjs5y|jj�Wntjk
r4YnX|jj�|jj�dS)N)r��closed�flushr.�errorrXr�)rrrrr}�s
zStreamRequestHandler.finishrb)	rHrIrJr�r�r0r�r{r}rrrrr�s
c@s(eZdZdd�Zdd�ZdS)rcCsGddlm}|j\|_|_||j�|_|�|_dS)Nr)�BytesIO)�ior�r<Zpacketr.r�r�)rr�rrrr{�szDatagramRequestHandler.setupcCs#|jj|jj�|j�dS)N)r.�sendtor��getvaluer=)rrrrr}�szDatagramRequestHandler.finishN)rHrIrJr{r}rrrrr�s) �__version__r.r#rf�errnor�ImportError�dummy_threadingr2r�__all__�hasattr�extendrr!�SelectSelectorrrrrr
rrrr	rrrrr
rrrrrr�<module>{sJ
	
	�~Q.+

?>