
    hV                         S r SSKrSSKJrJrJrJrJrJr	J
r
  SSKJr  SSKJr  SSKJr  SSKJr  \" \5       " S S	\R&                  \R(                  5      5       rS
 rS	S/rg)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                   v    \ rS rSrSr\\-  \-  r\	r
\rS rS rS rS rS rS rS	 rS
 rS r\rS rS rSrg)PollReactor$   a  
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                     [        5       U l        0 U l        0 U l        0 U l        [
        R                  R                  U 5        g)zW
Initialize polling object, file descriptor tracking dictionaries, and
the base class.
N)r	   _poller_selectables_reads_writesr   PosixReactorBase__init__)selfs    c/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/internet/pollreactor.pyr   PollReactor.__init__C   s7    
 v""++D1    c                 >    U R                   R                  U5        SnXR                  ;   a	  U[        -  nXR
                  ;   a	  U[        -  nUS:w  a  U R                   R                  X5        gXR                  ;   a  U R                  U	 gg! [         a     N~f = f)z*Register/unregister an fd with the poller.r   N)	r   
unregisterKeyErrorr   r   r   r   registerr   )r   fdmasks      r   _updateRegistrationPollReactor._updateRegistrationN   s    	LL##B' &=D'>D19LL!!"+&&&%%b) '  		s   B 
BBc                      UR                  5       nX#     X2;   a  X#	 U R	                  U5        g g ! [         a.    U R                  R                  5        H  u  p4XL d  M     MM      g f = fN)filenoBaseExceptionr   itemsr"   )r   
selectablemdictr    fdess        r   _dictRemovePollReactor._dictRemove`   sw    	""$B I ;	$$R(   		 !--335% 6 		s   0 +A(A(#A('A(c                     UR                  5       nX R                  ;  a/  XR                  U'   SU R                  U'   U R                  U5        gg)z@Add a FileDescriptor for notification of data available to read.   N)r&   r   r   r"   )r   readerr    s      r   	addReaderPollReactor.addReaderu   sE    ]]_[[ $*b!DKKO$$R( !r   c                     UR                  5       nX R                  ;  a/  XR                  U'   SU R                  U'   U R                  U5        gg)zAAdd a FileDescriptor for notification of data available to write.r/   N)r&   r   r   r"   )r   writerr    s      r   	addWriterPollReactor.addWriter}   sF    ]]_\\!$*b! DLL$$R( "r   c                 8    U R                  XR                  5      $ )z?Remove a Selectable for notification of data available to read.)r,   r   )r   r0   s     r   removeReaderPollReactor.removeReader   s    44r   c                 8    U R                  XR                  5      $ )z@Remove a Selectable for notification of data available to write.)r,   r   )r   r4   s     r   removeWriterPollReactor.removeWriter   s    55r   c                     U R                  U R                   Vs/ s H  oR                  U   PM     snU R                   Vs/ s H  oR                  U   PM     sn5      $ s  snf s  snf )z4
Remove all selectables, and return a list of them.
)
_removeAllr   r   r   r   r    s     r   	removeAllPollReactor.removeAll   sY     -1[[9[rr"[9-1\\:\rr"\:
 	
9:s   A!A&
c                 p   Ub  [        US-  5      n U R                  R                  U5      nU R                  nU H-  u  pV U R                  U   n[        R                  " XtXuU5        M/     g! [         a,  nUR                  S   [
        R                  :X  a   SnAge SnAff = f! [         a     Mx  f = f)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   doPollPollReactor.doPoll   s    'D.)G	!!'*A ##IB!..r2

 z*%H   	vvayEKK'		   s/   A. B'.
B$8!BBB$'
B54B5c                 ^    U R                    Vs/ s H  oR                  U   PM     sn$ s  snf r%   )r   r   r?   s     r   
getReadersPollReactor.getReaders   s'    04<"!!"%<<<   *c                 ^    U R                    Vs/ s H  oR                  U   PM     sn$ s  snf r%   )r   r   r?   s     r   
getWritersPollReactor.getWriters   s'    04="!!"%===rT   )r   r   r   r   N)__name__
__module____qualname____firstlineno____doc__r   r   r   _POLL_DISCONNECTEDr   _POLL_INr   	_POLL_OUTr   r"   r,   r1   r5   r8   r;   r@   rO   doIterationrR   rV   __static_attributes__ r   r   r   r   $   sb    2 !7*X5HI	2*$)*))56
I, K=>r   r   c                  4    [        5       n SSKJn  U" U 5        g)zInstall the poll() reactor.r   )installReactorN)r   twisted.internet.mainrd   )prd   s     r   installrg      s    A41r   rg   )r\   rF   selectr   r   r   r   r   r   rD   r	   zope.interfacer
   twisted.internetr   twisted.internet.interfacesr   twisted.pythonr   r   _PollLikeMixinr   rg   __all__rb   r   r   <module>ro      sq       ' & 5  ]M>),,i.F.F M> M>` )
$r   