QfLr ddlmZmZddlmZddlmZddlZddlZddl Z dZ dZ dZ edgd Z d e _d e j_d e j _d e j"_de j$_GddeZGddeZGddeZGddeZGddeZeedr GddeZeedr GddeZeed r Gd!d"eZeed#r Gd$d%eZd&Zed#reZyedreZyed reZyedreZyeZy)')ABCMetaabstractmethod) namedtuple)MappingNc t|tr|}n t|j}|dkrt dj ||S#ttt f$rt dj |dwxYw)NzInvalid file object: {!r}rzInvalid file descriptor: {}) isinstanceintfilenoAttributeError TypeError ValueErrorformat)fileobjfds 0/opt/alt/python312/lib64/python3.12/selectors.py_fileobj_to_fdrs '3  ?W^^%&B Av6==bABB I  :6 ?$$*F7O5:> ? ?s A0B 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 dZdZdZdZy)_SelectorMappingc||_yN) _selector)selfselectors r__init__z_SelectorMapping.__init__?s !c@t|jjSr)lenr _fd_to_keyrs r__len__z_SelectorMapping.__len__Bs4>>,,--r c |jj|}|jj|S#t$rtdj |dwxYwN{!r} is not registered)r_fileobj_lookupr#KeyErrorr)rrrs r __getitem__z_SelectorMapping.__getitem__Es[ O//8B>>,,R0 0 O3::7CD$ N Os 36%Ac@t|jjSr)iterrr#r$s r__iter__z_SelectorMapping.__iter__LsDNN--..r N)__name__ __module__ __qualname__rr%r+r.r rrr<s3".O/r rcreZdZ ed dZedZd dZed dZdZdZ edZ d Z d Z y) BaseSelectorNc trNotImplementedErrorrrrrs rregisterzBaseSelector.register_s &"!r c trr6)rrs r unregisterzBaseSelector.unregisterv "!r cL |j||j|||Sr)r;r9r8s rmodifyzBaseSelector.modifys(   }}Wfd33r c trr6)rtimeouts rselectzBaseSelector.selectr<r c yrr2r$s rclosezBaseSelector.closes   r c |j}| td ||S#t$rtdj|dwxYw)NzSelector is closedr()get_map RuntimeErrorr*r)rrmappings rget_keyzBaseSelector.get_keys` ,,. ?34 4 O7# # O3::7CD$ N Os %%A c trr6r$s rrEzBaseSelector.get_maps @!!r c|Srr2r$s r __enter__zBaseSelector.__enter__s r c$|jyr)rC)rargss r__exit__zBaseSelector.__exit__s  r r) r/r0r1rr9r;r>rArCrHrErKrNr2r rr4r4Psq "",""$4"""$  O""r r4) metaclasscBeZdZ dZdZd dZdZd dZdZdZ d Z y) _BaseSelectorImplc2i|_t||_yr)r#r_mapr$s rrz_BaseSelectorImpl.__init__s$T* r c t|S#t$r?|jjD] }|j|us|j ccYSwxYwr)rrr#valuesrrrrkeys rr)z!_BaseSelectorImpl._fileobj_lookupsW  !'* * --/;;')66M0   s 4AAANcF|r|ttzzrtdj|t ||j |||}|j |jvr%tdj||j ||j|j <|S)NzInvalid events: {!r}z"{!r} (FD {}) is already registered) EVENT_READ EVENT_WRITErrrr)rr#r*rrrrrWs rr9z_BaseSelectorImpl.registersFzK'?%@@3::6BC C'4#7#7#@&$O 66T__ $?"F7CFF35 5#& r c |jj|j|}|S#t$rtdj |dwxYwr')r#popr)r*rrVs rr;z_BaseSelectorImpl.unregistersZ O//%%d&:&:7&CDC  O3::7CD$ N Os *.%Acr |j|j|}||jk7r&|j ||j |||}|S||jk7r+|j|}||j|j<|S#t$rtdj|dwxYw)Nr()r) r#r)r*rrr;r9r_replacerr[s rr>z_BaseSelectorImpl.modifys O//$"6"6w"?@C SZZ  OOG $--6C  SXX ,,D,)C&)DOOCFF #  O3::7CD$ N Os B%B6cF|jjd|_yr)r#clearrSr$s rrCz_BaseSelectorImpl.close s  r c|jSr)rSr$s rrEz_BaseSelectorImpl.get_maps yyr cB |j|S#t$rYywxYwr)r#r*)rrs r _key_from_fdz_BaseSelectorImpl._key_from_fds-  ??2& &  s  r) r/r0r1rr)r9r;r>rCrErdr2r rrQrQs-'+ &   r rQc~eZdZ fdZdfd ZfdZejdk(rddZn e jZddZ xZ S)SelectSelectorc^t|t|_t|_yr)superrset_readers_writersr __class__s rrzSelectSelector.__init__%s    r ct||||}|tzr%|jj |j |t zr%|jj |j |Sr)rhr9rYrjaddrrZrk)rrrrrWrms rr9zSelectSelector.register*sWgw5 J  MM  cff % K  MM  cff % r ct||}|jj|j|j j|j|Sr)rhr;rjdiscardrrkrrrWrms rr;zSelectSelector.unregister2sCg ) cff% cff% r win32cJtj||||\}}}|||zgfSr)rA)rrw_r@xs r_selectzSelectSelector._select9s,mmAq!W5GAq!a!eR< r c|dn t|d}g} |j|j|jg|\}}}t |}t |}||zD]R}d}||vr |t z}||vr |tz}|j|}|s3|j|||jzfT|S#t$r|cYSwxYwNr) maxryrjrkInterruptedErrorrirYrZrdappendr) rr@readyrurvrwrrrWs rrAzSelectSelector.select?s!/$s7A ll4==$--WMGAq! F Fa%BFQw*$Qw+%##B'C c6CJJ#678   L s,B22 C?Cr) r/r0r1rr9r;sysplatformryrA __classcell__rms@rrfrf"s8    ||w --r rfcVeZdZ dZdZdZfdZdfd ZfdZdfd Z ddZ xZ S)_PollLikeSelectorNcLt||j|_yr)rhr _selector_clsrrls rrz_PollLikeSelector.__init__[s ++-r ct||||}d}|tzr||jz}|tzr||j z} |j j|j||S#t|!|xYwr{) rhr9rY _EVENT_READrZ _EVENT_WRITErrr;)rrrrrW poller_eventsrms rr9z_PollLikeSelector.register_sgw5 J  T-- -M K  T.. .M  NN # #CFFM :   G w ' s &A..Bct||} |jj|j|S#t$rY|SwxYwr)rhr;rrOSErrorrrs rr;z_PollLikeSelector.unregistermsOg )  NN % %cff -      s%9 AAc |j|j|}d}||jk7r[d}|tzr||j z}|t zr||jz} |jj|j|d}||jk7rd}|r,|j||}||j|j<|S#t$rt|ddwxYw#t|1|xYw)Nz is not registeredFrT)rr)r#r)r*rrYrrZrrr>rrhr;rr_)rrrrrWchangedselector_eventsrms rr>z_PollLikeSelector.modifyws  G//$"6"6w"?@C SZZ O "4#3#33 #4#4#44 %%cffo>G 388 G ,,f4,8C&)DOOCFF # - Gg[(:;<$ F G "7+sC%&C*C'*C<c|d}n |dkrd}ntj|dz}g} |jj|}|D]m\}}d}||j zr |t z}||jzr |tz}|j|}|sN|j|||jzfo|S#t$r|cYSwxYw)Nr@@) mathceilrpollr}rrZrrYrdr~r)rr@r fd_event_listreventrrWs rrAz_PollLikeSelector.selects ?G \Gii# .G  NN//8M'IBF((((+%))))*$##B'C c6CJJ#678'   L sB88 CCr) r/r0r1rrrrr9r;r>rArrs@rrrUs.FMKL. 6r rrcVeZdZ ejZej ZejZ y) PollSelectorN) r/r0r1rArrPOLLINrPOLLOUTrr2r rrrs " mm ~~ r repollcveZdZ ejZej ZejZ dZ ddZfdZ xZ S) EpollSelectorc6|jjSrrr r$s rr zEpollSelector.fileno>>((* *r c|d}n#|dkrd}ntj|dzdz}tt|jd}g} |j j ||}|D]u\}}d}|tjzr |tz}|tjzr |tz}|j|}|sV|j|||jzfw|S#t$r|cYSwxYw)NrrgMbP?r)rrr|r"r#rrr}rAEPOLLINrZEPOLLOUTrYrdr~r) rr@max_evrrrrrrWs rrAzEpollSelector.selectsA))GcM2T9 T__-q1FE  $ 3 3GV D + EFNN?*k)FFOO++j(F''+LL#v ':!;<+L$   s C## C10C1cV|jjt|yrrrCrhrls rrCzEpollSelector.close NN " GMOr r) r/r0r1rArrrrrrr rCrrs@rrrs6# nn   + @  r rdevpollcneZdZ ejZej ZejZ dZ fdZ xZ S)DevpollSelectorc6|jjSrrr$s rr zDevpollSelector.filenorr cV|jjt|yrrrls rrCzDevpollSelector.closerr ) r/r0r1rArrrrrrr rCrrs@rrrs0) mm ~~  +  r rkqueuecNeZdZ fdZdZdfd ZfdZddZfdZxZ S)KqueueSelectorcbt|tj|_d|_yr{)rhrrArr _max_eventsrls rrzKqueueSelector.__init__s# G  #]]_DN D r c6|jjSrrr$s rr zKqueueSelector.filenorr c:t||||} |tzrptj|j tj tj}|jj|gdd|xjdz c_ |tzrptj|j tjtj}|jj|gdd|xjdz c_ |S#t|5|xYwNrr)rhr9rYrAkeventrKQ_FILTER_READ KQ_EV_ADDrcontrolrrZKQ_FILTER_WRITEr;)rrrrrWkevrms rr9zKqueueSelector.registers'"7FD9C J& --0E0E(.(8(8:CNN**C5!Q7$$)$K' --0F0F(.(8(8:CNN**C5!Q7$$)$J "7+s C2DDcxt||}|jtzrqt j |j tjtj}|xjdzc_ |jj|gdd|jtzrst j |j tjtj}|xjdzc_ |jj|gdd|S|S#t$rYwxYw#t$rY|SwxYw)Nrr)rhr;rrYrArrr KQ_EV_DELETErrrrrZr)rrrWrrms rr;zKqueueSelector.unregisters '$W-CzzJ&mmCFFF,A,A$*$7$79  A% NN**C5!Q7 zzK'mmCFFF,B,B$*$7$79  A% NN**C5!Q7J3JJs$7D;D, D)(D), D98D9c|dn t|d}|jxsd}g} |jjd||}|D]}|j }|j }d}|tjk(r |tz}|tjk(r |tz}|j|} | si|j| || jzf|S#t$r|cYSwxYwr)r|rrrr}identfilterrArrYrrZrdr~r) rr@rrkev_listrrflagrrWs rrAzKqueueSelector.select.s%od3w?G%%*FE >>11$H YYzz6000j(F6111k)F''+LL#v ':!;< L$   sC CCcV|jjt|yrrrls rrCzKqueueSelector.closeGrr r) r/r0r1rr r9r;rArCrrs@rrrs)$ !  + $ . 2  r rc tt|d}|y |}|dk(r|jdy|jy#t$rYywxYw)NFrrT)getattrrArrCr)methodr selector_objs r_can_userLsjvvt,H z V    a      sAA AA)abcrr collectionsrcollections.abcrrrArrYrZrr__doc__rrrrrr4rQrfrhasattrrrrrrDefaultSelectorr2r rrss("#   2(KL   8 6 R E /w/({W{|Q Qh0&0fW)Wt 66&(& 67+)+\ 69 +  68O*Od4 H$O g#O i%O f"O$Or