HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/pollreactor.cpython-38.pyc
U

��W[��@s�dZddlmZmZddlZddlmZmZddlm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZdd	lmZee�Gd
d�dejej��Zdd
�Zdd
gZdS)z�
A poll() 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 pollreactor
    pollreactor.install()
�)�division�absolute_importN)�error�poll)�POLLIN�POLLOUT�POLLHUP�POLLERR�POLLNVAL)�implementer)�log)�	posixbase)�
IReactorFDSetc@s�eZdZdZeeBeBZeZ	e
Zdd�Zdd�Z
dd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZeZdd�Zdd�ZdS)�PollReactora^
    A reactor that uses poll(2).

    @ivar _poller: A L{select.poll} which will be used to check for I/O
        readiness.

    @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 dictionary mapping integer file descriptors to arbitrary
        values (this is essentially a set).  Keys in this dictionary will be
        registered with C{_poller} for read readiness notifications which will
        be dispatched to the corresponding L{FileDescriptor} instances in
        C{_selectables}.

    @ivar _writes: A dictionary mapping integer file descriptors to arbitrary
        values (this is essentially a set).  Keys in this dictionary will be
        registered with C{_poller} for write readiness notifications which will
        be dispatched to the corresponding L{FileDescriptor} instances in
        C{_selectables}.
    cCs*t�|_i|_i|_i|_tj�|�dS)zo
        Initialize polling object, file descriptor tracking dictionaries, and
        the base class.
        N)r�_poller�_selectables�_reads�_writesr
�PosixReactorBase�__init__��self�r�>/usr/lib/python3/dist-packages/twisted/internet/pollreactor.pyr=s
zPollReactor.__init__cCs|z|j�|�Wntk
r$YnXd}||jkr<|tB}||jkrN|tB}|dkrf|j�||�n||jkrx|j|=dS)z*Register/unregister an fd with the poller.rN)	rZ
unregister�KeyErrorrrrr�registerr)r�fd�maskrrr�_updateRegistrationIs


zPollReactor._updateRegistrationcCsdz|��}||Wn2|j��D]\}}||kr&qBq&YdSYnX||kr`||=|�|�dS)N)�filenor�itemsr)r�
selectableZmdictrZfdesrrr�_dictRemove[szPollReactor._dictRemovecCs4|��}||jkr0||j|<d|j|<|�|�dS)zIAdd a FileDescriptor for notification of data available to read.
        �N)rrrr)r�readerrrrr�	addReaderps



zPollReactor.addReadercCs4|��}||jkr0||j|<d|j|<|�|�dS)zJAdd a FileDescriptor for notification of data available to write.
        r#N)rrrr)r�writerrrrr�	addWriterys



zPollReactor.addWritercCs|�||j�S)zHRemove a Selectable for notification of data available to read.
        )r"r)rr$rrr�removeReader�szPollReactor.removeReadercCs|�||j�S)zIRemove a Selectable for notification of data available to write.
        )r"r)rr&rrr�removeWriter�szPollReactor.removeWritercs,���fdd��jD��fdd��jD��S)zD
        Remove all selectables, and return a list of them.
        csg|]}�j|�qSr�r��.0rrrr�
<listcomp>�sz)PollReactor.removeAll.<locals>.<listcomp>csg|]}�j|�qSrr*r+rrrr-�s)Z
_removeAllrrrrrr�	removeAll�s�zPollReactor.removeAllc
Cs�|dk	rt|d�}z|j�|�}Wn>tk
rb}z |jdtjkrPWY�
dS�W5d}~XYnX|j}|D]B\}}z|j|}Wnt	k
r�YqnYnXt
�|||||�qndS)zPoll the poller for new events.Ni�r)�intrr�SelectError�args�errnoZEINTRZ_doReadOrWriterrrZcallWithLogger)rZtimeout�l�eZ_drdwrZeventr!rrr�doPoll�s

zPollReactor.doPollcs�fdd��jD�S)Ncsg|]}�j|�qSrr*r+rrrr-�sz*PollReactor.getReaders.<locals>.<listcomp>)rrrrr�
getReaders�szPollReactor.getReaderscs�fdd��jD�S)Ncsg|]}�j|�qSrr*r+rrrr-�sz*PollReactor.getWriters.<locals>.<listcomp>)rrrrr�
getWriters�szPollReactor.getWritersN)�__name__�
__module__�__qualname__�__doc__rr	r
Z_POLL_DISCONNECTEDrZ_POLL_INrZ	_POLL_OUTrrr"r%r'r(r)r.r5ZdoIterationr6r7rrrrrs 			rcCst�}ddlm}||�dS)zInstall the poll() reactor.r)�installReactorN)rZtwisted.internet.mainr<)�pr<rrr�install�sr>)r;Z
__future__rrr2Zselectrr0rrrrr	r
Zzope.interfacerZtwisted.pythonrZtwisted.internetr
Ztwisted.internet.interfacesrrZ_PollLikeMixinrr>�__all__rrrr�<module>s