+
    DfjB*                     x   R t ^ RIt^ RIt^ RIHtHtHtHt ^ RIH	t	H
t
 ^ RIHtHt ^ RIHtHt  ]! ]R4      t]! ]R4      t]! ]R4      t]! ]R	4      t]! ]R
4      t ! R R]4      t]P6                  ! ]]4       ]! ]]4       ! R R]
P8                  4      4       tR tRR.tR#   ] d   t]! ]4      hRtAii ; i)am  
A kqueue()/kevent() based implementation of the Twisted main loop.

To use this reactor, start your application specifying the kqueue reactor::

   twistd --reactor kqueue ...

To install the event loop from code (and you should do this before any
connections, listeners or connectors are added)::

   from twisted.internet import kqreactor
   kqreactor.install()
N)	Attribute	Interfacedeclarationsimplementer)main	posixbase)IReactorDaemonizeIReactorFDSet)failurelog	KQ_EV_ADDKQ_EV_DELETE	KQ_EV_EOFKQ_FILTER_READKQ_FILTER_WRITEc                   :    ] tR t^*tRt]! R4      t]! R4      tRtR# )_IKQueuez*
An interface for KQueue implementations.
zAn implementation of kqueue(2).zAn implementation of kevent(2). N)	__name__
__module____qualname____firstlineno____doc__r   kqueuekevent__static_attributes__r       </usr/lib/python3/dist-packages/twisted/internet/kqreactor.pyr   r   *   s     89F89Fr   r   c                   |   a  ] tR t^6t o Rt]3R ltR tR tR t	R t
R tR tR	 tR
 tR tR tR tR t]tRtV tR# )KQueueReactora%  
A reactor that uses kqueue(2)/kevent(2) and relies on Python 2.6 or higher
which has built in support for kqueue in the select module.

@ivar _kq: A C{kqueue} which will be used to check for I/O readiness.

@ivar _impl: The implementation of L{_IKQueue} to use.

@ivar _selectables: A dictionary mapping integer file descriptors to
    instances of L{FileDescriptor} which have been registered with the
    reactor.  All L{FileDescriptor}s 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{_kq} for read readiness notifications
    which will be dispatched to the corresponding L{FileDescriptor}
    instances in C{_selectables}.

@ivar _writes: A set containing integer file descriptors.  Values in this
    set will be registered with C{_kq} for write readiness notifications
    which will be dispatched to the corresponding L{FileDescriptor}
    instances in C{_selectables}.
c                    Wn         V P                   P                  4       V n        \        4       V n        \        4       V n        / V n        \        P                  P                  V 4       R# )aF  
Initialize kqueue object, file descriptor tracking dictionaries, and
the base class.

See:
    - http://docs.python.org/library/select.html
    - www.freebsd.org/cgi/man.cgi?query=kqueue
    - people.freebsd.org/~jlemon/papers/kqueue.pdf

@param _kqueueImpl: The implementation of L{_IKQueue} to use. A
    hook for testing.
N)
_implr   _kqset_reads_writes_selectablesr   PosixReactorBase__init__)self_kqueueImpls   &&r   r(   KQueueReactor.__init__Q   sK     !
::$$&eu""++D1r   c                v    V P                   P                  V P                  P                  WV4      .^ ^ 4       R# )z
Private method for changing kqueue registration on a given FD
filtering for events given filter/op. This will never block and
returns nothing.
N)r"   controlr!   r   )r)   fdfilterops   &&&&r   _updateRegistration!KQueueReactor._updateRegistratione   s.     	$**++B;<aCr   c                H    V P                   P                  4        RV n         R# )z1
Implement L{IReactorDaemonize.beforeDaemonize}.
N)r"   close)r)   s   &r   beforeDaemonizeKQueueReactor.beforeDaemonizem   s     	r   c                    V P                   P                  4       V n        V P                   F  pV P	                  V\
        \        4       K   	  V P                   F  pV P	                  V\        \        4       K   	  R# )z0
Implement L{IReactorDaemonize.afterDaemonize}.
N)	r!   r   r"   r$   r1   r   r   r%   r   r)   r.   s   & r   afterDaemonizeKQueueReactor.afterDaemonize}   sX     ::$$&++B$$RC ,,B$$R)D r   c                R   VP                  4       pW P                  9  dH    V P                  V\        \        4       WP                  V&   V P                  P                  V4       R# R#   \
         d     L:i ; i  YP                  T&   T P                  P                  T4       i ; i)z'
Implement L{IReactorFDSet.addReader}.
N)filenor$   r1   r   r   OSErrorr&   add)r)   readerr.   s   && r   	addReaderKQueueReactor.addReader   s     ]]_[[ $((^YG )/!!"%# !   )/!!"%##   A* *A85A; 7A88A; ;+B&c                R   VP                  4       pW P                  9  dH    V P                  V\        \        4       WP                  V&   V P                  P                  V4       R# R#   \
         d     L:i ; i  YP                  T&   T P                  P                  T4       i ; i)z'
Implement L{IReactorFDSet.addWriter}.
N)r<   r%   r1   r   r   r=   r&   r>   )r)   writerr.   s   && r   	addWriterKQueueReactor.addWriter   s     ]]_\\!%((_iH )/!!"%  $ "   )/!!"%  $rB   c                   Rp VP                  4       pVR8X  d/   V P                  P                  4        F  w  r4WJ g   K  Rp M	  R# W0P                  9   da   V P                  P                  V4       W0P                  9  d   V P                  V V'       g    V P                  V\        \        4       R# R# R#   \         d    Rp Li ; i  \         d     R# i ; i)z*
Implement L{IReactorFDSet.removeReader}.
FTN)r<   BaseExceptionr&   itemsr$   remover%   r1   r   r   r=   )r)   r?   wasLostr.   fdess   &&   r   removeReaderKQueueReactor.removeReader   s     	B 8 --335>"G 6
 KKr"%%%b),,RN 	   	B	   #   B; C ;C
