File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/pollreactor.cpython-310.pyc
o
�bV � @ s� d Z ddlZddlmZmZmZmZmZmZ m
Z
ddlmZ ddl
mZ ddlmZ ddlmZ ee�G dd � d ejej��Zd
d� Zd dgZdS )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()
� N)�POLLERR�POLLHUP�POLLIN�POLLNVAL�POLLOUT�error�poll)�implementer)� posixbase)�
IReactorFDSet)�logc @ s� e Zd ZdZeeB eB ZeZ e
Zdd� Zdd� Z
dd� Zdd � Zd
d� Zdd
� 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}.
c C s* 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 C s
zPollReactor.__init__c C s� z| j �|� W n ty Y nw d}|| jv r|tB }|| jv r&|tB }|dkr3| j �||� dS || jv r>| j|= dS dS )z*Register/unregister an fd with the poller.r N) r �
unregister�KeyErrorr r r r �registerr )r �fd�maskr r r �_updateRegistrationN s �
�zPollReactor._updateRegistrationc C sn z
|� � }|| W n ty& | j�� D ]
\}}||u r nqY d S Y nw ||v r5||= | �|� d S d S )N)�fileno�
BaseExceptionr �itemsr )r �
selectable�mdictr �fdesr r r �_dictRemove` s ���
�zPollReactor._dictRemovec C �8 |� � }|| jvr|| j|<