Ñò §ÚêLc@sËdZddkZddkZddkZddkZddkZddklZlZl Z l Z l Z l Z l Z lZlZlZlZyeWnej o hZnXd„Zdefd„ƒYZeeefZd„Zd„Zd „Zd „Zd ed „Zd ed „Z e Z!de"eed„Z#dfd„ƒYZ$de$fd„ƒYZ%d„Z&ee"d„Z'ei(djo9ddk)Z)dfd„ƒYZ*de$fd„ƒYZ+ndS(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( tEALREADYt EINPROGRESSt EWOULDBLOCKt ECONNRESETtENOTCONNt ESHUTDOWNtEINTRtEISCONNtEBADFt ECONNABORTEDt errorcodecCsOyti|ƒSWn7tttfj o"|tjo t|Sd|SXdS(NsUnknown error %s(toststrerrort ValueErrort OverflowErrort NameErrorR (terr((s /usr/lib64/python2.6/asyncore.pyt _strerror?s   tExitNowcBseZRS((t__name__t __module__(((s /usr/lib64/python2.6/asyncore.pyRGscCs;y|iƒWn&tj o ‚n|iƒnXdS(N(thandle_read_eventt_reraised_exceptionst handle_error(tobj((s /usr/lib64/python2.6/asyncore.pytreadLs cCs;y|iƒWn&tj o ‚n|iƒnXdS(N(thandle_write_eventRR(R((s /usr/lib64/python2.6/asyncore.pytwriteTs cCs;y|iƒWn&tj o ‚n|iƒnXdS(N(thandle_expt_eventRR(R((s /usr/lib64/python2.6/asyncore.pyt _exception\s cCsy‚|ti@o|iƒn|ti@o|iƒn|ti@o|iƒn|titiBti B@o|i ƒnWnxt i j oD}|i dtttttfjo|iƒqý|i ƒn'tj o ‚n|iƒnXdS(Ni(tselecttPOLLINRtPOLLOUTRtPOLLPRIRtPOLLHUPtPOLLERRtPOLLNVALt handle_closetsocketterrortargsRRRRR RR(Rtflagste((s /usr/lib64/python2.6/asyncore.pyt readwriteds$ gc Cs|djo t}n|oïg}g}g}x|iƒD]s\}}|iƒ}|iƒ}|o|i|ƒn|o|i|ƒn|p|o|i|ƒq=q=Wg|jo|jo |jnoti|ƒdSy%ti||||ƒ\}}}Wn7ti j o(} | i dt jo‚qOdSnXx;|D]3}|i |ƒ}|djoqVnt |ƒqVWx;|D]3}|i |ƒ}|djoq”nt|ƒq”Wx?|D]3}|i |ƒ}|djoqÒnt|ƒqÒWndS(Ni(tNonet socket_maptitemstreadabletwritabletappendttimetsleepRR'R(RtgetRRR( ttimeouttmaptrtwR*tfdRtis_rtis_wR((s /usr/lib64/python2.6/asyncore.pytpollysV     * %    c Cs…|djo t}n|dj ot|dƒ}ntiƒ}|o6x™|iƒD]‹\}}d}|iƒo|titiBO}n|i ƒo|ti O}n|o/|ti ti Bti BO}|i||ƒqXqXWy|i|ƒ}Wn9tij o*}|idtjo‚ng}nXxH|D]<\}}|i|ƒ}|djoq=nt||ƒq=WndS(Nièi(R,R-tintRR<R.R/RR!R0R R#R"R$tregisterR'R(RR4R+(R5R6tpollsterR9RR)R7R((s /usr/lib64/python2.6/asyncore.pytpoll2¥s8          g>@cCs¢|djo t}n|ottdƒo t}nt}|djo xP|o|||ƒqNWn4x0|o(|djo|||ƒ|d}qnWdS(NR<ii(R,R-thasattrRR@R<(R5tuse_pollR6tcounttpoll_fun((s /usr/lib64/python2.6/asyncore.pytloopÇs     t dispatchercBsUeZeZeZeZeZd Ze dgƒZ d d d„Z d„Z d d„Z d d„Zd„Zd d„Zd„Zd„Zd „Zd „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zdd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%d„Z&d„Z'd„Z(RS(!twarningcCsÉ|djo t|_n ||_d|_|o‰|idƒ|i||ƒt|_y|iƒ|_ WqÅt i j o:}|i dt jo t|_q¸|i|ƒ‚qÅXn d|_ dS(Ni(R,R-t_mapt_filenot setblockingt set_sockettTruet connectedt getpeernametaddrR&R'R(RtFalset del_channel(tselftsockR6R((s /usr/lib64/python2.6/asyncore.pyt__init__âs          cCsÒ|iid|iig}|io|io|idƒn|io|idƒn|idj oHy|id|iƒWqµtj o|it |iƒƒqµXnddi |ƒt |ƒfS(Nt.t listeningRMs%s:%ds <%s at %#x>t ( t __class__RRt acceptingROR1RMR,t TypeErrortreprtjointid(RRtstatus((s /usr/lib64/python2.6/asyncore.pyt__repr__s cCs+|djo |i}n|||iscCs@t|_tidjo|djo d}n|ii|ƒS(Ntnti(RLRYR tnameR&tlisten(RRtnum((s /usr/lib64/python2.6/asyncore.pyRmEs  cCs||_|ii|ƒS(N(ROR&tbind(RRRO((s /usr/lib64/python2.6/asyncore.pyRoKs cCszt|_|ii|ƒ}|tttfjodS|dtfjo||_|i ƒnti |t |ƒ‚dS(Ni( RPRMR&t connect_exRRRRROthandle_connect_eventR'R (RRtaddressR((s /usr/lib64/python2.6/asyncore.pytconnectOs  cCs]y#|iiƒ\}}||fSWn3tij o$}|idtjoqY‚nXdS(Ni(R&tacceptR'R(R(RRtconnROtwhy((s /usr/lib64/python2.6/asyncore.pyRt[scCs„y|ii|ƒ}|SWnctij oT}|idtjodS|idttttfjo|i ƒdS‚nXdS(Ni( R&tsendR'R(RRRRR R%(RRtdatatresultRv((s /usr/lib64/python2.6/asyncore.pyRwfs  cCsy0|ii|ƒ}|p|iƒdS|SWnJtij o;}|idttttgjo|iƒdS‚nXdS(Nti( R&trecvR%R'R(RRRR (RRt buffer_sizeRxRv((s /usr/lib64/python2.6/asyncore.pyR{ss   cCsmt|_t|_|iƒy|iiƒWn9tij o*}|idtt fjo‚qinXdS(Ni( RPRMRYRQR&tcloseR'R(RR(RRRv((s /usr/lib64/python2.6/asyncore.pyR}…s   cCsJyt|i|ƒSWn/tj o#td|ii|fƒ‚nXdS(Ns!%s instance has no attribute '%s'(tgetattrR&tAttributeErrorRXR(RRtattr((s /usr/lib64/python2.6/asyncore.pyt __getattr__‘s cCstiidt|ƒƒdS(Nslog: %s (tsyststderrRtstr(RRtmessage((s /usr/lib64/python2.6/asyncore.pytlogœstinfocCs'||ijod||fGHndS(Ns%s: %s(tignore_log_types(RRR…Rc((s /usr/lib64/python2.6/asyncore.pytlog_infoŸscCsH|io|iƒn-|ip|iƒ|iƒn |iƒdS(N(RYt handle_acceptRMRqt handle_read(RR((s /usr/lib64/python2.6/asyncore.pyR£s    cCs|iƒt|_dS(N(thandle_connectRLRM(RR((s /usr/lib64/python2.6/asyncore.pyRq®s cCsy|iodS|ipR|iititiƒ}|djoti|t|ƒƒ‚n|iƒn|i ƒdS(Ni( RYRMR&RiRgtSO_ERRORR'RRqt handle_write(RRR((s /usr/lib64/python2.6/asyncore.pyR²s   cCsD|iititiƒ}|djo|iƒn |iƒdS(Ni(R&RiRgRR%t handle_expt(RRR((s /usr/lib64/python2.6/asyncore.pyRÁs c Csmtƒ\}}}}yt|ƒ}Wndt|ƒ}nX|id||||fdƒ|iƒdS(Ns)<__repr__(self) failed for object at %0x>s:uncaptured python exception, closing channel %s (%s:%s %s)R'(tcompact_tracebackR[R]R‰R%(RRtniltttvttbinfot self_repr((s /usr/lib64/python2.6/asyncore.pyRÐscCs|iddƒdS(Ns!unhandled incoming priority eventRG(R‰(RR((s /usr/lib64/python2.6/asyncore.pyRäscCs|iddƒdS(Nsunhandled read eventRG(R‰(RR((s /usr/lib64/python2.6/asyncore.pyR‹çscCs|iddƒdS(Nsunhandled write eventRG(R‰(RR((s /usr/lib64/python2.6/asyncore.pyRŽêscCs|iddƒdS(Nsunhandled connect eventRG(R‰(RR((s /usr/lib64/python2.6/asyncore.pyRŒíscCs|iddƒdS(Nsunhandled accept eventRG(R‰(RR((s /usr/lib64/python2.6/asyncore.pyRŠðscCs|iddƒ|iƒdS(Nsunhandled close eventRG(R‰R}(RR((s /usr/lib64/python2.6/asyncore.pyR%ósN()RRRPtdebugRMRYtclosingR,ROt frozensetRˆRTR_R`RQRdRKRjR/R0RmRoRsRtRwR{R}RR†R‰RRqRRRRR‹RŽRŒRŠR%(((s /usr/lib64/python2.6/asyncore.pyRFÙsH                    tdispatcher_with_sendcBs;eZddd„Zd„Zd„Zd„Zd„ZRS(cCs ti|||ƒd|_dS(NRz(RFRTt out_buffer(RRRSR6((s /usr/lib64/python2.6/asyncore.pyRTþscCs3d}ti||id ƒ}|i||_dS(Nii(RFRwRš(RRtnum_sent((s /usr/lib64/python2.6/asyncore.pyt initiate_sendscCs|iƒdS(N(Rœ(RR((s /usr/lib64/python2.6/asyncore.pyRŽscCs|i p t|iƒS(N(RMtlenRš(RR((s /usr/lib64/python2.6/asyncore.pyR0 scCsC|io|idt|ƒƒn|i||_|iƒdS(Ns sending %s(R–R‰R[RšRœ(RRRx((s /usr/lib64/python2.6/asyncore.pyRw s N(RRR,RTRœRŽR0Rw(((s /usr/lib64/python2.6/asyncore.pyR™üs    c CsØtiƒ\}}}g}|ptdƒ‚nxF|o>|i|iii|iiit|i ƒfƒ|i }q5W~|d\}}}di g}|D]}|d|q¢~ƒ} |||f||| fS(Nstraceback does not existiÿÿÿÿRWs [%s|%s|%s]( R‚texc_infotAssertionErrorR1ttb_frametf_codet co_filenametco_nameR„t tb_linenottb_nextR\( R’R“ttbR”tfiletfunctiontlinet_[1]txR‡((s /usr/lib64/python2.6/asyncore.pyRs  .cCs±|djo t}nx‰|iƒD]{}y|iƒWq$tj o/}|idtjoqŸ|p‚qŸq$tj o ‚q$|p‚qŸq$Xq$W|iƒdS(Ni( R,R-tvaluesR}tOSErrorR(RRtclear(R6t ignore_allR«((s /usr/lib64/python2.6/asyncore.pyt close_all+s"    tposixt file_wrappercBsMeZd„Zd„Zd„Zdd„ZeZeZd„Z d„Z RS(cCsti|ƒ|_dS(N(R tdupR9(RRR9((s /usr/lib64/python2.6/asyncore.pyRTRscGsti|i|ŒS(N(R RR9(RRR(((s /usr/lib64/python2.6/asyncore.pyR{UscGsti|i|ŒS(N(R RR9(RRR(((s /usr/lib64/python2.6/asyncore.pyRwXscCs=|tijo|tijo | odStdƒ‚dS(Nis-Only asyncore specific behaviour implemented.(R&RgRtNotImplementedError(RRtleveltoptnametbuflen((s /usr/lib64/python2.6/asyncore.pyRi[s cCsti|iƒdS(N(R R}R9(RR((s /usr/lib64/python2.6/asyncore.pyR}fscCs|iS(N(R9(RR((s /usr/lib64/python2.6/asyncore.pyReisN( RRRTR{RwR,RiRRR}Re(((s /usr/lib64/python2.6/asyncore.pyR²Ms     tfile_dispatchercBseZdd„Zd„ZRS(cCsŽti|d|ƒt|_y|iƒ}Wntj onX|i|ƒti|ti dƒ}|t i B}ti|ti |ƒdS(Ni( RFRTR,RLRMReRtset_filetfcntltF_GETFLR t O_NONBLOCKtF_SETFL(RRR9R6R)((s /usr/lib64/python2.6/asyncore.pyRTns   cCs/t|ƒ|_|iiƒ|_|iƒdS(N(R²R&ReRIR`(RRR9((s /usr/lib64/python2.6/asyncore.pyR¹{sN(RRR,RTR¹(((s /usr/lib64/python2.6/asyncore.pyR¸ls (,t__doc__RR&R‚R2R terrnoRRRRRRRRRR R R-RRt ExceptionRtKeyboardInterruptt SystemExitRRRRR+R,R<R@tpoll3RPRERFR™RR°RlRºR²R¸(((s /usr/lib64/python2.6/asyncore.pyt/s<     L      , ÿ$