§
    ÈtºfV  ã                   óÈ   — d Z ddlZddlmZmZmZmZmZmZ	m
Z
 ddlmZ ddlmZ ddlmZ ddlmZ  ee¦  «         G d„ d	ej        ej        ¦  «        ¦   «         Zd
„ Zd	dgZdS )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                   óp   — e Zd ZdZeez  ez  ZeZ	e
Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd	„ Zd
„ ZeZd„ Zd„ ZdS )Ú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                 ó”   — t          ¦   «         | _        i | _        i | _        i | _        t
          j                             | ¦  «         dS )zo
        Initialize polling object, file descriptor tracking dictionaries, and
        the base class.
        N)r	   Ú_pollerÚ_selectablesÚ_readsÚ_writesr   ÚPosixReactorBaseÚ__init__©Úselfs    ú[/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/pollreactor.pyr   zPollReactor.__init__C   sB   € õ
 ‘v”vˆŒØˆÔØˆŒØˆŒÝÔ"×+Ò+¨DÑ1Ô1Ð1Ð1Ð1ó    c                 ó  — 	 | j                              |¦  «         n# t          $ r Y nw xY wd}|| j        v r
|t          z  }|| j        v r
|t          z  }|dk    r| j                              ||¦  «         dS || j        v r
| j        |= dS dS )z*Register/unregister an fd with the poller.r   N)	r   Ú
unregisterÚKeyErrorr   r   r   r   Úregisterr   )r   ÚfdÚmasks      r   Ú_updateRegistrationzPollReactor._updateRegistrationN   sÁ   € ð	ØŒL×#Ò# BÑ'Ô'Ð'Ð'øÝð 	ð 	ð 	ØˆDð	øøøð ˆØ�”ÐÐØ�&‘=ˆDØ�”ÐÐØ�'‘>ˆDØ�1Š9ˆ9ØŒL×!Ò! " dÑ+Ô+Ð+Ð+Ð+à�TÔ&Ð&Ð&ØÔ% bÐ)Ð)Ð)ð 'Ð&s   ‚ �
*©*c                 óî   — 	 |                      ¦   «         }||          n8# t          $ r+ | j                             ¦   «         D ]\  }}||u r nŒY d S Y nw xY w||v r||= |                      |¦  «         d S d S )N)ÚfilenoÚBaseExceptionr   Úitemsr!   )r   Ú
selectableÚmdictr   Úfdess        r   Ú_dictRemovezPollReactor._dictRemove`   s¼   € ð	à×"Ò"Ñ$Ô$ˆBð �"ŒIˆIˆIøÝð 		ð 		ð 		ð !Ô-×3Ò3Ñ5Ô5ð ð ‘��DØ Ð%Ð%Ø�Eð &ð
 ��ð	 �Eð		øøøð �ˆ;ˆ;Ø�b�	Ø×$Ò$ RÑ(Ô(Ð(Ð(Ð(ð ˆ;s   ‚ Ÿ/AÁAc                 ó–   — |                      ¦   «         }|| j        vr+|| j        |<   d| j        |<   |                      |¦  «         dS dS )z@Add a FileDescriptor for notification of data available to read.é   N)r#   r   r   r!   )r   Úreaderr   s      r   Ú	addReaderzPollReactor.addReaderu   sV   € à�]Š]‰_Œ_ˆØ�T”[Ð Ð Ø$*ˆDÔ˜bÑ!ØˆDŒK˜‰OØ×$Ò$ RÑ(Ô(Ð(Ð(Ð(ð !Ð r   c                 ó–   — |                      ¦   «         }|| j        vr+|| j        |<   d| j        |<   |                      |¦  «         dS dS )zAAdd a FileDescriptor for notification of data available to write.r+   N)r#   r   r   r!   )r   Úwriterr   s      r   Ú	addWriterzPollReactor.addWriter}   sW   € à�]Š]‰_Œ_ˆØ�T”\Ð!Ð!Ø$*ˆDÔ˜bÑ!Ø ˆDŒL˜ÑØ×$Ò$ RÑ(Ô(Ð(Ð(Ð(ð "Ð!r   c                 ó8   — |                       || j        ¦  «        S )z?Remove a Selectable for notification of data available to read.)r)   r   )r   r,   s     r   ÚremoveReaderzPollReactor.removeReader…   s   € à×Ò ¨¬Ñ4Ô4Ð4r   c                 ó8   — |                       || j        ¦  «        S )z@Remove a Selectable for notification of data available to write.)r)   r   )r   r/   s     r   ÚremoveWriterzPollReactor.removeWriter‰   s   € à×Ò ¨¬Ñ5Ô5Ð5r   c                 ót   ‡ — ‰                       ˆ fd„‰ j        D ¦   «         ˆ fd„‰ j        D ¦   «         ¦  «        S )zD
        Remove all selectables, and return a list of them.
        c                 ó*   •— g | ]}‰j         |         ‘ŒS © ©r   ©Ú.0r   r   s     €r   ú
<listcomp>z)PollReactor.removeAll.<locals>.<listcomp>’   s!   ø€ Ð9Ð9Ð9 rˆTÔ˜rÔ"Ð9Ð9Ð9r   c                 ó*   •— g | ]}‰j         |         ‘ŒS r7   r8   r9   s     €r   r;   z)PollReactor.removeAll.<locals>.<listcomp>“   s!   ø€ Ð:Ð:Ð: rˆTÔ˜rÔ"Ð:Ð:Ð:r   )Ú
_removeAllr   r   r   s   `r   Ú	removeAllzPollReactor.removeAll�   sM   ø€ ð �ŠØ9Ð9Ð9Ð9¨T¬[Ð9Ñ9Ô9Ø:Ð:Ð:Ð:¨T¬\Ð:Ñ:Ô:ñ
ô 
ð 	
r   c                 óZ  — |�t          |dz  ¦  «        }	 | j                             |¦  «        }n4# t          $ r'}|j        d         t
          j        k    rY d}~dS ‚ d}~ww xY w| j        }|D ]<\  }}	 | j        |         }n# t          $ r Y Œ w xY wt          j        |||||¦  «         Œ=dS )zPoll the poller for new events.Niè  r   )Úintr   r	   ÚSelectErrorÚargsÚerrnoÚEINTRÚ_doReadOrWriter   r   r   ÚcallWithLogger)r   ÚtimeoutÚlÚeÚ_drdwr   Úeventr&   s           r   ÚdoPollzPollReactor.doPoll–   sö   € àÐÝ˜' D™.Ñ)Ô)ˆGð	Ø”×!Ò! 'Ñ*Ô*ˆAˆAøÝð 	ð 	ð 	ØŒv�aŒy�EœKÒ'Ð'Ø�����àøøøøð		øøøð
 Ô#ˆØð 	Ið 	I‰IˆB�ðØ!Ô.¨rÔ2�
