tzh
2024-08-22 c7d0944258c7d0943aa7b2211498fd612971ce27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
K\¬Qc@sdZddlZddlZddlZddlZddlZddlZddlmZm    Z    m
Z
m Z m Z m Z mZmZmZmZmZmZmZmZee e eeeefƒZyeWnek
rëiZnXd„Zdefd„ƒYZeeefZd„Z d„Z!d    „Z"d
„Z#d e$d „Z%d e$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(tEALREADYt EINPROGRESSt EWOULDBLOCKt
ECONNRESETtEINVALtENOTCONNt    ESHUTDOWNtEINTRtEISCONNtEBADFt ECONNABORTEDtEPIPEtEAGAINt    errorcodecCsKytj|ƒSWn3tttfk
rF|tkr>t|Sd|SXdS(NsUnknown error %s(toststrerrort
ValueErrort OverflowErrort    NameErrorR (terr((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt    _strerrorDs  tExitNowcBseZRS((t__name__t
__module__(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRLscCs9y|jƒWn$tk
r$‚n|jƒnXdS(N(thandle_read_eventt_reraised_exceptionst handle_error(tobj((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytreadQs  cCs9y|jƒWn$tk
r$‚n|jƒnXdS(N(thandle_write_eventRR(R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytwriteYs  cCs9y|jƒWn$tk
r$‚n|jƒnXdS(N(thandle_expt_eventRR(R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt
_exceptionas  cCsäyz|tj@r|jƒn|tj@r7|jƒn|tj@rQ|jƒn|tjtjBtj    B@ry|j
ƒnWnct j k
r¼}|j dtkr¯|jƒqà|j
ƒn$tk
rÏ‚n|jƒnXdS(Ni(tselecttPOLLINRtPOLLOUTRtPOLLPRIRtPOLLHUPtPOLLERRtPOLLNVALt handle_closetsocketterrortargst _DISCONNECTEDRR(Rtflagste((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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}    |    j dt 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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytpoll}sN        ' %      cCs}|dkrt}n|dk    r4t|dƒ}ntjƒ}|ryx|jƒD]\}}d}|jƒrˆ|tjtjBO}n|j    ƒr®|j
r®|tj O}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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytloopÍs               t
dispatchercBsaeZeZeZeZeZeZd Z    e
dgƒZ d 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
j k
r¶}|j dt tfkr£t|_q·|j|ƒ‚qÃXn    d|_
dS(Ni(R0R1t_mapt_filenot setblockingt
set_sockettTruet    connectedt getpeernametaddrR)R*R+RRtFalset del_channel(tselftsockR;R((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt__repr__    s     cCs)|dkr|j}n|||j<dS(N(R0RMRN(RWR;((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt add_channels  cCsD|j}|dkr!|j}n||kr7||=nd|_dS(N(RNR0RM(RWR;R>((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRVs        
cCs?||f|_tj||ƒ}|jdƒ|j|ƒdS(Ni(tfamily_and_typeR)RORP(RWtfamilyttypeRX((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt create_socket's cCs)||_|jƒ|_|j|ƒdS(N(R)tfilenoRNRd(RWRXR;((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRP-s    cCsTy9|jjtjtj|jjtjtjƒdBƒWntjk
rOnXdS(Ni(R)t
setsockoptt
SOL_SOCKETt SO_REUSEADDRt
getsockoptR*(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytset_reuse_addr3s     cCstS(N(RQ(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR3DscCstS(N(RQ(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR4GscCs=t|_tjdkr-|dkr-d}n|jj|ƒS(Ntnti(RQR6RtnameR)tlisten(RWtnum((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRqNs        cCs||_|jj|ƒS(N(RTR)tbind(RWRT((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRsTs    cCs£t|_t|_|jj|ƒ}|tttfksT|t    krat
j dkra||_ dS|dt fkr‰||_ |jƒntj|t|ƒ‚dS(NRotcei(sntRt(RURRRQt
connectingR)t
connect_exRRRRRRpRTRthandle_connect_eventR*R (RWtaddressR((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytconnectXs                 cCsty|jjƒ\}}WnJtk
r-dStjk
re}|jdtttfkr_dS‚n X||fSdS(Ni(    R)tacceptR^R0R*R+RR
R (RWtconnRTtwhy((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRzfs cCsry|jj|ƒ}|SWnQtjk
rm}|jdtkrFdS|jdtkrg|jƒdS‚nXdS(Ni(R)tsendR*R+RR,R((RWtdatatresultR|((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR}ts
cCsoy.|jj|ƒ}|s)|jƒdS|SWn:tjk
rj}|jdtkrd|jƒdS‚nXdS(Nti(R)trecvR(R*R+R,(RWt buffer_sizeR~R|((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRs
 
cCsrt|_t|_t|_|jƒy|jjƒWn5tjk
rm}|jdt    t
fkrn‚qnnXdS(Ni( RURRR6RuRVR)tcloseR*R+RR    (RWR|((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt __getattr__ s cCstjjdt|ƒƒdS(Nslog: %s
(tsyststderrRtstr(RWtmessage((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytlog°stinfocCs%||jkr!d||fGHndS(Ns%s: %s(tignore_log_types(RWR’Rg((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pytlog_info³scCsP|jr|jƒn6|jsB|jr5|jƒn|jƒn
|jƒdS(N(R6t handle_acceptRRRuRwt handle_read(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR·s               cCsb|jjtjtjƒ}|dkrBtj|t|ƒƒ‚n|jƒt|_t    |_
dS(Ni( R)RmRktSO_ERRORR*Rthandle_connectRQRRRURu(RWR((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRwÃs  
    cCs=|jr dS|js/|jr/|jƒq/n|jƒdS(N(R6RRRuRwt handle_write(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRËs             cCsB|jjtjtjƒ}|dkr4|jƒn
|jƒdS(Ni(R)RmRkR™R(t handle_expt(RWR((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRåscCs|jddƒdS(Ns!unhandled incoming priority eventRL(R–(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRœùscCs|jddƒdS(Nsunhandled read eventRL(R–(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR˜üscCs|jddƒdS(Nsunhandled write eventRL(R–(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR›ÿscCs|jddƒdS(Nsunhandled connect eventRL(R–(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRšscCs|jddƒdS(Nsunhandled accept eventRL(R–(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR—scCs|jddƒ|jƒdS(Nsunhandled close eventRL(R–Rƒ(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR(sN(+RRRUtdebugRRR6RutclosingR0RTt    frozensetR•RYRct__str__RdRVRhRPRnR3R4RqRsRyRzR}RRƒRŽR“R–RRwRRRRœR˜R›RšR—R((((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRKßsL                                                                                                         tdispatcher_with_sendcBs;eZddd„Zd„Zd„Zd„Zd„ZRS(cCs tj|||ƒd|_dS(NR€(RKRYt
out_buffer(RWRXR;((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRYscCs3d}tj||jd ƒ}|j||_dS(Nii(RKR}R¨(RWtnum_sent((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt initiate_sendscCs|jƒdS(N(Rª(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR›scCs|j pt|jƒS(N(RRtlenR¨(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR4scCsA|jr#|jdt|ƒƒn|j||_|jƒdS(Ns
sending %s(R£R–R_R¨Rª(RWR~((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR}"s    N(RRR0RYRªR›R4R}(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR§s
            c    CsÌtjƒ\}}}g}|s0tdƒ‚nxD|rv|j|jjj|jjjt|j    ƒfƒ|j
}q3W~|d\}}}dj g|D]}d|^qšƒ}|||f|||fS(Nstraceback does not existiÿÿÿÿR\s
[%s|%s|%s]( Rtexc_infotAssertionErrorR5ttb_frametf_codet co_filenametco_nameR‘t    tb_linenottb_nextR`(    RŸR ttbR¡tfiletfunctiontlinetxR”((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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¸((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt    close_all@s           tposixt file_wrappercBsMeZd„Zd„Zd„Zdd„ZeZeZd„Z    d„Z
RS(cCstj|ƒ|_dS(N(RtdupR>(RWR>((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRYgscGstj|j|ŒS(N(RRR>(RWR+((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRjscGstj|j|ŒS(N(RRR>(RWR+((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR}mscCs9|tjkr)|tjkr)| r)dStdƒ‚dS(Nis-Only asyncore specific behaviour implemented.(R)RkR™tNotImplementedError(RWtleveltoptnametbuflen((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRmps
cCstj|jƒdS(N(RRƒR>(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRƒ{scCs|jS(N(R>(RW((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRi~sN( RRRYRR}R0RmRRRƒRi(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyR¿bs                 tfile_dispatchercBseZdd„Zd„ZRS(cCsŒtj|d|ƒt|_y|jƒ}Wntk
r?nX|j|ƒtj|tj    dƒ}|t
j B}tj|tj |ƒdS(Ni( RKRYR0RQRRRiRˆtset_filetfcntltF_GETFLRt
O_NONBLOCKtF_SETFL(RWR>R;R-((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRYƒs       cCs/t|ƒ|_|jjƒ|_|jƒdS(N(R¿R)RiRNRd(RWR>((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRƐsN(RRR0RYRÆ(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyRŁs (2t__doc__R!R)RR7R‰RterrnoRRRRRRRRRR    R
R R R R¥R,R1RRt    ExceptionRtKeyboardInterruptt
SystemExitRRRR R/R0RAREtpoll3RURJRKR§RR½RpRÇR¿RÅ(((sP/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/asyncore.pyt<module>/sB      ^  
                    -!ÿ3