Your IP : 3.142.172.250


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



���]�N�@sddlZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZee
ee
eeeh�ZyeWnek
r�iZYnXdd�ZGdd�de�ZeeefZdd�Zd	d
�Zdd�Z d
d�Z!dddd�Z"dddd�Z#e#Z$dddddd�Z%Gdd�d�Z&Gdd�de&�Z'dd�Z(dddd�Z)ej*d krGd!d"�d"�Z+Gd#d$�d$e&�Z,dS)%�N)
�EALREADY�EINPROGRESS�EWOULDBLOCK�
ECONNRESET�EINVAL�ENOTCONN�	ESHUTDOWN�EISCONN�EBADF�ECONNABORTED�EPIPE�EAGAIN�	errorcodec
CsOytj|�SWn7tttfk
rJ|tkr>t|Sd|SYnXdS)NzUnknown error %s)�os�strerror�
ValueError�
OverflowError�	NameErrorr)�err�r�-/opt/alt/python35/lib64/python3.5/asyncore.py�	_strerrorDsrc@seZdZdS)�ExitNowN)�__name__�
__module__�__qualname__rrrrrLsrcCs;y|j�Wn&tk
r%�Yn|j�YnXdS)N)�handle_read_event�_reraised_exceptions�handle_error)�objrrr�readQs
r cCs;y|j�Wn&tk
r%�Yn|j�YnXdS)N)�handle_write_eventrr)rrrr�writeYs
r"cCs;y|j�Wn&tk
r%�Yn|j�YnXdS)N)�handle_expt_eventrr)rrrr�
_exceptionas
r$cCs�yn|tj@r|j�|tj@r1|j�|tj@rH|j�|tjtjBtj	B@rm|j
�Wnttk
r�}z/|jdt
kr�|j�n
|j
�WYdd}~Xn&tk
r��Yn|j�YnXdS)Nr)�select�POLLINr�POLLOUTr!�POLLPRIr#�POLLHUP�POLLERR�POLLNVAL�handle_close�OSError�args�
_DISCONNECTEDrr)r�flags�errr�	readwriteis"







r2gc	Cs�|dkrt}|r�g}g}g}x�t|j��D]m\}}|j�}|j�}|rt|j|�|r�|jr�|j|�|s�|r=|j|�q=Wg|ko�|ko�|knr�tj|�dSt	j	||||�\}}}x6|D].}|j
|�}|dkr2qt|�qWx6|D].}|j
|�}|dkrkqGt|�qGWx6|D].}|j
|�}|dkr�q�t
|�q�WdS)N)�
socket_map�list�items�readable�writable�append�	accepting�time�sleepr%�getr r"r$)	�timeout�map�r�wr1�fdrZis_rZis_wrrr�poll}sD

'
!


rBcCs|dkrt}|dk	r.t|d�}tj�}|rxt|j��D]k\}}d}|j�r�|tjtjBO}|j	�r�|j
r�|tjO}|rS|j||�qSW|j|�}x?|D]7\}}|j
|�}|dkrq�t||�q�WdS)Ni�r)r3�intr%rBr4r5r6r&r(r7r9r'�registerr<r2)r=r>ZpollsterrArr0r?rrr�poll2�s(
rEg>@FcCs�|dkrt}|r0ttd�r0t}nt}|dkr_xJ|r[|||�qEWn0x-|r�|dkr�|||�|d}qbWdS)NrBr�)r3�hasattrr%rErB)r=Zuse_pollr>�countZpoll_funrrr�loop�s		
rIc@s�eZdZdZdZdZdZdZdZe	dh�Z
dddd�Zdd�ZeZ
ddd	�Zdd
d�Zejejdd
�Zddd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'd(�Z d)d*�Z!d+d,�Z"d-d.�Z#d/d0�Z$d1d2�Z%d3d4�Z&d5d6�Z'd7d8�Z(d9d:�Z)d;d<�Z*d=d>�Z+d?d@�Z,dS)A�
dispatcherFN�warningcCs�|dkrt|_n	||_d|_|r�|jd�|j||�d|_y|j�|_Wq�tk
r�}z:|j	dt
tfkr�d|_n|j|��WYdd}~Xq�Xn	d|_
dS)NrTF)r3�_map�_fileno�setblocking�
set_socket�	connected�getpeername�addrr-r.rr�del_channel�socket)�self�sockr>rrrr�__init__�s 		
	
zdispatcher.__init__cCs�|jjd|jjg}|jr?|jr?|jd�n|jrU|jd�|jdk	r�y|jd|j�Wn(tk
r�|jt|j��YnXddj	|�t
|�fS)N�.Z	listeningrPz%s:%dz<%s at %#x>� )�	__class__rrr9rRr8rP�	TypeError�repr�join�id)rU�statusrrr�__repr__�s	

