%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/protocols/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/protocols/__pycache__/pcp.cpython-312.pyc

�

Ϫ�f���dZddlmZddlmZeej
ej�Gd�d��ZGd�de�Zy)	z
Producer-Consumer Proxy.
�)�implementer)�
interfacesc�h�eZdZdZdZdZdZdZdZdZ	dZ
d�Zd�Zd�Z
d�Zd	�Zd
�Zd�Zd�Zd
efd�Zy)�BasicProducerConsumerProxyaa
    I can act as a man in the middle between any Producer and Consumer.

    @ivar producer: the Producer I subscribe to.
    @type producer: L{IProducer<interfaces.IProducer>}
    @ivar consumer: the Consumer I publish to.
    @type consumer: L{IConsumer<interfaces.IConsumer>}
    @ivar paused: As a Producer, am I paused?
    @type paused: bool
    NTFc�^�g|_|�$||_|j||j�yy�N)�_buffer�consumer�registerProducer�iAmStreaming)�selfr
s  �7/usr/lib/python3/dist-packages/twisted/protocols/pcp.py�__init__z#BasicProducerConsumerProxy.__init__#s1�������$�D�M��%�%�d�D�,=�,=�>� �c�`�d|_|jr|jj�yy�NT)�paused�producer�pauseProducing�r
s rrz)BasicProducerConsumerProxy.pauseProducing+s%������=�=��M�M�(�(�*�rc�&�d|_|jrD|jjdj	|j��g|jddn|j
sd|_|j�|jj�yy)NF�T)	rr	r
�write�joinr�outstandingPullr�resumeProducingrs rrz*BasicProducerConsumerProxy.resumeProducing0sl������<�<��M�M��������� 5�6� �D�L�L��O��$�$�'+��$��=�=�$��M�M�)�)�+�%rc�n�|j�|jj�|j�|`yyr)r�
stopProducingr
rs rrz(BasicProducerConsumerProxy.stopProducing=s0���=�=�$��M�M�'�'�)��=�=�$��
�%rc���|js|js(|js|jj	|�y|j
�#|j
j
|�d|_yy�NF)rrrr	�appendr
r�r
�datas  rrz BasicProducerConsumerProxy.writeEsT���;�;�t�0�0��9M�9M��L�L����%�
�]�]�
&��M�M����%�#(�D� �'rc�p�|j�|jj�|j�yr)r
�finish�unregisterProducerrs rr%z!BasicProducerConsumerProxy.finishNs(���=�=�$��M�M� � �"����!rc� �||_||_yr)r�producerIsStreaming�r
r�	streamings   rrz+BasicProducerConsumerProxy.registerProducerSs�� ��
�#,�� rc�r�|j�|`|`|jr|jj�yyr)rr(r
r&rs rr&z-BasicProducerConsumerProxy.unregisterProducerWs3���=�=�$��
��(��=�=��M�M�,�,�.�r�returnc�V�d|j�dt|�d�d|j�d�S)N�<�@�xz around �>)�	__class__�idr
rs r�__repr__z#BasicProducerConsumerProxy.__repr__^s,���4�>�>�"�!�B�t�H�Q�<�x��
�
��a�H�Hr)�__name__�
__module__�__qualname__�__doc__r
rr(rrr�stoppedrrrrrr%rr&�strr4�rrrrsc��	��H��H����L��O�
�F��G�?�+�
,��)�"�
-�/�I�#�Irrc�@�eZdZdZdZdZdZd�Zd�Zd�Z	d�Z
d�Zd	�Zy
)�ProducerConsumerProxyz�ProducerConsumerProxy with a finite buffer.

    When my buffer fills up, I have my parent Producer pause until my buffer
    has room in it again.
    iFc��d|_yr)rrs rrz$ProducerConsumerProxy.pauseProducingos����rc���d|_|jrsdj|j�}|j|�}|t	|�kr)||d}|j
rJd��|g|jddng|jddnd}|jr4|r2|js&|j�|jj�|j
s||_	|j��td�|jD��}|jr1||jkr"d|_|jj�y|jr|jj�yyy)NFr�.Streaming producer did not write all its data.rc3�2K�|]}t|����y�wr��len��.0�ss  r�	<genexpr>z8ProducerConsumerProxy.resumeProducing.<locals>.<genexpr>������=�1��A��=���)rr	r�_writeSomeDatarCr�unregisteredr
r&rr�sum�producerPaused�
bufferSizer)r
r#�	bytesSent�unsent�
bytesBuffereds     rrz%ProducerConsumerProxy.resumeProducingts9������<�<��7�7�4�<�<�(�D��+�+�D�1�I��3�t�9�$��i�j�)���)�)�D�C�D�)�#)�(����Q��"$����Q���I�
�����L�L��
�
�)��M�M�,�,�.�� � �'0�=�D� ��=�=�$��=����=�=�M��"�"�
����(G�&+��#��
�
�-�-�/��%�%��
�
�-�-�/�&�%rc�>�|js|js(|js|jj	|�nv|j
�j|jrJd��|j
|�}d|_|t|�k(s1|jrJd��|jj	||d�|j�[|jrNtd�|jD��}||jk\r"|jj�d|_
yyyy)Nz9Writing fresh data to consumer before my buffer is empty!Fr@c3�2K�|]}t|����y�wrrBrDs  rrGz.ProducerConsumerProxy.write.<locals>.<genexpr>�rHrIT)rrrr	r!r
rJrCrr(rLrNrrM)r
r#rOrQs    rrzProducerConsumerProxy.write�s���;�;�t�0�0��9M�9M��L�L����%�
�]�]�
&��L�L�
K�J�
K� ��+�+�D�1�I�#(�D� ���D�	�)��)�)�D�C�D�)����#�#�D���$4�5��M�M�%�4�+C�+C��=����=�=�M�����/��
�
�,�,�.�&*��#�0�,D�%rc�f�d|_tj|||�|s|j�yyr )rKrrrr)s   rrz&ProducerConsumerProxy.registerProducer�s0��!���"�3�3�D�(�I�N���$�$�&�rc��|j�|`|`d|_|jr(|js|jj�yyyr)rr(rKr
r	r&rs rr&z(ProducerConsumerProxy.unregisterProducer�sC���=�=�$��
��(� ����=�=�����M�M�,�,�.�".�=rc�h�|j�y|jj|�t|�S)z`Write as much of this data as possible.

        @returns: The number of bytes written.
        r)r
rrCr"s  rrJz$ProducerConsumerProxy._writeSomeData�s-��
�=�=� ���
�
���D�!��4�y�rN)
r5r6r7r8rNrMrKrrrrr&rJr;rrr=r=bs7����J��N��L��
+0�Z+�8'�/�rr=N)	r8�zope.interfacer�twisted.internetr�	IProducer�	IConsumerrr=r;rr�<module>r[sT��
�'�'�
�Z�
!�
!�:�#7�#7�8�PI�PI�9�PI�fq�6�qr

Zerion Mini Shell 1.0