<s> from twisted . internet import protocol <EOL> from twisted . internet import reactor <EOL> import re <EOL> class MyPP ( protocol . ProcessProtocol ) : <EOL> def __init__ ( self , verses ) : <EOL> self . verses = verses <EOL> self . data = "<STR_LIT>" <EOL> def connectionMade ( self ) : <EOL> print "<STR_LIT>" <EOL> for i in range ( self . verses ) : <EOL> self . transport . write ( "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> self . transport . closeStdin ( ) <EOL> def outReceived ( self , data ) : <EOL> print "<STR_LIT>" % len ( data ) <EOL> self . data = self . data + data <EOL> def errReceived ( self , data ) : <EOL> print "<STR_LIT>" % len ( data ) <EOL> def inConnectionLost ( self ) : <EOL> print "<STR_LIT>" <EOL> def outConnectionLost ( self ) : <EOL> print "<STR_LIT>" <EOL> ( dummy , lines , words , chars , file ) = re . split ( r'<STR_LIT>' , self . data ) <EOL> print "<STR_LIT>" % lines <EOL> def errConnectionLost ( self ) : <EOL> print "<STR_LIT>" <EOL> def processExited ( self , reason ) : <EOL> print "<STR_LIT>" % ( reason . value . exitCode , ) <EOL> def processEnded ( self , reason ) : <EOL> print "<STR_LIT>" % ( reason . value . exitCode , ) <EOL> print "<STR_LIT>" <EOL> reactor . stop ( ) <EOL> pp = MyPP ( <NUM_LIT:10> ) <EOL> reactor . spawnProcess ( pp , "<STR_LIT>" , [ "<STR_LIT>" ] , { } ) <EOL> reactor . run ( ) </s>
