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__/_producer_helpers.cpython-38.pyc
U

��W[��@spdZddlmZmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
gZee�Gdd	�d	e��Zd
S)z%
Helpers for working with producers.
�)�division�absolute_import)�implementer)�
IPushProducer)�	cooperate)�log)�safe_strc@sLeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�ZdS)�_PullToPusha�
    An adapter that converts a non-streaming to a streaming producer.

    Because of limitations of the producer API, this adapter requires the
    cooperation of the consumer. When the consumer's C{registerProducer} is
    called with a non-streaming producer, it must wrap it with L{_PullToPush}
    and then call C{startStreaming} on the resulting object. When the
    consumer's C{unregisterProducer} is called, it must call
    C{stopStreaming} on the L{_PullToPush} instance.

    If the underlying producer throws an exception from C{resumeProducing},
    the producer will be unregistered from the consumer.

    @ivar _producer: the underling non-streaming producer.

    @ivar _consumer: the consumer with which the underlying producer was
                     registered.

    @ivar _finished: C{bool} indicating whether the producer has finished.

    @ivar _coopTask: the result of calling L{cooperate}, the task driving the
                     streaming producer.
    FcCs||_||_dS)N)�	_producer�	_consumer)�selfZpullProducerZconsumer�r
�D/usr/lib/python3/dist-packages/twisted/internet/_producer_helpers.py�__init__3sz_PullToPush.__init__ccs~z|j��Wnbt�ddt|j�f�z|j��Wn.t�ddt|j�f�d|_YYdSXYnXdVqdS)z�
        A generator that calls C{resumeProducing} on the underlying producer
        forever.

        If C{resumeProducing} throws an exception, the producer is
        unregistered, which should result in streaming stopping.
        Nz%%s failed, producing will be stopped:z!%s failed to unregister producer:T)r
�resumeProducingr�errrrZunregisterProducer�	_finished�rr
r
r�_pull8s	
�
�z_PullToPush._pullcCst|���|_dS)z�
        This should be called by the consumer when the producer is registered.

        Start streaming data to the consumer.
        N)rr�	_coopTaskrr
r
r�startStreamingTsz_PullToPush.startStreamingcCs|jr
dSd|_|j��dS)z�
        This should be called by the consumer when the producer is
        unregistered.

        Stop streaming data to the consumer.
        NT)rr�stoprr
r
r�
stopStreaming]sz_PullToPush.stopStreamingcCs|j��dS)z7
        @see: C{IPushProducer.pauseProducing}
        N)r�pauserr
r
r�pauseProducingjsz_PullToPush.pauseProducingcCs|j��dS)z8
        @see: C{IPushProducer.resumeProducing}
        N)rZresumerr
r
rrqsz_PullToPush.resumeProducingcCs|��|j��dS)z6
        @see: C{IPushProducer.stopProducing}
        N)rr
�
stopProducingrr
r
rrxsz_PullToPush.stopProducingN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrr
r
r
rr	s	
r	N)rZ
__future__rrZzope.interfacerZtwisted.internet.interfacesrZtwisted.internet.taskrZtwisted.pythonrZtwisted.python.reflectr�__all__�objectr	r
r
r
r�<module>s