Ϫf"2dZddlZddlZddlmZddlmZddlmZddl m Z  e edZ e edZ e ed Ze ed Ze ed ZeeGd d ej(ej*ZdZd dgZy#e$r ZeedZ[wwxYw)z An epoll() based implementation of the twisted main loop. To install the event loop (and you should do this before any connections, listeners or connectors are added):: from twisted.internet import epollreactor epollreactor.install() N) implementer) posixbase) IReactorFDSet)logepollEPOLLHUPEPOLLERREPOLLINEPOLLOUTcheZdZdZeezZeZe Z dZ dZ dZ dZdZdZdZd Zd Zd Zd ZeZy ) EPollReactora A reactor that uses epoll(7). @ivar _poller: A C{epoll} which will be used to check for I/O readiness. @ivar _selectables: A dictionary mapping integer file descriptors to instances of C{FileDescriptor} which have been registered with the reactor. All C{FileDescriptors} which are currently receiving read or write readiness notifications will be present as values in this dictionary. @ivar _reads: A set containing integer file descriptors. Values in this set will be registered with C{_poller} for read readiness notifications which will be dispatched to the corresponding C{FileDescriptor} instances in C{_selectables}. @ivar _writes: A set containing integer file descriptors. Values in this set will be registered with C{_poller} for write readiness notifications which will be dispatched to the corresponding C{FileDescriptor} instances in C{_selectables}. @ivar _continuousPolling: A L{_ContinuousPolling} instance, used to handle file descriptors (e.g. filesystem files) that are not supported by C{epoll(7)}. ctd|_t|_t|_i|_t j||_t jj|y)zm Initialize epoll object, file descriptor tracking dictionaries, and the base class. iN) r_pollerset_reads_writes _selectablesr_ContinuousPolling_continuousPollingPosixReactorBase__init__)selfs ?/usr/lib/python3/dist-packages/twisted/internet/epollreactor.pyrzEPollReactor.__init__GsPT{ e u "+">">t"D""++D1c|j}||vr[|}||vr"||z}|jj||n|jj|||j ||||<yy)z Private method for adding a descriptor from the event loop. It takes care of adding it if new or modifying it if already added for another state (read -> read/write for example). N)filenormodifyregisteradd) rxerprimaryother selectablesevent antieventfdflagss r_addzEPollReactor._addVsrZZ\ W E U{" ##B. %%b%0 KKO!KO! rc |j||j|j|jtt y#t $rD}|jtjk(r|jj|nYd}~yd}~wwxYw)zR Add a FileDescriptor for notification of data available to read. N) r(rrrr r OSErrorerrnoEPERMr addReader)rreaderes rr-zEPollReactor.addReaderpsn  II T\\43D3Dgx  ww%++%''11&9:  2""2&> %%//1  2 =>s A8A= c|jDcgc]}|j|c}|jjzScc}wN)rrr getReadersrDs rrGzEPollReactor.getReaderssE,0KK &(D  b !  # # . . 01 1 Ac|jDcgc]}|j|c}|jjzScc}wrF)rrr getWritersrDs rrJzEPollReactor.getWriterssE,0LL &(D  b !  # # . . 01 1 rHcp|d} |jj|t|j}|j}|D].\}} |j|}tj|||||0y#t$r(}|j t j k(rYd}~yd}~wwxYw#t$rYqwxYw)z1 Poll the poller for new events. Nr5) rpolllenrr*r+EINTR_doReadOrWritercallWithLoggerKeyError)rtimeoutlerr_drdwr&r$ selectables rdoPollzEPollReactor.doPolls ?G   !!'3t/@/@+ABA## MIB M!..r2 "":uj"eL  M yyEKK'    s//A5 B)5 B&>B! B!!B&) B54B5N)__name__ __module__ __qualname____doc__rr _POLL_DISCONNECTEDr _POLL_INr _POLL_OUTrr(r-r2r:r=r@rCrGrJrW doIterationrrr r %s]8"H,HI 2"4""2      1 1 M>Krr c4t}ddlm}||y)z& Install the epoll() reactor. r)installReactorN)r twisted.internet.mainrb)prbs rinstallres A41rre)r[r+selectzope.interfacertwisted.internetrtwisted.internet.interfacesrtwisted.pythonrgetattrrrr r r AttributeErrorr/ ImportErrorr_PollLikeMixinr re__all__r`rrrps &&5  FG $Evz*Hvz*Hfi(Gvz*H  ]P9--y/G/GPPf 9 %E a.s-BB BB