AlkantarClanX12

Your IP : 13.59.234.182


Current Path : /opt/alt/python33/lib64/python3.3/__pycache__/
Upload File :
Current File : //opt/alt/python33/lib64/python3.3/__pycache__/asyncore.cpython-33.pyo

�
��fQc@sdZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZeee
eeeef�ZyeWnek
r�iZYnXdd�ZGdd�de�ZeeefZdd	�Zd
d�Z dd
�Z!dd�Z"de#dd�Z$de#dd�Z%e%Z&de'e#e#dd�Z(Gdd�d�Z)Gdd�de)�Z*dd�Z+e#e'dd�Z,ej-d krddl.Z.Gd!d"�d"�Z/Gd#d$�d$e)�Z0ndS(%u�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.
iN(
uEALREADYuEINPROGRESSuEWOULDBLOCKu
ECONNRESETuEINVALuENOTCONNu	ESHUTDOWNuEISCONNuEBADFuECONNABORTEDuEPIPEuEAGAINu	errorcodec
CsOytj|�SWn7tttfk
rJ|tkr>t|Sd|SYnXdS(NuUnknown error %s(uosustrerroru
ValueErroru
OverflowErroru	NameErroru	errorcode(uerr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu	_strerrorDsu	_strerrorcBs|EeZdZdS(uExitNowN(u__name__u
__module__u__qualname__(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuExitNowLsuExitNowcCs;y|j�Wn&tk
r%�Yn|j�YnXdS(N(uhandle_read_eventu_reraised_exceptionsuhandle_error(uobj((u-/opt/alt/python33/lib64/python3.3/asyncore.pyureadQs
ureadcCs;y|j�Wn&tk
r%�Yn|j�YnXdS(N(uhandle_write_eventu_reraised_exceptionsuhandle_error(uobj((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuwriteYs
uwritecCs;y|j�Wn&tk
r%�Yn|j�YnXdS(N(uhandle_expt_eventu_reraised_exceptionsuhandle_error(uobj((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
_exceptionas
u
_exceptioncCs�yz|tj@r|j�n|tj@r7|j�n|tj@rQ|j�n|tjtjBtj	B@ry|j
�nWnwtjk
r�}z/|j
dtkr�|j�n
|j
�WYdd}~Xn&tk
r��Yn|j�YnXdS(Ni(uselectuPOLLINuhandle_read_eventuPOLLOUTuhandle_write_eventuPOLLPRIuhandle_expt_eventuPOLLHUPuPOLLERRuPOLLNVALuhandle_closeusocketuerroruargsu
_DISCONNECTEDuhandle_erroru_reraised_exceptions(uobjuflagsue((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu	readwriteis"







u	readwritegc	
Cs�|dkrt}n|r�g}g}g}x�t|j��D]v\}}|j�}|j�}|rz|j|�n|r�|jr�|j|�n|s�|r@|j|�q@q@Wg|ko�|ko�|knr�tj	|�dSy%t
j
||||�\}}}Wntk
r/dSYnXx9|D]1}|j|�}|dkr^q7nt
|�q7Wx9|D]1}|j|�}|dkr�qsnt|�qsWx<|D]1}|j|�}|dkr�q�nt|�q�WndS(N(uNoneu
socket_mapulistuitemsureadableuwritableuappendu	acceptingutimeusleepuselectuInterruptedErrorugetureaduwriteu
_exception(	utimeoutumapuruwueufduobjuis_ruis_w((u-/opt/alt/python33/lib64/python3.3/asyncore.pyupoll}sJ	'
%
	


upollcCsK|dkrt}n|dk	r4t|d�}ntj�}|rGx�t|j��D]t\}}d}|j�r�|tjtj	BO}n|j
�r�|jr�|tjO}n|rY|j
||�qYqYWy|j|�}Wntk
r�g}YnXxE|D]:\}}|j|�}|dkr3qnt||�qWndS(Ni�i(uNoneu
socket_mapuintuselectupollulistuitemsureadableuPOLLINuPOLLPRIuwritableu	acceptinguPOLLOUTuregisteruInterruptedErrorugetu	readwrite(utimeoutumapupollsterufduobjuflagsur((u-/opt/alt/python33/lib64/python3.3/asyncore.pyupoll2�s.	
upoll2g>@cCs�|dkrt}n|r3ttd�r3t}nt}|dkrbxJ|r^|||�qHWn0x-|r�|dkr�|||�|d}qeWdS(Nupollii(uNoneu
socket_mapuhasattruselectupoll2upoll(utimeoutuuse_pollumapucountupoll_fun((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuloop�s			
uloopcBs�|EeZdZdBZdBZdBZdBZdBZdAZ
edg�ZdAdAdd�Z
dd�ZeZdAdd�ZdAdd	�Zejejd
d�ZdAdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Z d"d#�Z!d$d%�Z"d&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/dAS(Cu
dispatcheruwarningcCs�|dkrt|_n	||_d|_|r�|jd�|j||�d|_y|j�|_	Wq�t
jk
r�}z:|jdt
tfkr�d|_n|j|��WYdd}~Xq�Xn	d|_
dS(NiTF(uNoneu
socket_mapu_mapu_filenousetblockingu
set_socketuTrueu	connectedugetpeernameuaddrusocketuerroruargsuENOTCONNuEINVALuFalseudel_channel(uselfusockumapuerr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__init__�s 		
	
udispatcher.__init__c
Cs�|jjd|jjg}|jr?|jr?|jd�n|jrX|jd�n|jdk	r�y|jd|j�Wq�tk
r�|jt	|j��Yq�Xnddj
|�t|�fS(Nu.u	listeningu	connectedu%s:%du<%s at %#x>u (u	__class__u
__module__u__name__u	acceptinguaddruappendu	connecteduNoneu	TypeErrorureprujoinuid(uselfustatus((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__repr__s	
udispatcher.__repr__cCs)|dkr|j}n|||j<dS(N(uNoneu_mapu_fileno(uselfumap((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuadd_channelsudispatcher.add_channelcCsD|j}|dkr!|j}n||kr7||=nd|_dS(N(u_filenouNoneu_map(uselfumapufd((u-/opt/alt/python33/lib64/python3.3/asyncore.pyudel_channels	
udispatcher.del_channelcCs?||f|_tj||�}|jd�|j|�dS(Ni(ufamily_and_typeusocketusetblockingu
set_socket(uselfufamilyutypeusock((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
create_sockets
udispatcher.create_socketcCs)||_|j�|_|j|�dS(N(usocketufilenou_filenouadd_channel(uselfusockumap((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
set_socket%s	udispatcher.set_socketcCsUy9|jjtjtj|jjtjtj�dB�Wntjk
rPYnXdS(Ni(usocketu
setsockoptu
SOL_SOCKETuSO_REUSEADDRu
getsockoptuerror(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuset_reuse_addr+s	udispatcher.set_reuse_addrcCsdS(NT(uTrue(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyureadable<sudispatcher.readablecCsdS(NT(uTrue(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuwritable?sudispatcher.writablecCs=d|_tjdkr-|dkr-d}n|jj|�S(NuntiT(uTrueu	acceptinguosunameusocketulisten(uselfunum((u-/opt/alt/python33/lib64/python3.3/asyncore.pyulistenFs		udispatcher.listencCs||_|jj|�S(N(uaddrusocketubind(uselfuaddr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyubindLs	udispatcher.bindcCs�d|_d|_|jj|�}|tttfksT|t	krat
jdkra||_dS|dt
fkr�||_|j�ntj|t|��dS(NuntuceiFT(untuce(uFalseu	connecteduTrueu
connectingusocketu
connect_exuEINPROGRESSuEALREADYuEWOULDBLOCKuEINVALuosunameuaddruEISCONNuhandle_connect_eventuerroru	errorcode(uselfuaddressuerr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuconnectPs				
udispatcher.connectcCs�y|jj�\}}Wn`tk
r1dSYnUtjk
r{}z(|jdtttfkrfdS�WYdd}~XnX||fSdS(Ni(	usocketuacceptu	TypeErroruNoneuerroruargsuEWOULDBLOCKuECONNABORTEDuEAGAIN(uselfuconnuaddruwhy((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuaccept^s
udispatcher.acceptcCs�y|jj|�}|SWnctjk
r}z@|jdtkrIdS|jdtkrj|j�dS�WYdd}~XnXdS(Ni(usocketusenduerroruargsuEWOULDBLOCKu
_DISCONNECTEDuhandle_close(uselfudatauresultuwhy((u-/opt/alt/python33/lib64/python3.3/asyncore.pyusendls
udispatcher.sendcCs�y.|jj|�}|s)|j�dS|SWnLtjk
r|}z)|jdtkrg|j�dS�WYdd}~XnXdS(Nsi(usocketurecvuhandle_closeuerroruargsu
_DISCONNECTED(uselfubuffer_sizeudatauwhy((u-/opt/alt/python33/lib64/python3.3/asyncore.pyurecvys

udispatcher.recvcCs�d|_d|_d|_|j�y|jj�WnGtjk
r}z$|jdt	t
fkrm�nWYdd}~XnXdS(NiF(uFalseu	connectedu	acceptingu
connectingudel_channelusocketucloseuerroruargsuENOTCONNuEBADF(uselfuwhy((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuclose�s			
udispatcher.closec
Cs�yt|j|�}Wn.tk
rFtd|jj|f��Yn9Xdi|jjd6|d6}tj|tdd�|SdS(Nu!%s instance has no attribute '%s'uA%(me)s.%(attr)s is deprecated; use %(me)s.socket.%(attr)s insteadumeuattru
stackleveli(ugetattrusocketuAttributeErroru	__class__u__name__uwarningsuwarnuDeprecationWarning(uselfuattruretattrumsg((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__getattr__�s
udispatcher.__getattr__cCstjjdt|��dS(Nulog: %s
(usysustderruwriteustr(uselfumessage((u-/opt/alt/python33/lib64/python3.3/asyncore.pyulog�sudispatcher.loguinfocCs*||jkr&td||f�ndS(Nu%s: %s(uignore_log_typesuprint(uselfumessageutype((u-/opt/alt/python33/lib64/python3.3/asyncore.pyulog_info�sudispatcher.log_infocCsP|jr|j�n6|jsB|jr5|j�n|j�n
|j�dS(N(u	acceptingu
handle_acceptu	connectedu
connectinguhandle_connect_eventuhandle_read(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_read_event�s	
		

udispatcher.handle_read_eventcCsb|jjtjtj�}|dkrBtj|t|���n|j�d|_d|_
dS(NiTF(usocketu
getsockoptu
SOL_SOCKETuSO_ERRORuerroru	_strerroruhandle_connectuTrueu	connecteduFalseu
connecting(uselfuerr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_connect_event�s
	udispatcher.handle_connect_eventcCs=|jr
dS|js/|jr/|j�q/n|j�dS(N(u	acceptingu	connectedu
connectinguhandle_connect_eventuhandle_write(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_write_event�s			udispatcher.handle_write_eventcCsB|jjtjtj�}|dkr4|j�n
|j�dS(Ni(usocketu
getsockoptu
SOL_SOCKETuSO_ERRORuhandle_closeuhandle_expt(uselfuerr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_expt_event�s
udispatcher.handle_expt_eventcCsnt�\}}}}yt|�}Wndt|�}YnX|jd||||fd�|j�dS(Nu)<__repr__(self) failed for object at %0x>u:uncaptured python exception, closing channel %s (%s:%s %s)uerror(ucompact_tracebackurepruidulog_infouhandle_close(uselfunilutuvutbinfou	self_repr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_error�sudispatcher.handle_errorcCs|jdd�dS(Nu!unhandled incoming priority eventuwarning(ulog_info(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_expt�sudispatcher.handle_exptcCs|jdd�dS(Nuunhandled read eventuwarning(ulog_info(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_read�sudispatcher.handle_readcCs|jdd�dS(Nuunhandled write eventuwarning(ulog_info(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_write�sudispatcher.handle_writecCs|jdd�dS(Nuunhandled connect eventuwarning(ulog_info(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_connect�sudispatcher.handle_connectcCs,|j�}|dk	r(|j|�ndS(N(uacceptuNoneuhandle_accepted(uselfupair((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
handle_accept�sudispatcher.handle_acceptcCs|j�|jdd�dS(Nuunhandled accepted eventuwarning(ucloseulog_info(uselfusockuaddr((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_accepteds
udispatcher.handle_acceptedcCs|jdd�|j�dS(Nuunhandled close eventuwarning(ulog_infouclose(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_closesudispatcher.handle_closeNF(0u__name__u
__module__u__qualname__uFalseudebugu	connectedu	acceptingu
connectinguclosinguNoneuaddru	frozensetuignore_log_typesu__init__u__repr__u__str__uadd_channeludel_channelusocketuAF_INETuSOCK_STREAMu
create_socketu
set_socketuset_reuse_addrureadableuwritableulistenubinduconnectuacceptusendurecvucloseu__getattr__ulogulog_infouhandle_read_eventuhandle_connect_eventuhandle_write_eventuhandle_expt_eventuhandle_erroruhandle_exptuhandle_readuhandle_writeuhandle_connectu
handle_acceptuhandle_accepteduhandle_close(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
dispatcher�sN 
	

u
dispatchercBsV|EeZdZdddd�Zdd�Zdd�Zdd�Zd	d
�ZdS(udispatcher_with_sendcCs tj|||�d|_dS(Ns(u
dispatcheru__init__u
out_buffer(uselfusockumap((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__init__sudispatcher_with_send.__init__cCs?d}tj||jdd��}|j|d�|_dS(Nii(u
dispatcherusendu
out_buffer(uselfunum_sent((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
initiate_sendsu"dispatcher_with_send.initiate_sendcCs|j�dS(N(u
initiate_send(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuhandle_writesu!dispatcher_with_send.handle_writecCs|jpt|j�S(N(u	connectedulenu
out_buffer(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuwritablesudispatcher_with_send.writablecCsA|jr#|jdt|��n|j||_|j�dS(Nu
sending %s(udebugulog_infourepru
out_bufferu
initiate_send(uselfudata((u-/opt/alt/python33/lib64/python3.3/asyncore.pyusend s	udispatcher_with_send.sendN(	u__name__u
__module__u__qualname__uNoneu__init__u
initiate_senduhandle_writeuwritableusend(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asyncore.pyudispatcher_with_sends
udispatcher_with_sendcCs�tj�\}}}g}|s0td��nxD|rv|j|jjj|jjjt|j	�f�|j
}q3W~|d\}}}djdd�|D��}|||f|||fS(Nutraceback does not existiu cSsg|]}d|�qS(u
[%s|%s|%s]((u.0ux((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
<listcomp>;s	u%compact_traceback.<locals>.<listcomp>i����(usysuexc_infouAssertionErroruappendutb_frameuf_codeuco_filenameuco_nameustru	tb_linenoutb_nextujoin(utuvutbutbinfoufileufunctionulineuinfo((u-/opt/alt/python33/lib64/python3.3/asyncore.pyucompact_traceback*s	
ucompact_tracebackcCs�|dkrt}nx�t|j��D]�}y|j�Wq(tk
r�}z'|jdtkrgn|ss�nWYdd}~Xq(tk
r��Yq(|s��nYq(Xq(W|j	�dS(Ni(
uNoneu
socket_mapulistuvaluesucloseuOSErroruargsuEBADFu_reraised_exceptionsuclear(umapu
ignore_allux((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu	close_all>s 	
u	close_alluposixcBsk|EeZdZdd�Zdd�Zdd�Zd
dd�ZeZeZ	d	d
�Z
dd�Zd
S(ufile_wrappercCstj|�|_dS(N(uosudupufd(uselfufd((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__init__esufile_wrapper.__init__cGstj|j|�S(N(uosureadufd(uselfuargs((u-/opt/alt/python33/lib64/python3.3/asyncore.pyurecvhsufile_wrapper.recvcGstj|j|�S(N(uosuwriteufd(uselfuargs((u-/opt/alt/python33/lib64/python3.3/asyncore.pyusendksufile_wrapper.sendcCs9|tjkr)|tjkr)|r)dStd��dS(Niu-Only asyncore specific behaviour implemented.(usocketu
SOL_SOCKETuSO_ERRORuNotImplementedError(uselfuleveluoptnameubuflen((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu
getsockoptns
ufile_wrapper.getsockoptcCstj|j�dS(N(uosucloseufd(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyucloseysufile_wrapper.closecCs|jS(N(ufd(uself((u-/opt/alt/python33/lib64/python3.3/asyncore.pyufileno|sufile_wrapper.filenoN(u__name__u
__module__u__qualname__u__init__urecvusenduNoneu
getsockoptureaduwriteucloseufileno(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asyncore.pyufile_wrapper`sufile_wrappercBs/|EeZdZddd�Zdd�ZdS(ufile_dispatchercCs�tj|d|�d|_y|j�}Wntk
r@YnX|j|�tj|tj	d�}|t
jB}tj|tj|�dS(NiT(
u
dispatcheru__init__uNoneuTrueu	connectedufilenouAttributeErroruset_fileufcntluF_GETFLuosu
O_NONBLOCKuF_SETFL(uselfufdumapuflags((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu__init__�s	


ufile_dispatcher.__init__cCs/t|�|_|jj�|_|j�dS(N(ufile_wrapperusocketufilenou_filenouadd_channel(uselfufd((u-/opt/alt/python33/lib64/python3.3/asyncore.pyuset_file�sufile_dispatcher.set_fileN(u__name__u
__module__u__qualname__uNoneu__init__uset_file(u
__locals__((u-/opt/alt/python33/lib64/python3.3/asyncore.pyufile_dispatchers
ufile_dispatcher(1u__doc__uselectusocketusysutimeuwarningsuosuerrnouEALREADYuEINPROGRESSuEWOULDBLOCKu
ECONNRESETuEINVALuENOTCONNu	ESHUTDOWNuEISCONNuEBADFuECONNABORTEDuEPIPEuEAGAINu	errorcodeu	frozensetu
_DISCONNECTEDu
socket_mapu	NameErroru	_strerroru	ExceptionuExitNowuKeyboardInterruptu
SystemExitu_reraised_exceptionsureaduwriteu
_exceptionu	readwriteuNoneupollupoll2upoll3uFalseuloopu
dispatcherudispatcher_with_senducompact_tracebacku	close_allunameufcntlufile_wrapperufile_dispatcher(((u-/opt/alt/python33/lib64/python3.3/asyncore.pyu<module>/sBX
*�9