+
    Dfj!                         R t ^ RIHt ^ RIHtHt RtRt ! R R4      t ! R R4      t	^ R	I
t
^ R	It^ R	It^ R	It]! ]4       ! R
 R]4      4       tRt]! ]4       ! R R]4      4       tR	# )z
Implements a simple polling interface for file descriptors that don't work with
select() - this is pretty much only useful on Windows.
)implementer)	IConsumerIPushProducerg&.>g?c                   0   a  ] tR t^t o RtR tR tRtV tR# )_PollableResourceTc                    R V n         R# TNactiveselfs   &?/usr/lib/python3/dist-packages/twisted/internet/_pollingfile.pyactivate_PollableResource.activate   s	        c                    R V n         R# FNr	   r   s   &r   
deactivate_PollableResource.deactivate   s	    r   r	   N)	__name__
__module____qualname____firstlineno__r
   r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s     F r   r   c                   V   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
tV tR# )_PollingTimerc                R    Wn         . V n        R V n        \        V n        RV n        R # )NF)reactor
_resources
_pollTimerMAX_TIMEOUT_currentTimeout_paused)r   r    s   &&r   __init___PollingTimer.__init__    s$    *r   c                \    V P                   P                  V4       V P                  4        R # N)r!   append_checkPollingState)r   ress   &&r   _addPollableResource"_PollingTimer._addPollableResource'   s     s#!r   c                    V P                    F(  pVP                  '       g   K  V P                  4         R # 	  V P                  4        R # r)   )r!   r
   _startPolling_stopPolling)r   resources   & r   r+    _PollingTimer._checkPollingState+   s6    H""$ (
 r   c                P    V P                   f   V P                  4       V n         R # R # r)   )r"   _rescheduler   s   &r   r0   _PollingTimer._startPolling3   s!    ??""..0DO #r   c                h    V P                   e$   V P                   P                  4        R V n         R # R # r)   )r"   cancelr   s   &r   r1   _PollingTimer._stopPolling7   s(    ??&OO""$"DO 'r   c                    R V n         R# r   )r%   r   s   &r   _pause_PollingTimer._pause<   s	    r   c                4    R V n         V P                  4        R# r   )r%   r+   r   s   &r   _unpause_PollingTimer._unpause?   s    !r   c                    V P                   '       g1   V P                  P                  V P                  V P                  4      # R # r)   )r%   r    	callLaterr$   
_pollEventr   s   &r   r5   _PollingTimer._rescheduleC   s1    |||<<))$*>*>PP r   c                   R p. pV P                    FR  pVP                  '       g   K  WP                  4       ,          pVP                  '       g   KA  VP                  V4       KT  	  V P                  pV'       d-   V P                  VR,           ,          pV\
        8  d   \
        pM$V P                  R,          pV\        8  d   \        pW@n        V'       d   V P                  4       V n        R# R# )g        g      ?g       @N)	r!   r
   	checkWorkr*   r$   MIN_TIMEOUTr#   r5   r"   )r   	workUnits	anyActiver2   
