U
    2ÜŸjÌ  ã                   @   s~   d Z ddlZddlmZmZ ddlmZmZ G dd„ dejƒZ	e
dkrze ejd ¡ ¡  dd	lmZ e e	ƒ ¡ e ¡  dS )
z«
Main program for the child process run by
L{twisted.test.test_stdio.StandardInputOutputTests.test_producer} to test
that process transports implement IProducer properly.
é    N)ÚprotocolÚstdio)ÚlogÚreflectc                   @   s4   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	d
„ ZdS )ÚProducerChildFó    c                 C   s   t  d¡ t dtj¡ d S )Nz*****OVER*****é   )r   ÚmsgÚreactorÚ	callLaterÚstop)ÚselfÚreason© r   úD/tmp/pip-unpacked-wheel-4b529toj/twisted/test/stdio_test_producer.pyÚconnectionLost   s    
zProducerChild.connectionLostc                 C   sf   |  j |7  _ | jr6t tj¡ t d¡ | j ¡  n,| j 	|¡ | j  
d¡rZ| j ¡  n|  ¡  d S )Nz$dataReceived while transport paused!s   
0
)ÚbufÚ_pausedr   ZstartLoggingÚsysÚstderrr	   Ú	transportZloseConnectionÚwriteÚendswithÚpause)r   Údatar   r   r   ÚdataReceived   s    
zProducerChild.dataReceivedc                 C   s"   d| _ | j ¡  t d| j¡ d S )NTg{®Gáz„?)r   r   ZpauseProducingr
   r   Úunpause©r   r   r   r   r   '   s    
zProducerChild.pausec                 C   s   d| _ | j ¡  d S )NF)r   r   ZresumeProducingr   r   r   r   r   ,   s    zProducerChild.unpauseN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r      s   r   Ú__main__r   )r
   )Ú__doc__r   Ztwisted.internetr   r   Ztwisted.pythonr   r   ÚProtocolr   r   ZnamedAnyÚargvÚinstallr
   Z
StandardIOÚrunr   r   r   r   Ú<module>   s   