zdispatcher.__repr__cCs&|dkr|j}|||j<dS)N)rLrM)rUr>rrr�add_channels	zdispatcher.add_channelcCs>|j}|dkr|j}||kr1||=d|_dS)N)rMrL)rUr>rArrrrSs		zdispatcher.del_channelcCs?||f|_tj||�}|jd�|j|�dS)Nr)Zfamily_and_typerTrNrO)rU�family�typerVrrr�
create_sockets
zdispatcher.create_socketcCs)||_|j�|_|j|�dS)N)rT�filenorMra)rUrVr>rrrrO s	zdispatcher.set_socketcCsRy9|jjtjtj|jjtjtj�dB�Wntk
rMYnXdS)NrF)rT�
setsockopt�
SOL_SOCKET�SO_REUSEADDR�
getsockoptr-)rUrrr�set_reuse_addr&s	
zdispatcher.set_reuse_addrcCsdS)NTr)rUrrrr67szdispatcher.readablecCsdS)NTr)rUrrrr7:szdispatcher.writablecCs:d|_tjdkr*|dkr*d}|jj|�S)NT�nt�)r9r�namerT�listen)rU�numrrrrnAs	zdispatcher.listencCs||_|jj|�S)N)rRrT�bind)rUrRrrrrpGs	zdispatcher.bindcCs�d|_d|_|jj|�}|tttfksT|tkratj	dkra||_
dS|dtfkr�||_
|j�nt
|t|��dS)NFTrk�cer)rkrq)rP�
connectingrT�
connect_exrrrrrrmrRr	�handle_connect_eventr-r)rU�addressrrrr�connectKs				
zdispatcher.connectcCs�y|jj�\}}Wn]tk
r1dSYnRtk
rx}z(|jdtttfkrcdS�WYdd}~XnX||fSdS)Nr)rT�acceptr[r-r.rrr
)rU�connrR�whyrrrrwYs
zdispatcher.acceptcCs�y|jj|�}|SWn`tk
r|}z@|jdtkrFdS|jdtkrg|j�dS�WYdd}~XnXdS)Nr)rT�sendr-r.rr/r,)rU�data�resultryrrrrzgs
zdispatcher.sendcCs~y.|jj|�}|s)|j�dS|SWnItk
ry}z)|jdtkrd|j�dS�WYdd}~XnXdS)N�r)rT�recvr,r-r.r/)rUZbuffer_sizer{ryrrrr~ts

zdispatcher.recvcCs�d|_d|_d|_|j�|jdk	r�y|jj�WnAtk
r�}z!|jdtt	fkrv�WYdd}~XnXdS)NFr)
rPr9rrrSrT�closer-r.rr
)rUryrrrr�s			
zdispatcher.closecCstjjdt|��dS)Nzlog: %s
)�sys�stderrr"�str)rU�messagerrr�log�szdispatcher.log�infocCs'||jkr#td||f�dS)Nz%s: %s)�ignore_log_types�print)rUr�rcrrr�log_info�szdispatcher.log_infocCsM|jr|j�n3|js?|jr2|j�|j�n
|j�dS)N)r9�
handle_acceptrPrrrt�handle_read)rUrrrr�s	
		

zdispatcher.handle_read_eventcCs\|jjtjtj�}|dkr<t|t|���|j�d|_d|_dS)NrTF)	rTrirg�SO_ERRORr-r�handle_connectrPrr)rUrrrrrt�s
	zdispatcher.handle_connect_eventcCs7|jr
dS|js)|jr)|j�|j�dS)N)r9rPrrrt�handle_write)rUrrrr!�s			
zdispatcher.handle_write_eventcCsB|jjtjtj�}|dkr4|j�n
|j�dS)Nr)rTrirgr�r,�handle_expt)rUrrrrr#�s
zdispatcher.handle_expt_eventcCsnt�\}}}}yt|�}Wndt|�}YnX|jd||||fd�|j�dS)Nz)<__repr__(self) failed for object at %0x>z:uncaptured python exception, closing channel %s (%s:%s %s)�error)�compact_tracebackr\r^r�r,)rU�nil�t�v�tbinfoZ	self_reprrrrr�szdispatcher.handle_errorcCs|jdd�dS)Nz!unhandled incoming priority eventrK)r�)rUrrrr��szdispatcher.handle_exptcCs|jdd�dS)Nzunhandled read eventrK)r�)rUrrrr��szdispatcher.handle_readcCs|jdd�dS)Nzunhandled write eventrK)r�)rUrrrr��szdispatcher.handle_writecCs|jdd�dS)Nzunhandled connect eventrK)r�)rUrrrr��szdispatcher.handle_connectcCs)|j�}|dk	r%|j|�dS)N)rw�handle_accepted)rUZpairrrrr��szdispatcher.handle_acceptcCs|j�|jdd�dS)Nzunhandled accepted eventrK)rr�)rUrVrRrrrr��s
zdispatcher.handle_acceptedcCs|jdd�|j�dS)Nzunhandled close eventrK)r�r)rUrrrr,�szdispatcher.handle_close)-rrr�debugrPr9rr�closingrR�	frozensetr�rWr`�__str__rarSrT�AF_INET�SOCK_STREAMrdrOrjr6r7rnrprvrwrzr~rr�r�rrtr!r#rr�r�r�r�r�r�r,rrrrrJ�sL 
	
