§
    Ètºfb  ã                   ó²   — U d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
  e
¦   «         Zg Zee         ed<    ee¦  «         G d„ d	¦  «        ¦   «         Zd
S )z%
Helpers for working with producers.
é    )ÚList)Úimplementer)ÚIPushProducer)Ú	cooperate)ÚLoggerÚ__all__c                   ó@   — e Zd ZdZdZd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
S )Ú_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.
    Fc                 ó"   — || _         || _        d S )N)Ú	_producerÚ	_consumer)ÚselfÚpullProducerÚconsumers      úa/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/_producer_helpers.pyÚ__init__z_PullToPush.__init__3   s   € Ø%ˆŒØ!ˆŒˆˆó    c              #   óˆ  K  — 	 t                                d| j        ¬¦  «        5 }| j                             ¦   «          ddd¦  «         n# 1 swxY w Y   |j        rbt                                d| j        ¬¦  «        5 }| j                             ¦   «          ddd¦  «         n# 1 swxY w Y   |j        r	d| _        dS dV — ŒÀ)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.
        Tz+while calling resumeProducing on {producer})ÚproducerNz.while calling unregisterProducer on {consumer})r   )Ú_logÚfailuresHandledr   ÚresumeProducingÚfailedr   ÚunregisterProducerÚ	_finished)r   ÚopÚ
handlingops      r   Ú_pullz_PullToPush._pull7   sU  è è € ð	Ý×%Ò%Ø=ÈÌð &ñ ô ð 1àØ”×.Ò.Ñ0Ô0Ð0ð1ð 1ð 1ñ 1ô 1ð 1ð 1ð 1ð 1ð 1ð 1øøøð 1ð 1ð 1ð 1ð Œyð 
Ý×)Ò)ØDØ!œ^ð *ñ ô ð 8ð  Ø”N×5Ò5Ñ7Ô7Ð7ð	8ð 8ð 8ñ 8ô 8ð 8ð 8ð 8ð 8ð 8ð 8øøøð 8ð 8ð 8ð 8ð
 Ô$ð ð &*�D”NØ�FØˆJˆJˆJð!	s#   ¥AÁAÁAÁ>B$Â$B(Â+B(c                 óR   — t          |                      ¦   «         ¦  «        | _        dS )z‡
        This should be called by the consumer when the producer is registered.

        Start streaming data to the consumer.
        N)r   r   Ú	_coopTask©r   s    r   ÚstartStreamingz_PullToPush.startStreamingQ   s   € õ # 4§:¢:¡<¤<Ñ0Ô0ˆŒˆˆr   c                 óX   — | j         rdS d| _         | j                             ¦   «          dS )z�
        This should be called by the consumer when the producer is
        unregistered.

        Stop streaming data to the consumer.
        NT)r   r    Ústopr!   s    r   ÚstopStreamingz_PullToPush.stopStreamingY   s4   € ð Œ>ð 	ØˆFØˆŒØŒ×ÒÑÔÐÐÐr   c                 ó8   — | j                              ¦   «          dS )z7
        @see: C{IPushProducer.pauseProducing}
        N)r    Úpauser!   s    r   ÚpauseProducingz_PullToPush.pauseProducinge   s   € ð 	Œ×ÒÑÔÐÐÐr   c                 ó8   — | j                              ¦   «          dS )z8
        @see: C{IPushProducer.resumeProducing}
        N)r    Úresumer!   s    r   r   z_PullToPush.resumeProducingk   s   € ð 	Œ×ÒÑÔÐÐÐr   c                 ó`   — |                       ¦   «          | j                             ¦   «          dS )z6
        @see: C{IPushProducer.stopProducing}
        N)r%   r   ÚstopProducingr!   s    r   r,   z_PullToPush.stopProducingq   s0   € ð 	×ÒÑÔÐØŒ×$Ò$Ñ&Ô&Ð&Ð&Ð&r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r"   r%   r(   r   r,   © r   r   r
   r
      sŽ   € € € € € ðð ð0 €Ið"ð "ð "ðð ð ð41ð 1ð 1ð
ð 
ð 
ðð ð ð ð  ð  ð'ð 'ð 'ð 'ð 'r   r
   N)r0   Útypingr   Úzope.interfacer   Útwisted.internet.interfacesr   Útwisted.internet.taskr   Útwisted.loggerr   r   r   ÚstrÚ__annotations__r
   r1   r   r   ú<module>r9      sä   ðð
ð ð ð Ð Ð Ð Ð Ð à &Ð &Ð &Ð &Ð &Ð &à 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø +Ð +Ð +Ð +Ð +Ð +Ø !Ð !Ð !Ð !Ð !Ð !à€v�x„x€ð €ˆˆcŒÐ Ð Ñ ð €ˆ]ÑÔð^'ð ^'ð ^'ð ^'ð ^'ñ ^'ô ^'ñ Ôð^'ð ^'ð ^'r   