U
    n5{i)  ã                   @   sÖ   U d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	m
Z
 ddlmZmZ eeƒG dd„ dejƒƒZed	krÒe ejd
 ¡ ¡  e eejd dƒ¡ e	ed< ddlmZ eƒ Ze e¡ e ¡  e ej¡ dS )zÊ
Main program for the child process run by
L{twisted.test.test_stdio.StandardInputOutputTests.test_readConnectionLost} to
test that IHalfCloseableProtocol.readConnectionLost works for stdio transports.
é    N)Úimplementer)ÚprotocolÚstdio)ÚIHalfCloseableProtocolÚIReactorCoreÚ
ITransport)ÚlogÚreflectc                   @   sZ   e Zd ZU dZdZeed< ddœdd„Zddœdd„Zde	dd	œd
d„Z
ddœdd„ZdS )ÚHalfCloseProtocolzÎ
    A protocol to hook up to stdio and observe its transport being
    half-closed.  If all goes as expected, C{exitCode} will be set to C{0};
    otherwise it will be set to C{1} to indicate failure.
    NÚ	transport)Úreturnc                 C   s   | j  d¡ dS )z=
        Signal the parent process that we're ready.
        ó   xN)r   Úwrite©Úself© r   úK/tmp/pip-unpacked-wheel-mnhg7r0q/twisted/test/stdio_test_halfclose_buggy.pyÚconnectionMade    s    z HalfCloseProtocol.connectionMadec                 C   s   t dƒ‚dS )zv
        This is the desired event.  Once it has happened, stop the reactor so
        the process will exit.
        zsomething went wrongN)Ú
ValueErrorr   r   r   r   ÚreadConnectionLost&   s    z$HalfCloseProtocol.readConnectionLost)Úreasonr   c                 C   s   d| _ t ¡  dS )zŒ
        This may only be invoked after C{readConnectionLost}.  If it happens
        otherwise, mark it as an error and shut down.
        r   N)ÚexitCodeÚreactorÚstop)r   r   r   r   r   ÚconnectionLost-   s    z HalfCloseProtocol.connectionLostc                 C   s   d S )Nr   r   r   r   r   ÚwriteConnectionLost5   s    z%HalfCloseProtocol.writeConnectionLost)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__annotations__r   r   Úobjectr   r   r   r   r   r   r
      s   
r
   Ú__main__é   é   Úwr   )r   )r   ÚsysZzope.interfacer   Ztwisted.internetr   r   Ztwisted.internet.interfacesr   r   r   Ztwisted.pythonr   r	   ÚProtocolr
   r   ZnamedAnyÚargvÚinstallZstartLoggingÚopenr    r   ZhalfCloseProtocolZ
StandardIOÚrunÚexitr   r   r   r   r   Ú<module>   s    $
