HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/internet/__pycache__/_pollingfile.cpython-38.pyc
U


W[#�@s�dZddlmZmZddlmZddlmZmZddl	m
Z
dZdZGdd	�d	�Z
Gd
d�d�ZddlZddlZddlZddlZee�Gd
d�de
��ZdZee�Gdd�de
��ZdS)z�
Implements a simple polling interface for file descriptors that don't work with
select() - this is pretty much only useful on Windows.
�)�absolute_import�division)�implementer)�	IConsumer�
IPushProducer)�unicodeg��&�.>g�������?c@s eZdZdZdd�Zdd�ZdS)�_PollableResourceTcCs
d|_dS�NT��active��self�r�?/usr/lib/python3/dist-packages/twisted/internet/_pollingfile.py�activatesz_PollableResource.activatecCs
d|_dS�NFr
rrrr�
deactivatesz_PollableResource.deactivateN)�__name__�
__module__�__qualname__rrrrrrrrsrc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�
_PollingTimercCs"||_g|_d|_t|_d|_dSr)�reactor�
_resources�
_pollTimer�MAX_TIMEOUT�_currentTimeout�_paused)r
rrrr�__init__%s
z_PollingTimer.__init__cCs|j�|�|��dS�N)r�append�_checkPollingState)r
�resrrr�_addPollableResource,sz"_PollingTimer._addPollableResourcecCs*|jD]}|jr|��q&q|��dSr)rr�
_startPolling�_stopPolling)r
�resourcerrrr 0s

z _PollingTimer._checkPollingStatecCs|jdkr|��|_dSr)r�_reschedulerrrrr#8s
z_PollingTimer._startPollingcCs|jdk	r|j��d|_dSr)rZcancelrrrrr$<s

z_PollingTimer._stopPollingcCs
d|_dSr	)rrrrr�_pauseAsz_PollingTimer._pausecCsd|_|��dSr)rr rrrr�_unpauseDsz_PollingTimer._unpausecCs|js|j�|j|j�SdSr)rrZ	callLaterr�
_pollEventrrrrr&Hsz_PollingTimer._reschedulecCs�d}g}|jD]&}|jr||��7}|jr|�|�q|j}|r\|j|d}|tkrrt}n|jd}|tkrrt}||_|r�|��|_dS)Ngg�?g@)	rr�	checkWorkrr�MIN_TIMEOUTrr&r)r
Z	workUnitsZ	anyActiver%Z
newTimeoutrrrr)Ls$

z_PollingTimer._pollEventN)rrrrr"r r#r$r'r(r&r)rrrrr"srNc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_PollableReadPipecCs||_||_||_dSr)�pipe�receivedCallback�lostCallback)r
r-r.r/rrrrosz_PollableReadPipe.__init__c	Cs�d}g}z>t�|jd�\}}}|s&Wqht�|j|d�\}}|�|�Wqtjk
rdd}YqhYqXqd�|�}|r�|�	|�|r�|�
�t|�S)Nr��)�	win32pipeZ
PeekNamedPiper-�	win32fileZReadFiler�win32api�error�joinr.�cleanup�len)	r
ZfinishedZfullDataRead�bufferZbytesToRead�resultZhr�dataZdataBufrrrr*us"

z_PollableReadPipe.checkWorkcCs|��|��dSr)rr/rrrrr7�sz_PollableReadPipe.cleanupcCs,zt�|j�Wntjk
r&YnXdSr)r4�CloseHandler-�
pywintypesr5rrrr�close�sz_PollableReadPipe.closecCs|��dSr)r>rrrr�
stopProducing�sz_PollableReadPipe.stopProducingcCs|��dSr)rrrrr�pauseProducing�sz _PollableReadPipe.pauseProducingcCs|��dSr)rrrrr�resumeProducing�sz!_PollableReadPipe.resumeProducingN)
rrrrr*r7r>r?r@rArrrrr,lsr,ic@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�_PollableWritePipecCs\d|_d|_d|_d|_g|_||_||_zt�|tj	dd�Wnt
jk
rVYnXdS)NFr)�
disconnecting�producer�producerPaused�streamingProducer�outQueue�	writePiper/r2ZSetNamedPipeHandleStateZPIPE_NOWAITr=r5)r
rHr/rrrr�s�z_PollableWritePipe.__init__cCs
d|_dSr	)rCrrrrr>�sz_PollableWritePipe.closecCs|jdk	rd|_|j��dSr	)rDrEr@rrrr�
bufferFull�s
z_PollableWritePipe.bufferFullcCs0|jdk	r,|jr|jr,d|j_|j��dSdS)NFT)rDrFrErArrrr�bufferEmpty�s�
z_PollableWritePipe.bufferEmptycCsH|jdk	rtd||jf��|js,|��n||_||_|sD|��dS)awRegister 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.
        NzHCannot register producer %s, because producer %s was never unregistered.)rD�RuntimeErrorrr?rFrA)r
rDZ	streamingrrr�registerProducer�s

��
z#_PollableWritePipe.registerProducercCs
d|_dS)zDStop consuming data from a producer, without disconnecting.
        N)rDrrrr�unregisterProducer�sz%_PollableWritePipe.unregisterProducercCs<|��zt�|j�Wntjk
r.YnX|��dSr)rr4r<rHr=r5r/rrrr�writeConnectionLost�sz&_PollableWritePipe.writeConnectionLostcCs&ttt|�krtd��|j�|�dS)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)r�map�type�	TypeErrorrG�extend)r
�seqrrr�
writeSequence�s	z _PollableWritePipe.writeSequencecCsHt|t�rtd��|jrdS|j�|�ttt|j��t	krD|�
�dS)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}.
        rON)�
isinstancerrRrCrGr�sumrPr8�FULL_BUFFER_SIZErI)r
r;rrr�write�s	
z_PollableWritePipe.writecCs�d}|jsT|jr|��dSzt�|jdd�Wn"tjk
rR|��|YSX|jr�|j�d�}d}zt�|j|d�\}}Wn"t	jk
r�|��Yq�YqTX||7}t
|�|krT|j�d||d��q�qT|��}|s�|jr�|��|S)Nrr1)
rGrCrNr3Z	WriteFilerHr=r5�popr4r8�insertrJ)r
ZnumBytesWrittenr;ZerrCodeZ
nBytesWrittenZresumedrrrr*s:
�

z_PollableWritePipe.checkWorkN)
rrrrr>rIrJrLrMrNrUrYr*rrrrrB�s

rB)�__doc__Z
__future__rrZzope.interfacerZtwisted.internet.interfacesrrZtwisted.python.compatrr+rrrr2r3r4r=r,rXrBrrrr�<module>s"E4