← Back
Editing: pollreactor.cpython-38.pyc
U ��W[� � @ s� d Z ddlmZmZ ddlZddlmZmZ ddlm Z m Z mZmZm Z ddlmZ ddlmZ ddlmZ dd lmZ ee�G d d� dejej��Zdd � 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� 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 = s zPollReactor.__init__c C s| z| j �|� W n tk r$ Y nX d}|| jkr<|tB }|| jkrN|tB }|dkrf| j �||� n|| jkrx| j|= dS )z*Register/unregister an fd with the poller.r N) r Z unregister�KeyErrorr r r r �registerr )r �fd�maskr r r �_updateRegistrationI s zPollReactor._updateRegistrationc C sd z|� � }|| W n2 | j�� D ]\}}||kr& qBq&Y d S Y nX ||kr`||= | �|� d S )N)�filenor �itemsr )r � selectableZmdictr Zfdesr r r �_dictRemove[ s zPollReactor._dictRemovec C s4 |� � }|| jkr0|| j|<