o
    ¯b�  ã                   @   sž   d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 dd„ Z
G dd	„ d	ejƒZed
krMe	 ejd ¡ ¡  ddlmZ e eejd ƒ¡ e ¡  dS dS )z«
Main program for the child process run by
L{twisted.test.test_stdio.StandardInputOutputTests.test_consumer} to test
that process transports implement IConsumer properly.
é    N)ÚprotocolÚstdio)Úbasic)ÚlogÚreflectc                 C   s   t  tj¡ t  | ¡ d S ©N)r   ÚstartLoggingÚsysÚstderrÚerr)r   © r   úB/usr/lib/python3/dist-packages/twisted/test/stdio_test_consumer.pyÚfailed   s   r   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚConsumerChildc                 C   s
   || _ d S r   )ÚjunkPath)Úselfr   r   r   r   Ú__init__   s   
zConsumerChild.__init__c                    s:   t  ¡  tˆ jdƒˆ j¡}| t¡ | ‡ fdd„¡ d S )NÚrbc                    s
   ˆ j  ¡ S r   )Ú	transportÚloseConnection)Úign©r   r   r   Ú<lambda>!   s   
 z.ConsumerChild.connectionMade.<locals>.<lambda>)	r   Ú
FileSenderÚbeginFileTransferÚopenr   r   Ú
addErrbackr   ÚaddCallback)r   Údr   r   r   ÚconnectionMade   s
   ÿ
zConsumerChild.connectionMadec                 C   s   t  ¡  d S r   )ÚreactorÚstop)r   Úreasonr   r   r   ÚconnectionLost#   s   zConsumerChild.connectionLostN)Ú__name__Ú
__module__Ú__qualname__r   r   r#   r   r   r   r   r      s    r   Ú__main__é   )r    é   )Ú__doc__r	   Útwisted.internetr   r   Útwisted.protocolsr   Útwisted.pythonr   r   r   ÚProtocolr   r$   ÚnamedAnyÚargvÚinstallr    Ú
StandardIOÚrunr   r   r   r   Ú<module>   s   û