#NEWLINE# def __init__( self , command , input_pipe = None ) : #NEWLINE# #INDENT# '\n        Initializes a InputPipeProcessWrapper instance.\n\n        :param command: a subprocess.Popen instance with stdin=input_pipe and\n                        stdout=subprocess.PIPE.\n                        Alternatively, just its args argument as a convenience.\n        ' #NEWLINE# self . _command = command #NEWLINE# self . _input_pipe = input_pipe #NEWLINE# self . _original_input = True #NEWLINE# if ( input_pipe is not None ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# input_pipe . fileno ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# self . _original_input = False #NEWLINE# f = tempfile . NamedTemporaryFile ( 'wb' , prefix = 'luigi-process_tmp' , delete = False ) #NEWLINE# self . _tmp_file = f . name #NEWLINE# while True : #NEWLINE# #INDENT# chunk = input_pipe . read ( io . DEFAULT_BUFFER_SIZE ) #NEWLINE# if ( not chunk ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# f . write ( chunk ) #NEWLINE# #UNINDENT# input_pipe . close ( ) #NEWLINE# f . close ( ) #NEWLINE# self . _input_pipe = FileWrapper ( io . BufferedReader ( io . FileIO ( self . _tmp_file , 'r' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# self . _process = ( chunk if isinstance ( command , subprocess . Popen ) else self . create_subprocess ( command ) ) #NEWLINE# self . _process . _selfref = self