%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/kqreactor.cpython-312.pyc

�

Ϫ�fB*��r�dZddlZddlZddlmZmZmZmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZ	eed�Zeed�Zeed	�Zeed
�Zeed�ZGd�d
e�Zej6ee�ee
e�Gd�de
j8��Zd�ZddgZy#e$r
Zee��dZ[wwxYw)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�0�eZdZdZed�Zed�Zy)�_IKQueuez2
    An interface for KQueue implementations.
    zAn implementation of kqueue(2).zAn implementation of kevent(2).N)�__name__�
__module__�__qualname__�__doc__r�kqueue�kevent���</usr/lib/python3/dist-packages/twisted/internet/kqreactor.pyrr*s����8�
9�F�
�8�
9�Frrc�f�eZdZdZefd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�ZeZy)�
KQueueReactoram
    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���||_|jj�|_t�|_t�|_i|_tjj|�y)a�
        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  rr'zKQueueReactor.__init__QsM��!��
��:�:�$�$�&����e����u�������"�"�+�+�D�1rc�v�|jj|jj|||�gdd�y)z�
        Private method for changing kqueue registration on a given FD
        filtering for events given filter/op. This will never block and
        returns nothing.
        rN)r!�controlr r)r(�fd�filter�ops    r�_updateRegistrationz!KQueueReactor._updateRegistrationes0��	
�����$�*�*�+�+�B���;�<�a��Crc�F�|jj�d|_y)zA
        Implement L{IReactorDaemonize.beforeDaemonize}.
        N)r!�close)r(s r�beforeDaemonizezKQueueReactor.beforeDaemonizems��	
��������rc���|jj�|_|jD]}|j	|t
t��|jD]}|j	|tt��y)z@
        Implement L{IReactorDaemonize.afterDaemonize}.
        N)	r rr!r#r/rr
r$r�r(r,s  r�afterDaemonizezKQueueReactor.afterDaemonize}sf���:�:�$�$�&����+�+�	D�B��$�$�R���C�	D��,�,�	E�B��$�$�R��)�D�	Erc�J�|j�}||jvrG	|j|tt�||j|<|jj|�yy#t
$rY�7wxYw#||j|<|jj|�wxYw)z7
        Implement L{IReactorFDSet.addReader}.
        N)�filenor#r/rr
�OSErrorr%�add)r(�readerr,s   r�	addReaderzKQueueReactor.addReader�s����]�]�_��
�T�[�[� �
$��(�(��^�Y�G�)/��!�!�"�%�������#�!���
��
��)/��!�!�"�%�������#��#�A'�'	A3�0A6�2A3�3A6�6,B"c�J�|j�}||jvrG	|j|tt�||j|<|jj|�yy#t
$rY�7wxYw#||j|<|jj|�wxYw)z7
        Implement L{IReactorFDSet.addWriter}.
        N)r7r$r/rr
r8r%r9)r(�writerr,s   r�	addWriterzKQueueReactor.addWriter�s����]�]�_��
�T�\�\�!�
%��(�(��_�i�H�)/��!�!�"�%���� � ��$�"���
��
��)/��!�!�"�%���� � ��$�r<c��d}	|j�}|dk(r+|jj�D]
\}}||us�d}ny||jvrV|jj|�||jvr
|j|=|s	|j|tt�yyy#t$rd}Y��wxYw#t$rYywxYw)z:
        Implement L{IReactorFDSet.removeReader}.
        F���TN)r7�
BaseExceptionr%�itemsr#�remover$r/rrr8)r(r:�wasLostr,�fdess     r�removeReaderzKQueueReactor.removeReader�s�����	�����B���8� �-�-�3�3�5�
���D��T�>�"�G��
�
�
������K�K���r�"�����%��%�%�b�)����,�,�R���N��	���	��B�	�� �����#�B)�B:�)B7�6B7�:	C�Cc��d}	|j�}|dk(r+|jj�D]
\}}||us�d}ny||jvrV|jj|�||jvr
|j|=|s	|j|tt�yyy#t$rd}Y��wxYw#t$rYywxYw)z:
        Implement L{IReactorFDSet.removeWriter}.
        FrATN)r7rBr%rCr$rDr#r/rrr8)r(r>rEr,rFs     r�removeWriterzKQueueReactor.removeWriter�s�����	�����B���8� �-�-�3�3�5�
