HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/twisted/internet/__pycache__/epollreactor.cpython-38.pyc
U

�b�"�
@s�dZddlZddlZddlmZddlmZddlmZddl	m
Z
z6eed�Zeed�Z
eed	�Zeed
�Zeed�ZWn*ek
r�Zzee��W5dZ[XYnXee�Gdd
�d
ejej��Zdd�Zd
dgZdS)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)�log�epoll�EPOLLHUP�EPOLLERR�EPOLLIN�EPOLLOUTc@s|eZdZdZeeBZeZe	Z
dd�Zdd�Zdd�Z
dd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�ZeZdS)�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)}.
    cCs<td�|_t�|_t�|_i|_t�|�|_tj	�
|�dS)zm
        Initialize epoll object, file descriptor tracking dictionaries, and the
        base class.
        iN)r�_poller�set�_reads�_writes�_selectablesrZ_ContinuousPolling�_continuousPolling�PosixReactorBase�__init__��self�r�?/usr/lib/python3/dist-packages/twisted/internet/epollreactor.pyrGs
zEPollReactor.__init__c	CsX|��}||krT|}||kr4||O}|j�||�n|j�||�|�|�|||<dS)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)�filenor�modify�register�add)	r�xer�primary�other�selectables�event�	antievent�fd�flagsrrr�_addVs
zEPollReactor._addc
Csbz|�||j|j|jtt�Wn>tk
r\}z |jtjkrJ|j	�
|�n�W5d}~XYnXdS)zR
        Add a FileDescriptor for notification of data available to read.
        N)r$rrrr	r
�OSError�errno�EPERMr�	addReader)r�reader�errrr(ps�zEPollReactor.addReaderc
Csbz|�||j|j|jtt�Wn>tk
r\}z |jtjkrJ|j	�
|�n�W5d}~XYnXdS)zS
        Add a FileDescriptor for notification of data available to write.
        N)r$rrrr
r	r%r&r'r�	addWriter)r�writerr*rrrr+�s�zEPollReactor.addWriterc
Csv|��}|dkr2|��D]\}}||krq2qdS||krr||krV|}	|j�||	�n||=|j�|�|�|�dS)z�
        Private method for removing a descriptor from the event loop.

        It does the inverse job of _add, and also add a check in case of the fd
        has gone away.
        ���N)r�itemsrrZ
unregister�remove)
rrrrrr r!r"Zfdesr#rrr�_remove�szEPollReactor._removecCs:|j�|�r|j�|�dS|�||j|j|jtt�dS)zQ
        Remove a Selectable for notification of data available to read.
        N)	rZ	isReading�removeReaderr0rrrr	r
)rr)rrrr1�s�zEPollReactor.removeReadercCs:|j�|�r|j�|�dS|�||j|j|jtt�dS)zR
        Remove a Selectable for notification of data available to write.
        N)	rZ	isWriting�removeWriterr0rrrr
r	)rr,rrrr2�s�zEPollReactor.removeWritercs6���fdd��jD��fdd��jD���j��S)zD
        Remove all selectables, and return a list of them.
        csg|]}�j|�qSr�r��.0r"rrr�
<listcomp>�sz*EPollReactor.removeAll.<locals>.<listcomp>csg|]}�j|�qSrr3r4rrrr6�s)Z
_removeAllrrr�	removeAllrrrrr7�s���zEPollReactor.removeAllcs�fdd��jD��j��S)Ncsg|]}�j|�qSrr3r4rrrr6�sz+EPollReactor.getReaders.<locals>.<listcomp>)rr�
getReadersrrrrr8�s

��zEPollReactor.getReaderscs�fdd��jD��j��S)Ncsg|]}�j|�qSrr3r4rrrr6�sz+EPollReactor.getWriters.<locals>.<listcomp>)rr�
getWritersrrrrr9�s

��zEPollReactor.getWritersc
Cs�|dkrd}z|j�|t|j��}Wn:tk
r^}z|jtjkrLWY�
dS�W5d}~XYnX|j}|D]>\}}z|j|}Wntk
r�YqjXt	�
|||||�qjdS)z1
        Poll the poller for new events.
        Nr-)rZpoll�lenrr%r&ZEINTRZ_doReadOrWrite�KeyErrorrZcallWithLogger)rZtimeout�l�errZ_drdwr"r Z
selectablerrr�doPoll�s
zEPollReactor.doPollN)�__name__�
__module__�__qualname__�__doc__rrZ_POLL_DISCONNECTEDr	Z_POLL_INr
Z	_POLL_OUTrr$r(r+r0r1r2r7r8r9r>ZdoIterationrrrrr%s rcCst�}ddlm}||�dS)z&
    Install the epoll() reactor.
    r)�installReactorN)rZtwisted.internet.mainrC)�prCrrr�install�srE)rBr&ZselectZzope.interfacer�twisted.internetrZtwisted.internet.interfacesrZtwisted.pythonr�getattrrrrr	r
�AttributeErrorr*�ImportErrorrZ_PollLikeMixinrrE�__all__rrrr�<module>s&




T