
    Vh{                        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ej                               Zed	k(  r ej"                  ej$                  d
         j'                           ej(                   eej$                  d   d             e	ed<   ddlmZ  e       Z ej2                  e        ej4                           ej6                  ej8                         yy)z
Main program for the child process run by
L{twisted.test.test_stdio.StandardInputOutputTests.test_buggyWriteConnectionLost}
to test that IHalfCloseableProtocol.writeConnectionLost works for stdio
transports.
    N)implementer)protocolstdio)IHalfCloseableProtocolIReactorCore
ITransport)logreflectc                   N    e Zd ZU dZdZdZeed<   ddZddZ	dd	e
ddfd
ZddZy)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.
    	   F	transportreturnNc                 :    | j                   j                  d       y)z=
        Signal the parent process that we're ready.
           xN)r   writeselfs    ]/home/dcms/DCMS/lib/python3.12/site-packages/twisted/test/stdio_test_halfclose_buggy_write.pyconnectionMadez HalfCloseProtocol.connectionMade"   s     	T"    c                      y)zv
        This is the desired event.  Once it has happened, stop the reactor so
        the process will exit.
        N r   s    r   readConnectionLostz$HalfCloseProtocol.readConnectionLost(   s    r   reasonc                 R    | j                   rd| _        t        j                          y)z
        This may only be invoked after C{readConnectionLost}.  If it happens
        otherwise, mark it as an error and shut down.
        r   N)wasWriteConnectionLostexitCodereactorstop)r   r   s     r   connectionLostz HalfCloseProtocol.connectionLost.   s    
 &&DMr   c                 &    d| _         t        d      )NTzsomething went wrong)r   
ValueErrorr   s    r   writeConnectionLostz%HalfCloseProtocol.writeConnectionLost7   s    &*#/00r   )r   N)N)__name__
__module____qualname____doc__r   r   r   __annotations__r   r   objectr!   r$   r   r   r   r   r      s<     H"#V t 1r   r   __main__      wr   )r   )r(   syszope.interfacer   twisted.internetr   r   twisted.internet.interfacesr   r   r   twisted.pythonr	   r
   Protocolr   r%   namedAnyargvinstallstartLoggingopenr)   r   halfCloseProtocol
StandardIOrunexitr   r   r   r   <module>r>      s   
  & , X X ' #$"1)) "1 %"1J zGSXXa[!))+CT#((1+s+,()+E&'GKKMCHH''( r   