newTimeouts   &    r   rB   _PollingTimer._pollEventG   s    		H//11	???$$X. ( ))
--SAJK'(
--3JK'(
)"..0DO r   )r$   r%   r"   r!   r    N)r   r   r   r   r&   r-   r+   r0   r1   r;   r>   r5   rB   r   r   r   s   @r   r   r      s8     " 1#
"Q1 1r   r   Nc                   J   a  ] tR t^ht o R tR tR tR tR tR t	R t
RtV tR	# )
_PollableReadPipec                *    Wn         W n        W0n        R # r)   )pipereceivedCallbacklostCallback)r   rN   rO   rP   s   &&&&r   r&   _PollableReadPipe.__init__j   s    	 0(r   c                   ^ p. p  \         P                  ! V P                  ^4      w  r4pV'       g   M7\        P                  ! V P                  VR4      w  rgVP                  V4       Kf  RP                  V4      pV'       d   V P                  V4       V'       d   V P                  4        \        V4      #   \        P                   d    ^p Kg  i ; i)    Nr   )	win32pipePeekNamedPiperN   	win32fileReadFiler*   win32apierrorjoinrO   cleanuplen)	r   finishedfullDataReadbufferbytesToReadresulthrdatadataBufs	   &        r   rE   _PollableReadPipe.checkWorkp   s    	.7.E.EdiiQR.S+V"$--diidK##D)
 ((<(!!'*LLN7| >> s   ,B8 5B8 8CCc                F    V P                  4        V P                  4        R # r)   )r   rP   r   s   &r   r[   _PollableReadPipe.cleanup   s    r   c                     \         P                  ! V P                  4       R #   \        P                   d     R # i ; ir)   )rX   CloseHandlerN   
pywintypesrY   r   s   &r   close_PollableReadPipe.close   s1    	  + 		s    $ ==c                &    V P                  4        R # r)   )rk   r   s   &r   stopProducing_PollableReadPipe.stopProducing   s    

r   c                &    V P                  4        R # r)   )r   r   s   &r   pauseProducing _PollableReadPipe.pauseProducing   s    r   c                &    V P                  4        R # r)   )r   r   s   &r   resumeProducing!_PollableReadPipe.resumeProducing   s    r   )rP   rN   rO   N)r   r   r   r   r&   rE   r[   rk   rn   rq   rt   r   r   r   s   @r   rL   rL   h   s-     ). r   rL   c                   \   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
 tRtV tR# )_PollableWritePipec                    R V n         RV n        R V n        ^ V n        . V n        Wn        W n         \        P                  ! V\        P                  RR4       R#   \        P                   d     R# i ; ir   )disconnectingproducerproducerPausedstreamingProduceroutQueue	writePiperP   rT   SetNamedPipeHandleStatePIPE_NOWAITrj   rY   )r   r~   rP   s   &&&r   r&   _PollableWritePipe.__init__   so    "#!""(	--900$  		s   'A A32A3c                    R V n         R# r   )ry   r   s   &r   rk   _PollableWritePipe.close   s
    !r   c                h    V P                   e$   RV n        V P                   P                  4        R # R # )NT)rz   r{   rq   r   s   &r   
bufferFull_PollableWritePipe.bufferFull   s)    ==$"&DMM((* %r   c                    V P                   eR   V P                  '       d   V P                  '       d.   RV P                   n        V P                   P                  4        R# R# )NFT)rz   r|   r{   rt   r   s   &r   bufferEmpty_PollableWritePipe.bufferEmpty   sE    ==$'''D,?,?,?+0DMM(MM))+r   c                    V P                   e   \        RV: RV P                   : R24      hV P                  '       g   VP                  4        R# Wn         W n        V'       g   VP                  4        R# R# )aG  Register to receive data from a producer.

This sets this selectable to be a consumer for a producer.  When this
selectable runs out of data on a write() call, it will ask the producer
to resumeProducing(). A producer should implement the IProducer
interface.

FileDescriptor provides some infrastructure for producer methods.
NzCannot register producer z, because producer z was never unregistered.)rz   RuntimeErrorr
   rn   r|   rt   )r   rz   	streamings   &&&r   registerProducer#_PollableWritePipe.registerProducer   s_     ==$#+T]]<  {{{""$$M%."((* r   c                    RV n         R# )z;Stop consuming data from a producer, without disconnecting.N)rz   r   s   &r   unregisterProducer%_PollableWritePipe.unregisterProducer   s	    r   c                    V P                  4         \        P                  ! V P                  4       V P                  4        R #   \        P
                   d     L)i ; ir)   )r   rX   ri   r~   rj   rY   rP   r   s   &r   writeConnectionLost&_PollableWritePipe.writeConnectionLost   sK    	  0 	  		s    A AAc                    \         \        \        V4      9   d   \        R4      hV P                  P                  V4       R# )z
Append a C{list} or C{tuple} of bytes to the output buffer.

@param seq: C{list} or C{tuple} of C{str} instances to be appended to
    the output buffer.

@raise TypeError: If C{seq} contains C{unicode}.
%Unicode not allowed in output buffer.N)strmaptype	TypeErrorr}   extend)r   seqs   &&r   writeSequence _PollableWritePipe.writeSequence   s0     #dC. CDDS!r   c                "   \        V\        4      '       d   \        R4      hV P                  '       d   R# V P                  P                  V4       \        \        \        V P                  4      4      \        8  d   V P                  4        R# R# )z
Append some bytes to the output buffer.

@param data: C{str} to be appended to the output buffer.
@type data: C{str}.

@raise TypeError: If C{data} is C{unicode} instead of C{str}.
r   N)
isinstancer   r   ry   r}   r*   sumr   r\   FULL_BUFFER_SIZEr   )r   rc   s   &&r   write_PollableWritePipe.write   sf     dC  CDDT"s3&'*::OO ;r   c                    ^ pV P                   '       gH   V P                  '       d   V P                  4        ^ #  \        P                  ! V P
                  RR4       V P                   '       d~   V P                   P                  ^ 4      p^ p \        P                  ! V P
                  VR4      w  r4W,          p\        V4      V8  d"   V P                   P                  ^ W$R 4        V# K  V P                  4       pV'       g#   V P                  '       d   V P                  4        V#   \        P                   d    T P                  4        Tu # i ; i  \        P                   d    T P                  4         T# i ; i)rS   r   N)r}   ry   r   rV   	WriteFiler~   rj   rY   popr\   insertrX   r   )r   numBytesWrittenrc   errCodenBytesWrittenresumeds   &     r   rE   _PollableWritePipe.checkWork  sN   }}}!!!((*'##DNNC> mmm==$$Q'DG
)2)<)<T^^TSW)X&  0t9},MM((D,@A
  - &&(Gt111((*+ ## '((*&&' >> ((* s#   "D' $E ''EE%E=<E=)ry   rP   r}   rz   r{   r|   r~   N)r   r   r   r   r&   rk   r   r   r   r   r   r   r   rE   r   r   r   s   @r   rw   rw      s<      "+
+."" r   rw   i   )__doc__zope.interfacer   twisted.internet.interfacesr   r   rF   r#   r   r   rj   rX   rV   rT   rL   r   rw    r   r   <module>r      s   
 ' @ ?1 ?1J     ]0) 0 0f   YC* C Cr   