���D��T�>�"�G��
�
�
������L�L����#�����$��%�%�b�)����,�,�R��,�O��	���	��B�	�� ����rHc���|j|jD�cgc]}|j|��c}|jD�cgc]}|j|��c}�Scc}wcc}w)z7
        Implement L{IReactorFDSet.removeAll}.
        )�
_removeAllr#r%r$r4s  r�	removeAllzKQueueReactor.removeAll�sU�����-1�[�[�9�r�T�
�
�r�
"�9�-1�\�\�:�r�T�
�
�r�
"�:�
�	
��9��:s�A�A"
c�Z�|jD�cgc]}|j|��c}Scc}w)z8
        Implement L{IReactorFDSet.getReaders}.
        )r#r%r4s  r�
getReaderszKQueueReactor.getReaders�s'��15���<�"��!�!�"�%�<�<��<��(c�Z�|jD�cgc]}|j|��c}Scc}w)z8
        Implement L{IReactorFDSet.getWriters}.
        )r$r%r4s  r�
getWriterszKQueueReactor.getWriters�s'��15���=�"��!�!�"�%�=�=��=rPc��|�d}	|jjgt|j�|�}|j}|D]7}|j}	|j|}tj|||||��9y#t$r(}|j
t
jk(rYd}~y�d}~wwxYw#t$rY�zwxYw)z1
        Poll the kqueue for new events.
        N�)r!r+�lenr%r8�errno�EINTR�_doWriteOrRead�identr�callWithLogger�KeyError)r(�timeout�events�e�_drdw�eventr,�
selectables        r�doKEventzKQueueReactor.doKEvent�s����?��G�		��X�X�%�%�b�#�d�.?�.?�*@�'�J�F��#�#���		M�E����B�
M�!�.�.�r�2�
��"�"�:�u�j�"�e�L�		M���	��w�w�%�+�+�%����	���
��
�s/�0A?�B3�?	B0�B+�*B+�+B0�3	B?�>B?c��d}d}|j|j|j|jf\}}}}	|tzr|r|	rt
j}n]	|j�dk(rd}tj}n6|tk(rd}|j�}|tk(rd}|j�}|r|j'|||�yy#t$r-tj �}t#j$|d�Y�LwxYw)z�
        Private method called when a FD is ready for reading, writing or was
        lost. Do the work and raise errors where necessary.
        NFrATzSAn exception was raised from application code while processing a reactor selectable)r-�flags�data�fflagsrr�CONNECTION_LOSTr7r�_NO_FILEDESCr�doReadr�doWriterBr�Failurer�err�_disconnectSelectable)
r(rar,r`�why�inReadr-rdrerfs
          rrXzKQueueReactor._doWriteOrReads���
�����L�L��K�K��J�J��L�L�	)
�%����f��9���&��&�&�C�
��$�$�&�"�,�"�F�#�0�0�C���/�!%��(�/�/�1����0�!&��(�0�0�2����&�&�z�3��?���!�
��o�o�'������=��	
�s�AC
�
3D�?DN)rrrr�selectr'r/r2r5r;r?rGrJrMrOrRrbrX�doIterationrrrrr6sY���2$*�2�(D�� E�$�%��4�4
�=�>�M�<'@�R�Krrc�4�t�}ddlm}||�y)z'
    Install the kqueue() reactor.
    r)�installReactorN)r�twisted.internet.mainrs)�prss  r�installrv:s��	��A�4��1�rrv) rrVrp�zope.interfacerrrr�twisted.internetrr�twisted.internet.interfacesr	r
�twisted.pythonrr�getattrr
rrrr�AttributeErrorr^�ImportErrorr�directlyProvidesr&rrv�__all__rrr�<module>r�s���
�
�
�J�J�,�H�'��
���,�I��6�>�2�L����,�I��V�%5�6�N��f�&7�8�O�
:�y�:�����f�h�/�
�]�-�.�@�I�.�.�@�/�@�F��I�
&���}��
�a�.����s�-B$�$B6�)B1�1B6

Zerion Mini Shell 1.0