CCCc                   Rp VP                  4       pVR8X  d/   V P                  P                  4        F  w  r4WJ g   K  Rp M	  R# W0P                  9   da   V P                  P                  V4       W0P                  9  d   V P                  V V'       g    V P                  V\        \        4       R# R# R#   \         d    Rp Li ; i  \         d     R# i ; i)z*
Implement L{IReactorFDSet.removeWriter}.
FTNrH   )r<   rI   r&   rJ   r%   rK   r$   r1   r   r   r=   )r)   rD   rL   r.   rM   s   &&   r   removeWriterKQueueReactor.removeWriter   s     	B 8 --335>"G 6
 LL#$%%b),,R,O 	   	B	   rP   c                    T P                  V P                   Uu. uF  qP                  V,          NK  	  upV P                   Uu. uF  qP                  V,          NK  	  up4      # u upi u upi )z'
Implement L{IReactorFDSet.removeAll}.
)
_removeAllr$   r&   r%   r8   s   & r   	removeAllKQueueReactor.removeAll   s_     -1[[9[rr""[9-1\\:\rr""\:
 	
9:s   A'A,
c                d    V P                    Uu. uF  qP                  V,          NK  	  up# u upi )z(
Implement L{IReactorFDSet.getReaders}.
)r$   r&   r8   s   & r   
getReadersKQueueReactor.getReaders   s,     15<"!!"%%<<<   -c                d    V P                    Uu. uF  qP                  V,          NK  	  up# u upi )z(
Implement L{IReactorFDSet.getWriters}.
)r%   r&   r8   s   & r   
getWritersKQueueReactor.getWriters   s,     15="!!"%%===r[   c                   Vf   ^p V P                   P                  . \        V P                  4      V4      pT P                  pT F;  pTP                  p T P                  T,          p\        P                  ! YtYvT4       K=  	  R#   \         d,   pTP
                  \
        P                  8X  d    Rp?R# h Rp?ii ; i  \         d     K  i ; i)z!
Poll the kqueue for new events.
N)r"   r-   lenr&   r=   errnoEINTR_doWriteOrReadidentr   callWithLoggerKeyError)r)   timeouteventse_drdweventr.   
selectables   &&      r   doKEventKQueueReactor.doKEvent   s     ?G		XX%%b#d.?.?*@'JF ##EBM!..r2
 "":jeL   	 ww%++%	   s/   0B C B=B87B88B= CCc                P   RpRpVP                   VP                  VP                  VP                  3w  rgrV\        ,          '       d"   V'       d   V	'       d   \
        P                  pMc VP                  4       R8X  d   Rp\        P                  pM:V\        8X  d   RpVP                  4       pV\        8X  d   RpVP                  4       pV'       d   V P'                  WV4       R# R#   \         d0    \        P                   ! 4       p\"        P$                  ! TR4        LWi ; i)zz
Private method called when a FD is ready for reading, writing or was
lost. Do the work and raise errors where necessary.
NFTzSAn exception was raised from application code while processing a reactor selectablerH   )r/   flagsdatafflagsr   r   CONNECTION_LOSTr<   r   _NO_FILEDESCr   doReadr   doWriterI   r
   Failurer   err_disconnectSelectable)
r)   rl   r.   rk   whyinReadr/   rp   rq   rr   s
   &&&&      r   rc   KQueueReactor._doWriteOrRead  s    
 LLKKJJLL	)
% 9&&&C$$&","F#00C/!%(//10!&(002 &&z?  !  oo'=	s   +'C+ :C+ +7D%$D%)r!   r"   r$   r&   r%   N)r   r   r   r   r   selectr(   r1   r5   r9   r@   rE   rN   rR   rV   rY   r]   rm   rc   doIterationr   __classdictcell__)__classdict__s   @r   r   r   6   s\     2 $* 2(D E$%44
=>M<'@R Kr   r   c                 6    \        4       p ^ RIHp V! V 4       R# )z
Install the kqueue() reactor.
)installReactorN)r   twisted.internet.mainr   )pr   s     r   installr   :  s     	A41r   r   ) r   ra   r}   zope.interfacer   r   r   r   twisted.internetr   r   twisted.internet.interfacesr   r	   twisted.pythonr
   r   getattrr   r   r   r   r   AttributeErrorri   ImportErrorr   directlyProvidesr'   r   r   __all__r   r   r   <module>r      s   
   J J , H '
 ,I6>2L,IV%56Nf&78O
:y :   fh / ]-.@I.. @ /@F I
&}  
a.s   -B% %B9,B44B9