U
    
W[ã  ã                   @   sŽ   d Z ddlmZm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rŠe
 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.
é    )Úabsolute_importÚdivisionN)ÚstdioÚprotocol)Ú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   úB/usr/lib/python3/dist-packages/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   1   s    zProducerChild.unpauseN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r   r   r   r   r      s   r   Ú__main__r
   )r   )Ú__doc__Z
__future__r   r   r   Ztwisted.internetr   r   Ztwisted.pythonr   r   ZProtocolr   r    ZnamedAnyÚargvÚinstallr   Z
StandardIOÚrunr   r   r   r   Ú<module>   s   #