#NEWLINE# def run( self , data , timeout , kill_timeout , env , cwd ) : #NEWLINE# #INDENT# self . data = data #NEWLINE# environ = dict ( os . environ ) #NEWLINE# environ . update ( ( env or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# def target( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . process = subprocess . Popen ( self . cmd , universal_newlines = True , shell = False , env = environ , stdin = subprocess . PIPE , stdout = subprocess . PIPE , stderr = subprocess . PIPE , bufsize = 0 , cwd = cwd ) #NEWLINE# if ( sys . version_info [ 0 ] >= 3 ) : #NEWLINE# #INDENT# ( self . out , self . err ) = self . process . communicate ( input = ( bytes ( self . data , 'UTF-8' ) if self . data else None ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( self . out , self . err ) = self . process . communicate ( self . data ) #NEWLINE# #UNINDENT# #UNINDENT# except Exception as exc : #NEWLINE# #INDENT# self . exc = exc #NEWLINE# #UNINDENT# #UNINDENT# thread = threading . Thread ( target = target ) #NEWLINE# thread . start ( ) #NEWLINE# thread . join ( timeout ) #NEWLINE# if kill_timeout . exc : #NEWLINE# #INDENT# raise self . exc #NEWLINE# #UNINDENT# if _is_alive ( thread ) : #NEWLINE# #INDENT# _terminate_process ( self . process ) #NEWLINE# thread . join ( kill_timeout ) #NEWLINE# if _is_alive ( thread ) : #NEWLINE# #INDENT# _kill_process ( self . process ) #NEWLINE# thread . join ( ) #NEWLINE# #UNINDENT# #UNINDENT# self . returncode = self . process . returncode #NEWLINE# return ( self . out , self . err )