rJc@sReZdZdddd�Zdd�Zdd�Zdd	�Zd
d�ZdS)�dispatcher_with_sendNcCs tj|||�d|_dS)Nr})rJrW�
out_buffer)rUrVr>rrrrW�szdispatcher_with_send.__init__cCs?d}tj||jdd��}|j|d�|_dS)Nri)rJrzr�)rUZnum_sentrrr�
initiate_sendsz"dispatcher_with_send.initiate_sendcCs|j�dS)N)r�)rUrrrr�sz!dispatcher_with_send.handle_writecCs|jpt|j�S)N)rP�lenr�)rUrrrr7szdispatcher_with_send.writablecCs>|jr |jdt|��|j||_|j�dS)Nz
sending %s)r�r�r\r�r�)rUr{rrrrzs	zdispatcher_with_send.send)rrrrWr�r�r7rzrrrrr��s
r�cCs�tj�\}}}g}|s-td��xD|rs|j|jjj|jjjt|j	�f�|j
}q0W~|d\}}}djdd�|D��}|||f|||fS)Nztraceback does not existrFrYcSsg|]}d|�qS)z
[%s|%s|%s]r)�.0�xrrr�
<listcomp>)s	z%compact_traceback.<locals>.<listcomp>���)r��exc_info�AssertionErrorr8�tb_frame�f_code�co_filename�co_namer��	tb_lineno�tb_nextr])r�r��tbr��file�function�liner�rrrr�s	
r�cCs�|dkrt}x�t|j��D]}y|j�Wq%tk
r}z$|jdtkrdn	|sm�WYdd}~Xq%tk
r��Yq%|s��Yq%Xq%W|j�dS)Nr)	r3r4�valuesrr-r.r
r�clear)r>Z
ignore_allr�rrr�	close_all,s 
r��posixc@sseZdZdd�Zdd�Zdd�Zdd�Zd	d
d�ZeZeZ	dd
�Z
dd�Zd	S)�file_wrappercCstj|�|_dS)N)r�duprA)rUrArrrrWQszfile_wrapper.__init__cCs1|jdkr#tjd|t�|j�dS)Nrzunclosed file %r)rA�warnings�warn�ResourceWarningr)rUrrr�__del__Tszfile_wrapper.__del__cGstj|j|�S)N)rr rA)rUr.rrrr~Yszfile_wrapper.recvcGstj|j|�S)N)rr"rA)rUr.rrrrz\szfile_wrapper.sendNcCs9|tjkr)|tjkr)|r)dStd��dS)Nrz-Only asyncore specific behaviour implemented.)rTrgr��NotImplementedError)rU�levelZoptname�buflenrrrri_s
zfile_wrapper.getsockoptcCs0|jdkrdStj|j�d|_dS)NrrFr�)rArr)rUrrrrjszfile_wrapper.closecCs|jS)N)rA)rUrrrrepszfile_wrapper.fileno)rrrrWr�r~rzrir r"rrerrrrr�Lsr�c@s+eZdZddd�Zdd�ZdS)�file_dispatcherNcCsbtj|d|�d|_y|j�}Wntk
r@YnX|j|�tj|d�dS)NTF)rJrWrPre�AttributeError�set_filer�set_blocking)rUrAr>rrrrWus	

zfile_dispatcher.__init__cCs/t|�|_|jj�|_|j�dS)N)r�rTrerMra)rUrArrrr��szfile_dispatcher.set_file)rrrrWr�rrrrr�ssr�)-r%rTr�r:r�r�errnorrrrrrrr	r
rrr
rr�r/r3rr�	Exceptionr�KeyboardInterrupt�
SystemExitrr r"r$r2rBrEZpoll3rIrJr�r�r�rmr�r�rrrr�<module>1s>X
'�,'

?>