VcL ddlmZmZddlmZddlmZddlZddlZddl Z dZ dZ dZ edgd Z d e _d e j_d e j_d e j_de j_GddeZGddeZGddeZGddeZGddeZeedrGddeZeedrGddeZeed rGd!d"eZeed#rGd$d%eZd&Zed#reZdSedreZdSed reZdSedreZdSeZdS)')ABCMetaabstractmethod) namedtuple)MappingNcJ t|tr|}na t|}n>#ttt f$r$t d|dwxYw|dkr"t d||S)NzInvalid file object: {!r}rzInvalid file descriptor: {}) isinstanceintfilenoAttributeError TypeError ValueErrorformat)fileobjfds "/usr/lib64/python3.11/selectors.py_fileobj_to_fdrs '3?  ?W^^%%&&BB :6 ? ? ?$$*F7OO55:> ? ? AvC6==bAABBB Is !=;A8 SelectorKey)rreventsdatazSelectorKey(fileobj, fd, events, data) Object used to associate a file object to its backing file descriptor, selected event mask, and attached data. zFile object registered.zUnderlying file descriptor.z3Events that must be waited for on this file object.zvOptional opaque data associated to this file object. For example, this could be used to store a per-client session ID.c(eZdZ dZdZdZdZdS)_SelectorMappingc||_dSN) _selector)selfselectors r__init__z_SelectorMapping.__init__?s !c4t|jjSr)lenr _fd_to_keyrs r__len__z_SelectorMapping.__len__Bs4>,---r c |j|}|jj|S#t$r$td|dwxYwN{!r} is not registered)r_fileobj_lookupr#KeyErrorr)rrrs r __getitem__z_SelectorMapping.__getitem__Esk O//88B>,R0 0 O O O3::7CCDD$ N Os +..Ac4t|jjSr)iterrr#r$s r__iter__z_SelectorMapping.__iter__LsDN-...r N)__name__ __module__ __qualname__rr%r+r.r rrr<sV3"""...OOO/////r rceZdZ ed dZedZd dZed dZdZdZ edZ d Z d Z dS) BaseSelectorNc trNotImplementedErrorrrrrs rregisterzBaseSelector.register_s &"!r c trr6)rrs r unregisterzBaseSelector.unregisterv "!r c\ ||||||Sr)r;r9r8s rmodifyzBaseSelector.modifys1     }}Wfd333r c trr6)rtimeouts rselectzBaseSelector.selectr<r c dSrr2r$s rclosezBaseSelector.closes  r c |}|td ||S#t$r$td|dwxYw)NzSelector is closedr()get_map RuntimeErrorr*r)rrmappings rget_keyzBaseSelector.get_keys| ,,..  5344 4 O7# # O O O3::7CCDD$ N Os 0.Ac trr6r$s rrEzBaseSelector.get_maps @!!r c|Srr2r$s r __enter__zBaseSelector.__enter__s r c.|dSr)rC)rargss r__exit__zBaseSelector.__exit__s r r) r/r0r1rr9r;r>rArCrHrErKrNr2r rr4r4Ps """^",""^"$4444""""^"$    O O O""^"r r4) metaclasscDeZdZ dZdZd dZdZd dZdZdZ d Z dS) _BaseSelectorImplc<i|_t||_dSr)r#r_mapr$s rrz_BaseSelectorImpl.__init__s$T** r c t|S#t$r2|jD]}|j|ur |jccYSwxYwr)rrr#valuesrrrrkeys rr)z!_BaseSelectorImpl._fileobj_lookupsz  !'** *   --// " ";')"6MMMMM"   s7A ANcH|r|ttzzr"td|t |||||}|j|jvr(td||j||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered) EVENT_READ EVENT_WRITErrrr)rr#r*rrrrrWs rr9z_BaseSelectorImpl.registers DFzK'?%@@ D3::6BBCC C'4#7#7#@#@&$OO 6T_ $ 5?"F7CF3355 5#& r c |j||}n1#t$r$td|dwxYw|Sr')r#popr)r*rrVs rr;z_BaseSelectorImpl.unregistersp O/%%d&:&:7&C&CDDCC O O O3::7CCDD$ N O s -0.Ac| |j||}n1#t$r$td|dwxYw||jkr-||||||}n0||jkr%||}||j|j <|S)Nr()r) r#r)r*rrr;r9r_replacerr[s rr>z_BaseSelectorImpl.modifys O/$"6"6w"?"?@CC O O O3::7CCDD$ N O SZ  * OOG $ $ $--66CC SX  *,,D,))C&)DOCF # s #.AcF|jd|_dSr)r#clearrSr$s rrCz_BaseSelectorImpl.close s!  r c|jSr)rSr$s rrEz_BaseSelectorImpl.get_maps yr cB |j|S#t$rYdSwxYwr)r#r*)rrs r _key_from_fdz_BaseSelectorImpl._key_from_fds;  ?2& &   44 s  r) r/r0r1rr)r9r;r>rCrErdr2r rrQrQs'+++ &             r rQcleZdZ fdZdfd ZfdZejdkrddZne j ZddZ xZ S) SelectSelectorctt|_t|_dSr)superrset_readers_writersr __class__s rrzSelectSelector.__init__%s3   r Nct|||}|tzr|j|j|t zr|j|j|Sr)rhr9rYrjaddrrZrk)rrrrrWrms rr9zSelectSelector.register*smggw55 J  & M  cf % % % K  & M  cf % % % r ct|}|j|j|j|j|Sr)rhr;rjdiscardrrkrrrWrms rr;zSelectSelector.unregister2sOgg  )) cf%%% cf%%% r win32cHtj||||\}}}|||zgfSr)rA)rrw_r@xs r_selectzSelectSelector._select9s-mAq!W55GAq!a!eR< r c|dnt|d}g} ||j|jg|\}}}n#t$r|cYSwxYwt |}t |}||zD]V}d}||vr |t z}||vr |tz}||}|r| |||j zfW|SNr) maxryrjrkInterruptedErrorrirYrZrdappendr) rr@readyrurvrwrrrWs rrAzSelectSelector.select?s!>$$s7A ll4=$-WMMGAq!!   LLL  FF FFa% 9 9BFQw %*$Qw &+%##B''C 9 c6CJ#67888 s&? A Ar) r/r0r1rr9r;sysplatformryrA __classcell__rms@rrfrf"s    |w      -r rfcVeZdZ dZdZdZfdZdfd ZfdZdfd Z ddZ xZ S)_PollLikeSelectorNczt||_dSr)rhr _selector_clsrrls rrz_PollLikeSelector.__init__[s0 ++--r c4t|||}d}|tzr ||jz}|tzr ||jz} |j|j|n'#t|xYw|Sr{) rhr9rY _EVENT_READrZ _EVENT_WRITErrr;)rrrrrW poller_eventsrms rr9z_PollLikeSelector.register_sggw55 J  . T- -M K  / T. .M  N # #CFM : : : :  GG  w ' ' '  s  A11$Bct|} |j|jn#t$rYnwxYw|Sr)rhr;rrOSErrorrrs rr;z_PollLikeSelector.unregistermscgg  ))  N % %cf - - - -    D  sA AAc |j||}n!#t$rt|ddwxYwd}||jkrud}|tzr ||jz}|t zr ||jz} |j |j |n'#t |xYwd}||j krd}|r&|||}||j|j <|S)Nz is not registeredFrT)rr)r#r)r*rrYrrZrrr>rrhr;rr_)rrrrrWchangedselector_eventsrms rr>z_PollLikeSelector.modifyws; G/$"6"6w"?"?@CC G G Gg;;;<<$ F G SZ  O " 44#33 # 54#44 %%cfo>>>> ""7+++G 38  G  *,,f4,88C&)DOCF # s $A= B$Cc|d}n |dkrd}ntj|dz}g} |j|}n#t$r|cYSwxYw|D]g\}}d}||jzr |t z}||jzr |tz}| |}|r| |||j zfh|S)Nr@@) mathceilrpollr}rrZrrYrdr~r)rr@r fd_event_listreventrrWs rrAz_PollLikeSelector.selects  /GG \ /GGi# ..G  N//88MM   LLL & 9 9IBF((( &+%))) %*$##B''C 9 c6CJ#67888 sA AAr) r/r0r1rrrrr9r;r>rArrs@rrrUsFMKL.....      6r rrc:eZdZ ejZejZejZ dS) PollSelectorN) r/r0r1rArrPOLLINrPOLLOUTrr2r rrrs&" m ~ r repollcXeZdZ ejZejZejZ dZ ddZfdZ xZ S) EpollSelectorc4|jSrrr r$s rr zEpollSelector.fileno>((** *r Nc|d}n#|dkrd}ntj|dzdz}tt|jd}g} |j||}n#t$r|cYSwxYw|D]q\}}d}|tj zr |tz}|tj zr |tz}| |}|r||||jzfr|S)NrrgMbP?r)rrr|r"r#rrr}rAEPOLLINrZEPOLLOUTrYrdr~r) rr@max_evrrrrrrWs rrAzEpollSelector.selects. :A :)GcM22T9 T_--q11FE  $ 3 3GV D D #     * = = EFN?**k)FFO++)j(F''++=LL#v ':!;<<<LsA** A98A9cz|jtdSrrrCrhrls rrCzEpollSelector.close, N " " " GGMMOOOOOr r) r/r0r1rArrrrrrr rCrrs@rrrst# n   + + +    @         r rdevpollcPeZdZ ejZejZejZ dZ fdZ xZ S)DevpollSelectorc4|jSrrr$s rr zDevpollSelector.filenorr cz|jtdSrrrls rrCzDevpollSelector.closerr ) r/r0r1rArrrrrrr rCrrs@rrrs_) m ~  + + +         r rkqueuecNeZdZ fdZdZdfd ZfdZddZfdZxZ S) KqueueSelectorcxttj|_dSr)rhrrArrrls rrzKqueueSelector.__init__s* GG     #]__DNNNr c4|jSrrr$s rr zKqueueSelector.filenorr Nct|||} |tzrLtj|jtjtj}|j |gdd|tzrLtj|jtj tj}|j |gddn'#t |xYw|Sr{) rhr9rYrAkeventrKQ_FILTER_READ KQ_EV_ADDrcontrolrZKQ_FILTER_WRITEr;)rrrrrWkevrms rr9zKqueueSelector.registers''""7FD99C J&8 -0E(.(8::CN**C5!Q777K'8 -0F(.(8::CN**C5!Q777 ""7+++Js B,C$C7ct|}|jtzr^t j|jtjtj} |j |gddn#t$rYnwxYw|jtzr^t j|jtj tj} |j |gddn#t$rYnwxYw|Sr{)rhr;rrYrArrr KQ_EV_DELETErrrrZr)rrrWrrms rr;zKqueueSelector.unregisters ''$$W--CzJ& mCFF,A$*$799N**C5!Q7777DzK' mCFF,B$*$799N**C5!Q7777DJs$"B B  B C-- C:9C:c|dnt|d}tt|jd}g} |jd||}n#t $r|cYSwxYw|D]|}|j}|j}d}|tj kr |tz}|tj kr |tz}| |} | r|| || jzf}|S)Nrr)r|r"r#rrr}identfilterrArrYrrZrdr~r) rr@rrkev_listrrflagrrWs rrAzKqueueSelector.select)s%Bdd3w??GT_--q11FE >11$HH#      = =Yz600)j(F611*k)F''++=LL#v ':!;<<<LsA A&%A&cz|jtdSrrrls rrCzKqueueSelector.closeBrr r) r/r0r1rr r9r;rArCrrs@rrrs$ - - - - - + + +            *    2         r rc tt|d}|dS |}|dkr|dn|dS#t$rYdSwxYw)NFrrT)getattrrArrCr)methodr selector_objs r_can_userGsvvt,,Hu xzz V  !   a     t uus:A A'&A')abcrr collectionsrcollections.abcrrrArrYrZrr__doc__rrrrrr4rQrfrhasattrrrrrrDefaultSelectorr2r rrs]('''''''""""""######   2j(K(K(KLL   8 6 R E /////w///({{{{{W{{{{|QQQQQ QQQh00000&000fWWWWW)WWWt 766&&&&&&(&&& 767-+++++)+++\ 769      +    768LJJJJJ*JJJZ4 8H %$OOO Xg%#OOO Xi%%OOO Xf%"OOO$OOOr