ok

Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/usr/lib64/python2.7/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/usr/lib64/python2.7/asyncore.pyc

�
\цdc@sdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZmZeee
eeeef�ZyeWnek
r�iZnXd�Zdefd��YZeeefZd�Z d�Z!d	�Z"d
�Z#de$d�Z%de$d
�Z&e&Z'de(e$e$d�Z)dfd��YZ*de*fd��YZ+d�Z,e$e(d�Z-ej.dkr�ddl/Z/dfd��YZ0de*fd��YZ1ndS(s�Basic infrastructure for asynchronous socket service clients and servers.

There are only two ways to have a program on a single processor do "more
than one thing at a time".  Multi-threaded programming is the simplest and
most popular way to do it, but there is another very different technique,
that lets you have nearly all the advantages of multi-threading, without
actually using multiple threads. it's really only practical if your program
is largely I/O bound. If your program is CPU bound, then pre-emptive
scheduled threads are probably what you really need. Network servers are
rarely CPU-bound, however.

If your operating system supports the select() system call in its I/O
library (and nearly all do), then you can use it to juggle multiple
communication channels at once; doing other work while your I/O is taking
place in the "background."  Although this strategy can seem strange and
complex, especially at first, it is in many ways easier to understand and
control than multi-threaded programming. The module documented here solves
many of the difficult problems for you, making the task of building
sophisticated high-performance network servers and clients a snap.
i����N(tEALREADYtEINPROGRESStEWOULDBLOCKt
ECONNRESETtEINVALtENOTCONNt	ESHUTDOWNtEINTRtEISCONNtEBADFtECONNABORTEDtEPIPEtEAGAINt	errorcodecCsKytj|�SWn3tttfk
rF|tkr>t|Sd|SXdS(NsUnknown error %s(toststrerrort
ValueErrort
OverflowErrort	NameErrorR
(terr((s /usr/lib64/python2.7/asyncore.pyt	_strerrorDstExitNowcBseZRS((t__name__t
__module__(((s /usr/lib64/python2.7/asyncore.pyRLscCs9y|j�Wn$tk
r$�n|j�nXdS(N(thandle_read_eventt_reraised_exceptionsthandle_error(tobj((s /usr/lib64/python2.7/asyncore.pytreadQs
cCs9y|j�Wn$tk
r$�n|j�nXdS(N(thandle_write_eventRR(R((s /usr/lib64/python2.7/asyncore.pytwriteYs
cCs9y|j�Wn$tk
r$�n|j�nXdS(N(thandle_expt_eventRR(R((s /usr/lib64/python2.7/asyncore.pyt
_exceptionas
cCs�yz|tj@r|j�n|tj@r7|j�n|tj@rQ|j�n|tjtjBtj	B@ry|j
�nWnctjk
r�}|j
dtkr�|j�q�|j
�n$tk
r��n|j�nXdS(Ni(tselecttPOLLINRtPOLLOUTRtPOLLPRIRtPOLLHUPtPOLLERRtPOLLNVALthandle_closetsocketterrortargst
_DISCONNECTEDRR(Rtflagste((s /usr/lib64/python2.7/asyncore.pyt	readwriteis"








gc
Cs|dkrt}n|r�g}g}g}x�|j�D]v\}}|j�}|j�}|rt|j|�n|r�|jr�|j|�n|s�|r:|j|�q:q:Wg|ko�|ko�|knr�tj|�dSy%t	j	||||�\}}}Wn3t	j
k
rF}	|	jdtkr?�qGdSnXx9|D]1}|j
|�}|dkruqNnt|�qNWx9|D]1}|j
|�}|dkr�q�nt|�q�Wx<|D]1}|j
|�}|dkr�q�nt|�q�WndS(Ni(tNonet
socket_maptitemstreadabletwritabletappendt	acceptingttimetsleepR!R*R+RtgetRRR (
ttimeouttmaptrtwR.tfdRtis_rtis_wR((s /usr/lib64/python2.7/asyncore.pytpoll}sN	'
%


cCs}|dkrt}n|dk	r4t|d�}ntj�}|ryx�|j�D]�\}}d}|j�r�|tjtjBO}n|j	�r�|j
r�|tjO}n|rS|tjtj
BtjBO}|j||�qSqSWy|j|�}Wn5tjk
r0}|jdtkr'�ng}nXxE|D]:\}}|j|�}|dkreq8nt||�q8WndS(Ni�i(R0R1tintR!RAR2R3R"R$R4R6R#R&R%R'tregisterR*R+RR9R/(R:R;tpollsterR>RR-R<R((s /usr/lib64/python2.7/asyncore.pytpoll2�s4	
g>@cCs�|dkrt}n|r3ttd�r3t}nt}|dkrbxJ|r^|||�qHWn0x-|r�|dkr�|||�|d}qeWdS(NRAii(R0R1thasattrR!RERA(R:tuse_pollR;tcounttpoll_fun((s /usr/lib64/python2.7/asyncore.pytloop�s			
t
dispatchercBsaeZeZeZeZeZeZd Z	e
dg�Zd d d�Zd�Z
e
Zd d�Zd d�Zd�Zd d�Zd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zdd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*RS(!twarningcCs�|dkrt|_n	||_d|_|r�|jd�|j||�t|_y|j�|_	Wq�t
jk
r�}|jdt
tfkr�t|_q�|j|��q�Xn	d|_
dS(Ni(R0R1t_mapt_filenotsetblockingt
set_sockettTruet	connectedtgetpeernametaddrR)R*R+RRtFalsetdel_channel(tselftsockR;R((s /usr/lib64/python2.7/asyncore.pyt__init__�s 		
	

cCs�|jjd|jjg}|jr?|jr?|jd�n|jrX|jd�n|jdk	r�y|jd|j�Wq�tk
r�|jt	|j��q�Xnddj
|�t|�fS(Nt.t	listeningRRs%s:%ds<%s at %#x>t (t	__class__RRR6RTR5RRR0t	TypeErrortreprtjointid(RWtstatus((s /usr/lib64/python2.7/asyncore.pyt__repr__	s	
cCs)|dkr|j}n|||j<dS(N(R0RMRN(RWR;((s /usr/lib64/python2.7/asyncore.pytadd_channelscCsD|j}|dkr!|j}n||kr7||=nd|_dS(N(RNR0RM(RWR;R>((s /usr/lib64/python2.7/asyncore.pyRVs	
cCs?||f|_tj||�}|jd�|j|�dS(Ni(tfamily_and_typeR)RORP(RWtfamilyttypeRX((s /usr/lib64/python2.7/asyncore.pyt
create_socket's
cCs)||_|j�|_|j|�dS(N(R)tfilenoRNRd(RWRXR;((s /usr/lib64/python2.7/asyncore.pyRP-s	cCsTy9|jjtjtj|jjtjtj�dB�Wntjk
rOnXdS(Ni(R)t
setsockoptt
SOL_SOCKETtSO_REUSEADDRt
getsockoptR*(RW((s /usr/lib64/python2.7/asyncore.pytset_reuse_addr3s	cCstS(N(RQ(RW((s /usr/lib64/python2.7/asyncore.pyR3DscCstS(N(RQ(RW((s /usr/lib64/python2.7/asyncore.pyR4GscCs=t|_tjdkr-|dkr-d}n|jj|�S(Ntnti(RQR6RtnameR)tlisten(RWtnum((s /usr/lib64/python2.7/asyncore.pyRqNs		cCs||_|jj|�S(N(RTR)tbind(RWRT((s /usr/lib64/python2.7/asyncore.pyRsTs	cCs�t|_t|_|jj|�}|tttfksT|t	krat
jdkra||_dS|dt
fkr�||_|j�ntj|t|��dS(NRotcei(sntRt(RURRRQt
connectingR)t
connect_exRRRRRRpRTRthandle_connect_eventR*R
(RWtaddressR((s /usr/lib64/python2.7/asyncore.pytconnectXs				
cCsty|jj�\}}WnJtk
r-dStjk
re}|jdtttfkr_dS�nX||fSdS(Ni(	R)tacceptR^R0R*R+RR
R(RWtconnRTtwhy((s /usr/lib64/python2.7/asyncore.pyRzfs
cCsry|jj|�}|SWnQtjk
rm}|jdtkrFdS|jdtkrg|j�dS�nXdS(Ni(R)tsendR*R+RR,R((RWtdatatresultR|((s /usr/lib64/python2.7/asyncore.pyR}ts
cCsoy.|jj|�}|s)|j�dS|SWn:tjk
rj}|jdtkrd|j�dS�nXdS(Nti(R)trecvR(R*R+R,(RWtbuffer_sizeR~R|((s /usr/lib64/python2.7/asyncore.pyR��s

cCsrt|_t|_t|_|j�y|jj�Wn5tjk
rm}|jdt	t
fkrn�qnnXdS(Ni(RURRR6RuRVR)tcloseR*R+RR	(RWR|((s /usr/lib64/python2.7/asyncore.pyR��s			
cCs�yt|j|�}Wn-tk
rEtd|jj|f��n9Xdi|jjd6|d6}tj|tdd�|SdS(Ns!%s instance has no attribute '%s'sB%(me)s.%(attr)s is deprecated. Use %(me)s.socket.%(attr)s instead.tmetattrt
stackleveli(tgetattrR)tAttributeErrorR]RtwarningstwarntDeprecationWarning(RWR�tretattrtmsg((s /usr/lib64/python2.7/asyncore.pyt__getattr__�s
cCstjjdt|��dS(Nslog: %s
(tsyststderrRtstr(RWtmessage((s /usr/lib64/python2.7/asyncore.pytlog�stinfocCs%||jkr!d||fGHndS(Ns%s: %s(tignore_log_types(RWR�Rg((s /usr/lib64/python2.7/asyncore.pytlog_info�scCsP|jr|j�n6|jsB|jr5|j�n|j�n
|j�dS(N(R6t
handle_acceptRRRuRwthandle_read(RW((s /usr/lib64/python2.7/asyncore.pyR�s	
		

cCsb|jjtjtj�}|dkrBtj|t|���n|j�t|_t	|_
dS(Ni(R)RmRktSO_ERRORR*Rthandle_connectRQRRRURu(RWR((s /usr/lib64/python2.7/asyncore.pyRw�s
	cCs=|jr
dS|js/|jr/|j�q/n|j�dS(N(R6RRRuRwthandle_write(RW((s /usr/lib64/python2.7/asyncore.pyR�s			cCsB|jjtjtj�}|dkr4|j�n
|j�dS(Ni(R)RmRkR�R(thandle_expt(RWR((s /usr/lib64/python2.7/asyncore.pyR�s
cCsmt�\}}}}yt|�}Wndt|�}nX|jd||||fd�|j�dS(Ns)<__repr__(self) failed for object at %0x>s:uncaptured python exception, closing channel %s (%s:%s %s)R*(tcompact_tracebackR_RaR�R((RWtniltttvttbinfot	self_repr((s /usr/lib64/python2.7/asyncore.pyR�scCs|jdd�dS(Ns!unhandled incoming priority eventRL(R�(RW((s /usr/lib64/python2.7/asyncore.pyR��scCs|jdd�dS(Nsunhandled read eventRL(R�(RW((s /usr/lib64/python2.7/asyncore.pyR��scCs|jdd�dS(Nsunhandled write eventRL(R�(RW((s /usr/lib64/python2.7/asyncore.pyR��scCs|jdd�dS(Nsunhandled connect eventRL(R�(RW((s /usr/lib64/python2.7/asyncore.pyR�scCs|jdd�dS(Nsunhandled accept eventRL(R�(RW((s /usr/lib64/python2.7/asyncore.pyR�scCs|jdd�|j�dS(Nsunhandled close eventRL(R�R�(RW((s /usr/lib64/python2.7/asyncore.pyR(sN(+RRRUtdebugRRR6RutclosingR0RTt	frozensetR�RYRct__str__RdRVRhRPRnR3R4RqRsRyRzR}R�R�R�R�R�RRwRRRR�R�R�R�R�R((((s /usr/lib64/python2.7/asyncore.pyRK�sL 	
										
		
												tdispatcher_with_sendcBs;eZddd�Zd�Zd�Zd�Zd�ZRS(cCs tj|||�d|_dS(NR�(RKRYt
out_buffer(RWRXR;((s /usr/lib64/python2.7/asyncore.pyRYscCs3d}tj||jd �}|j||_dS(Nii(RKR}R�(RWtnum_sent((s /usr/lib64/python2.7/asyncore.pyt
initiate_sendscCs|j�dS(N(R�(RW((s /usr/lib64/python2.7/asyncore.pyR�scCs|jpt|j�S(N(RRtlenR�(RW((s /usr/lib64/python2.7/asyncore.pyR4scCsA|jr#|jdt|��n|j||_|j�dS(Ns
sending %s(R�R�R_R�R�(RWR~((s /usr/lib64/python2.7/asyncore.pyR}"s	N(RRR0RYR�R�R4R}(((s /usr/lib64/python2.7/asyncore.pyR�s
			c	Cs�tj�\}}}g}|s0td��nxD|rv|j|jjj|jjjt|j	�f�|j
}q3W~|d\}}}djg|D]}d|^q��}|||f|||fS(Nstraceback does not existi����R\s
[%s|%s|%s](R�texc_infotAssertionErrorR5ttb_frametf_codetco_filenametco_nameR�t	tb_linenottb_nextR`(	R�R�ttbR�tfiletfunctiontlinetxR�((s /usr/lib64/python2.7/asyncore.pyR�,s	
&cCs�|dkrt}nx|j�D]q}y|j�Wq"tk
rm}|jdtkr^q�|s��q�q"tk
r��q"|s��q�q"Xq"W|j�dS(Ni(	R0R1tvaluesR�tOSErrorR+R	Rtclear(R;t
ignore_allR�((s /usr/lib64/python2.7/asyncore.pyt	close_all@s 		
tposixtfile_wrappercBsMeZd�Zd�Zd�Zdd�ZeZeZd�Z	d�Z
RS(cCstj|�|_dS(N(RtdupR>(RWR>((s /usr/lib64/python2.7/asyncore.pyRYgscGstj|j|�S(N(RRR>(RWR+((s /usr/lib64/python2.7/asyncore.pyR�jscGstj|j|�S(N(RRR>(RWR+((s /usr/lib64/python2.7/asyncore.pyR}mscCs9|tjkr)|tjkr)|r)dStd��dS(Nis-Only asyncore specific behaviour implemented.(R)RkR�tNotImplementedError(RWtleveltoptnametbuflen((s /usr/lib64/python2.7/asyncore.pyRmps
cCstj|j�dS(N(RR�R>(RW((s /usr/lib64/python2.7/asyncore.pyR�{scCs|jS(N(R>(RW((s /usr/lib64/python2.7/asyncore.pyRi~sN(RRRYR�R}R0RmRRR�Ri(((s /usr/lib64/python2.7/asyncore.pyR�bs				tfile_dispatchercBseZdd�Zd�ZRS(cCs�tj|d|�t|_y|j�}Wntk
r?nX|j|�tj|tj	d�}|t
jB}tj|tj|�dS(Ni(
RKRYR0RQRRRiR�tset_filetfcntltF_GETFLRt
O_NONBLOCKtF_SETFL(RWR>R;R-((s /usr/lib64/python2.7/asyncore.pyRY�s	


cCs/t|�|_|jj�|_|j�dS(N(R�R)RiRNRd(RWR>((s /usr/lib64/python2.7/asyncore.pyR��sN(RRR0RYR�(((s /usr/lib64/python2.7/asyncore.pyR��s
(2t__doc__R!R)R�R7R�RterrnoRRRRRRRRRR	R
RRR
R�R,R1RRt	ExceptionRtKeyboardInterruptt
SystemExitRRRR R/R0RAREtpoll3RURJRKR�R�R�RpR�R�R�(((s /usr/lib64/python2.7/asyncore.pyt<module>/sB^

					-!�3	

Zerion Mini Shell 1.0