�
øÝð ð ð ð �ðøøøõ Ô˜z¨5°*¸bÀ%ÑHÔHÐHÐHð	Ið 	Is,   –1 ±
A"»AÁAÁA"Á4BÂ
BÂBc                 ó*   ‡ — ˆ fd„‰ j         D ¦   «         S )Nc                 ó*   •— g | ]}‰j         |         ‘ŒS r7   r8   r9   s     €r   r;   z*PollReactor.getReaders.<locals>.<listcomp>¯   s!   ø€ Ð<Ð<Ð<¨"�Ô! "Ô%Ð<Ð<Ð<r   )r   r   s   `r   Ú
getReaderszPollReactor.getReaders®   s   ø€ Ø<Ð<Ð<Ð<°´Ð<Ñ<Ô<Ð<r   c                 ó*   ‡ — ˆ fd„‰ j         D ¦   «         S )Nc                 ó*   •— g | ]}‰j         |         ‘ŒS r7   r8   r9   s     €r   r;   z*PollReactor.getWriters.<locals>.<listcomp>²   s!   ø€ Ð=Ð=Ð=¨"�Ô! "Ô%Ð=Ð=Ð=r   )r   r   s   `r   Ú
getWriterszPollReactor.getWriters±   s   ø€ Ø=Ð=Ð=Ð=°´Ð=Ñ=Ô=Ð=r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   Ú_POLL_DISCONNECTEDr   Ú_POLL_INr   Ú	_POLL_OUTr   r!   r)   r-   r0   r2   r4   r>   rL   ÚdoIterationrO   rR   r7   r   r   r   r   $   sé   € € € € € ðð ð2 ! 7Ñ*¨XÑ5ÐØ€HØ€Ið	2ð 	2ð 	2ð*ð *ð *ð$)ð )ð )ð*)ð )ð )ð)ð )ð )ð5ð 5ð 5ð6ð 6ð 6ð
ð 
ð 
ðIð Ið Ið, €Kð=ð =ð =ð>ð >ð >ð >ð >r   r   c                  óD   — t          ¦   «         } ddlm}  || ¦  «         dS )zInstall the poll() reactor.r   )ÚinstallReactorN)r   Útwisted.internet.mainr\   )Úpr\   s     r   Úinstallr_   µ   s3   € å‰Œ€AØ4Ð4Ð4Ð4Ð4Ð4à€N�1ÑÔÐÐÐr   r_   )rV   rC   Úselectr   r   r   r   r   r   rA   r	   Úzope.interfacer
   Útwisted.internetr   Útwisted.internet.interfacesr   Útwisted.pythonr   r   Ú_PollLikeMixinr   r_   Ú__all__r7   r   r   ú<module>rg      s1  ððð ð €€€ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 'Ð &Ð &Ð &Ð &Ð &à &Ð &Ð &Ð &Ð &Ð &Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ð Ð Ð Ð Ð Ð ð €ˆ]ÑÔðM>ð M>ð M>ð M>ð M>�)Ô,¨iÔ.Fñ M>ô M>ñ ÔðM>ð`ð ð ð ˜)Ð
$€€€r   