CasperSecurity

Current Path : /lib/python3/dist-packages/twisted/internet/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/twisted/internet/__pycache__/_pollingfile.cpython-310.pyc

o

�bW"�@s�dZddlmZddlmZmZdZdZGdd�d�ZGdd	�d	�Z	dd
l
Z
dd
lZdd
lZdd
l
Z
ee�Gdd�de��Zd
Zee�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.
�)�implementer)�	IConsumer�
IPushProducerg��&�.>g�������?c@s eZdZdZdd�Zdd�ZdS)�_PollableResourceTcC�
d|_dS�NT��active��self�r�?/usr/lib/python3/dist-packages/twisted/internet/_pollingfile.py�activate�
z_PollableResource.activatecCr�NFrr
rrr
�
deactivaterz_PollableResource.deactivateN)�__name__�
__module__�__qualname__r	rrrrrr
rsrc@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)rrrrr
�__init__ s

z_PollingTimer.__init__cCs|j�|�|��dS�N)r�append�_checkPollingState)r�resrrr
�_addPollableResource'sz"_PollingTimer._addPollableResourcecCs,|jD]}|jr|��dSq|��dSr)rr	�
_startPolling�_stopPolling)r�resourcerrr
r+s
�z _PollingTimer._checkPollingStatecCs|jdur|��|_dSdSr)r�_rescheduler
rrr
r"3s
�z_PollingTimer._startPollingcCs"|jdur|j��d|_dSdSr)r�cancelr
rrr
r#7s


�z_PollingTimer._stopPollingcCrr)rr
rrr
�_pause<rz_PollingTimer._pausecCsd|_|��dSr)rrr
rrr
�_unpause?sz_PollingTimer._unpausecCs|js|j�|j|j�SdSr)rr�	callLaterr�
_pollEventr
rrr
r%Cs�z_PollingTimer._reschedulecCs�d}g}|jD]}|jr||��7}|jr|�|�q|j}|r.|j|d}|tkr-t}n|jd}|tkr9t}||_|rE|��|_dSdS)Ngg�?g@)	rr	�	checkWorkrr�MIN_TIMEOUTrr%r)r�	workUnits�	anyActiver$�
newTimeoutrrr
r*Gs*

��
�z_PollingTimer._pollEventN)rrrrr!rr"r#r'r(r%r*rrrr
rsrNc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�_PollableReadPipecCs||_||_||_dSr)�pipe�receivedCallback�lostCallback)rr1r2r3rrr
rjs
z_PollableReadPipe.__init__c	Cs�d}g}	zt�|jd�\}}}|sWnt�|j|d�\}}|�|�Wntjy0d}Ynwqd�|�}|r>|�	|�|rD|�
�t|�S)Nr��)�	win32pipe�
PeekNamedPiper1�	win32file�ReadFiler�win32api�error�joinr2�cleanup�len)	r�finished�fullDataRead�buffer�bytesToRead�result�hr�data�dataBufrrr
r+ps(��

z_PollableReadPipe.checkWorkcCs|��|��dSr)rr3r
rrr
r=�sz_PollableReadPipe.cleanupcCs*z	t�|j�WdStjyYdSwr)r:�CloseHandler1�
pywintypesr;r
rrr
�close�s
�z_PollableReadPipe.closecC�|��dSr)rIr
rrr
�
stopProducing��z_PollableReadPipe.stopProducingcCrJr)rr
rrr
�pauseProducing�rLz _PollableReadPipe.pauseProducingcCrJr)rr
rrr
�resumeProducing�rLz!_PollableReadPipe.resumeProducingN)
rrrrr+r=rIrKrMrNrrrr
r0hsr0ic@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�_PollableWritePipecCsZd|_d|_d|_d|_g|_||_||_zt�|tj	dd�WdSt
jy,YdSw)NFr)�
disconnecting�producer�producerPaused�streamingProducer�outQueue�	writePiper3r6�SetNamedPipeHandleState�PIPE_NOWAITrHr;)rrUr3rrr
r�s

��z_PollableWritePipe.__init__cCrr)rPr
rrr
rI�rz_PollableWritePipe.closecCs"|jdurd|_|j��dSdSr)rQrRrMr
rrr
�
bufferFull�s
�z_PollableWritePipe.bufferFullcCs0|jdur|jr|jrd|j_|j��dSdS)NFT)rQrSrRrNr
rrr
�bufferEmpty�s
��
z_PollableWritePipe.bufferEmptycCsN|jdurtd||jf��|js|��dS||_||_|s%|��dSdS)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.)rQ�RuntimeErrorr	rKrSrN)rrQ�	streamingrrr
�registerProducer�s

���z#_PollableWritePipe.registerProducercCs
d|_dS)z;Stop consuming data from a producer, without disconnecting.N)rQr
rrr
�unregisterProducer�s
z%_PollableWritePipe.unregisterProducercCs:|��zt�|j�Wn
tjyYnw|��dSr)rr:rGrUrHr;r3r
rrr
�writeConnectionLost�s�z&_PollableWritePipe.writeConnectionLostcCs&ttt|�vrtd��|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)�str�map�type�	TypeErrorrT�extend)r�seqrrr
�
writeSequence�s	z _PollableWritePipe.writeSequencecCsLt|t�r	td��|jrdS|j�|�ttt|j��t	kr$|�
�dSdS)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`rcrPrTr�sumrar>�FULL_BUFFER_SIZErX)rrErrr
�write�s
	�z_PollableWritePipe.writecCs�d}|js)|jr|��dSz
t�|jdd�Wntjy(|��|YSw|jrk|j�d�}d}zt�|j|d�\}}Wnt	jyO|��Y|Sw||7}t
|�|krh|j�d||d��	|S|js,|��}|sx|jrx|��|S)Nrr5)
rTrPr^r8�	WriteFilerUrHr;�popr:r>�insertrY)r�numBytesWrittenrE�errCode�
nBytesWritten�resumedrrr
r+s>���
z_PollableWritePipe.checkWorkN)
rrrrrIrXrYr\r]r^rfrjr+rrrr
rO�s	
rO)�__doc__�zope.interfacer�twisted.internet.interfacesrrr,rrrrHr:r8r6r0rirOrrrr
�<module>s 
E3
Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY