ó
[³XMc           @   s  d  Z  d d l Z d d l m Z d d l m Z d d l m Z m Z d d l	 m
 Z
 m Z d e j f d „  ƒ  YZ e d	 k rý e
 j e j d
 ƒ j ƒ  e j e e j d d ƒ ƒ d d l m Z e ƒ  Z e j e ƒ e j ƒ  e j e j ƒ n  d S(   sÏ   
Main program for the child process run by
L{twisted.test.test_stdio.StandardInputOutputTestCase.test_readConnectionLost}
to test that IHalfCloseableProtocol.readConnectionLost works for process
transports.
iÿÿÿÿN(   t
   implements(   t   IHalfCloseableProtocol(   t   stdiot   protocol(   t   reflectt   logt   HalfCloseProtocolc           B   s9   e  Z d  Z e e ƒ d Z d „  Z d „  Z d „  Z	 RS(   sÎ   
    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.
    c         C   s   |  j  j d ƒ d S(   s=   
        Signal the parent process that we're ready.
        t   xN(   t	   transportt   write(   t   self(    (    sE   /usr/lib/python2.7/dist-packages/twisted/test/stdio_test_halfclose.pyt   connectionMade   s    c         C   s   d |  _  t j ƒ  d S(   sv   
        This is the desired event.  Once it has happened, stop the reactor so
        the process will exit.
        i    N(   t   exitCodet   reactort   stop(   R
   (    (    sE   /usr/lib/python2.7/dist-packages/twisted/test/stdio_test_halfclose.pyt   readConnectionLost&   s    	c         C   s9   |  j  d k r+ d |  _  t j | d ƒ n  t j ƒ  d S(   sŒ   
        This may only be invoked after C{readConnectionLost}.  If it happens
        otherwise, mark it as an error and shut down.
        i   s!   Unexpected call to connectionLostN(   R   t   NoneR   t   errR   R   (   R
   t   reason(    (    sE   /usr/lib/python2.7/dist-packages/twisted/test/stdio_test_halfclose.pyt   connectionLost/   s    	N(
   t   __name__t
   __module__t   __doc__R    R   R   R   R   R   R   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/test/stdio_test_halfclose.pyR      s   
			t   __main__i   i   t   w(   R   (   R   t   syst   zope.interfaceR    t   twisted.internet.interfacesR   t   twisted.internetR   R   t   twisted.pythonR   R   t   ProtocolR   R   t   namedAnyt   argvt   installt   startLoggingt   fileR   t
   StandardIOt   runt   exitR   (    (    (    sE   /usr/lib/python2.7/dist-packages/twisted/test/stdio_test_halfclose.pyt   <module>
   s   &	
