VcLcs 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)MappingNicsJ t|tr|}na t|}n>#ttt f$r$t d|dwxYw|dkr"t d||S)NzInvalid file object: {!r}rzInvalid file descriptor: {})Z isinstanceZintfilenoZAttributeErrorZ TypeError ValueErrorformat)fileobjfd "/usr/lib64/python3.11/selectors.py_fileobj_to_fdr s '3?  ?W^^%%&&BB :6 ? ? ?$$*F7OO55:> ? ? AvC6==bAABBB Is !=;A8 SelectorKey)r r eventsdatazSelectorKey(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.cs(eZdZ dZdZdZdZdS)_SelectorMappingcs||_dSN) _selector)selfselectorr r __init__z_SelectorMapping.__init__?s !c4t|jjSr)lenr _fd_to_keyr r __len__z_SelectorMapping.__len__Bs4>,---rcs |j|}|jj|S#t$r$td|dwxYwN{!r} is not registered)r_fileobj_lookuprKeyErrorr)rr r  r __getitem__z_SelectorMapping.__getitem__Esk O//88B>,R0 0 O O O3::7CCDD$ N Os +..Acrr)Ziterrrrrr __iter__z_SelectorMapping.__iter__LsDN-...rN)__name__ __module__ __qualname__rrr#r$rr rr<sV3"""...OOO/////rrcseZdZ ed dZedZd dZed dZdZdZ edZ d Z d Z dS) BaseSelectorNc trZNotImplementedErrorrr rr r registerzBaseSelector.register_s &"!rcr*rr+)rr r r unregisterzBaseSelector.unregisterv "!rcs\ ||||||Sr)r/r.r,r-r modifyzBaseSelector.modifys1     }}Wfd333rcr*rr+)rtimeoutr r selectzBaseSelector.selectr0rcs dSrr(rrr closezBaseSelector.closes  rcs |}|td ||S#t$r$td|dwxYw)NzSelector is closedr)get_mapZ RuntimeErrorr!r)rr Zmappingr"r get_keyzBaseSelector.get_keys| ,,..  5344 4 O7# # O O O3::7CCDD$ N Os 0.Acr*rr+rrr r5zBaseSelector.get_maps @!!rcs|Srr(rrr __enter__zBaseSelector.__enter__s rcs.|dSr)r4)rZargsr r __exit__zBaseSelector.__exit__s rr) r%r&r'rr.r/r1r3r4r6r5r7r8r(rr r)r)Ps """^",""^"$4444""""^"$    O O O""^"rr))Z metaclasscsDeZdZ dZdZd dZdZd dZdZdZ d Z dS) _BaseSelectorImplcs<i|_t||_dSr)rr_maprrr rz_BaseSelectorImpl.__init__s$T** rcs t|S#t$r2|jD]}|j|ur |jccYSwxYwr)r rrZvaluesr r rr keyr"r r z!_BaseSelectorImpl._fileobj_lookupsz  !'** *   --// " ";')"6MMMMM"   s7A ANcsH|r|ttzzr"td|t |||||}|j|jvr(td||j||j|j<|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered) EVENT_READ EVENT_WRITErrrr r rr!rr rrr< r r.z_BaseSelectorImpl.registers DFzK'?%@@ D3::6BBCC C'4#7#7#@#@&$OO 6T_ $ 5?"F7CF3355 5#& rcs |j||}n1#t$r$td|dwxYw|Sr)rZpopr r!rr;r"r r/z_BaseSelectorImpl.unregistersp O/%%d&:&:7&C&CDDCC O O O3::7CCDD$ N O s -0.Acs| |j||}n1#t$r$td|dwxYw||jkr-||||||}n0||jkr%||}||j|j <|S)Nr)r) rr r!rrr/r.r_replacer r?r@r r1z_BaseSelectorImpl.modifys O/$"6"6w"?"?@CC O O O3::7CCDD$ N O SZ  * OOG $ $ $--66CC SX  *,,D,))C&)DOCF # s #.AcsF|jd|_dSr)rZclearr:rrr r4z_BaseSelectorImpl.close s!  rcs|jSr)r:rrr r5z_BaseSelectorImpl.get_maps yrcsB |j|S#t$rYdSwxYwr)rr!)rr r r _key_from_fdz_BaseSelectorImpl._key_from_fds;  ?2& &   44 s  r) r%r&r'rr r.r/r1r4r5rBr(rr r9r9s'+++ &             rr9csleZdZ fdZdfd ZfdZejdkrddZne j ZddZ xZ S) SelectSelectorcstt|_t|_dSr)superrset_readers_writersr __class__ r rzSelectSelector.__init__%s3   rNcst|||}|tzr|j|j|t zr|j|j|Sr)rDr.r=rFZaddr r>rG)rr rrr<rIs r r.zSelectSelector.register*smggw55 J  & M  cf % % % K  & M  cf % % % rcst|}|j|j|j|j|Sr)rDr/rFZdiscardr rGrr r<rI r r/zSelectSelector.unregister2sOgg  )) cf%%% cf%%% rZwin32csHtj||||\}}}|||zgfSr)r3)rrw_r2Zxs r _selectzSelectSelector._select9s-mAq!W55GAq!a!eR< rcs|dnt|d}g} ||j|jg|\}}}n#t$r|cYSwxYwt |}t |}||zD]V}d}||vr |t z}||vr |tz}||}|r| |||j zfW|SNr) maxrPrFrGInterruptedErrorrEr=r>rBappendr) rr2readyrMrNrOr rr< r r3zSelectSelector.select?s!>$$s7A ll4=$-WMMGAq!!   LLL  FF FFa% 9 9BFQw %*$Qw &+%##B''C 9 c6CJ#67888 s&? A Ar) r%r&r'rr.r/sysZplatformrPr3 __classcell__rI@r rCrC"s    |w      -rrCcsVeZdZ dZdZdZfdZdfd ZfdZdfd Z ddZ xZ S)_PollLikeSelectorNcszt||_dSr)rDr _selector_clsrrHrJr rz_PollLikeSelector.__init__[s0 ++--rcs4t|||}d}|tzr ||jz}|tzr ||jz} |j|j|n'#t|xYw|SrQ) rDr.r= _EVENT_READr> _EVENT_WRITErr r/)rr rrr<Z poller_eventsrI r r.z_PollLikeSelector.register_sggw55 J  . T- -M K  / T. .M  N # #CFM : : : :  GG  w ' ' '  s  A11$Bcst|} |j|jn#t$rYnwxYw|Sr)rDr/rr OSErrorrKrLr r/z_PollLikeSelector.unregistermscgg  ))  N % %cf - - - -    D  sA AAcs |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)rr r!rr=r]r>r^rr1r rDr/rrA)rr rrr<ZchangedZselector_eventsrIs r r1z_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$Ccs|d}n |dkrd}ntj|dz}g} |j|}n#t$r|cYSwxYw|D]g\}}d}||jzr |t z}||jzr |tz}| |}|r| |||j zfh|S)Nr@@) mathceilrpollrSr]r>r^r=rBrTr)rr2rU fd_event_listr eventrr<s r r3z_PollLikeSelector.selects  /GG \ /GGi# ..G  N//88MM   LLL & 9 9IBF((( &+%))) %*$##B''C 9 c6CJ#67888 sA AAr) r%r&r'r\r]r^rr.r/r1r3rXrYrZr r[r[UsFMKL.....      6rr[rdcs:eZdZ ejZejZejZ dS) PollSelectorN) r%r&r'r3rdr\POLLINr]POLLOUTr^r(rr rgrgs&" m ~ rrgepollcsXeZdZ ejZejZejZ dZ ddZfdZ xZ S) EpollSelectorc4|jSrrrrrr rzEpollSelector.fileno>((** *rNcs|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)NirragMbP?r)rbrcrRrrrrdrSr3EPOLLINr>EPOLLOUTr=rBrTr) rr2max_evrUrer rfrr<rVr r3zEpollSelector.selects. :A :)GcM22T9 T_--q11FE  $ 3 3GV D D #     * = = EFN?**k)FFO++)j(F''++=LL#v ':!;<<<LsA** A98A9cz|jtdSrrr4rDrHrJr r4zEpollSelector.close, N " " " GGMMOOOOOrr) r%r&r'r3rjr\ror]rpr^rr4rXrYrZr rkrkst# n   + + +    @         rrkdevpollcsPeZdZ ejZejZejZ dZ fdZ xZ S)DevpollSelectorcrlrrmrrr rzDevpollSelector.filenornrcrrrrsrHrJr r4zDevpollSelector.closertr) r%r&r'r3rur\rhr]rir^rr4rXrYrZr rvrvs_) m ~  + + +         rrvkqueuecsNeZdZ fdZdZdfd ZfdZddZfdZxZ S) KqueueSelectorcsxttj|_dSr)rDrr3rwrrHrJr rzKqueueSelector.__init__s* GG     #]__DNNNrcrlrrmrrr rzKqueueSelector.filenornrNcst|||} |tzrLtj|jtjtj}|j |gdd|tzrLtj|jtj tj}|j |gddn'#t |xYw|SrQ) rDr.r=r3keventr KQ_FILTER_READZ KQ_EV_ADDrcontrolr>KQ_FILTER_WRITEr/)rr rrr<kevrIr_r r.zKqueueSelector.registers''""7FD99C J&8 -0E(.(8::CN**C5!Q777K'8 -0F(.(8::CN**C5!Q777 ""7+++Js B,C$C7cst|}|jtzr^t j|jtjtj} |j |gddn#t$rYnwxYw|jtzr^t j|jtj tj} |j |gddn#t$rYnwxYw|SrQ)rDr/rr=r3ryr rzZ KQ_EV_DELETErr{r`r>r|)rr r<r}rIs r r/zKqueueSelector.unregisters ''$$W--CzJ& mCFF,A$*$799N**C5!Q7777DzK' mCFF,B$*$799N**C5!Q7777DJs$"B B  B C-- C:9C:cs|dnt|d}tt|jd}g} |jd||}n#t $r|cYSwxYw|D]|}|j}|j}d}|tj kr |tz}|tj kr |tz}| |} | r|| || jzf}|S)Nrr)rRrrrr{rSZidentZfilterr3rzr=r|r>rBrTr) rr2rqrUZkev_listr}r Zflagrr<s r r3zKqueueSelector.select)s%Bdd3w??GT_--q11FE >11$HH#      = =Yz600)j(F611*k)F''++=LL#v ':!;<<<LsA A&%A&crrrrsrHrJr r4zKqueueSelector.closeBrtrr) r%r&r'rrr.r/r3r4rXrYrZr rxrxs$ - - - - - + + +            *    2         rrxcs tt|d}|dS |}|dkr|dn|dS#t$rYdSwxYw)NFrdrT)Zgetattrr3rdr4r`)ZmethodrZ selector_objr"r _can_user~Gsvvt,,Hu xzz V  !   a     t uus:A A'&A')ZabcrrZ collectionsrZcollections.abcrrbr3rWr=r>r rZ__doc__r r rrrr)r9rCr[Zhasattrrgrkrvrxr~ZDefaultSelectorr(rr rs]('''''''""""""######   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