def output_thread(log, stdout, stderr, timeout_event, is_alive, quit, stop_output_event):
 readers = []
 errors = []
 if (stdout is not None):
  readers.append(stdout)
  errors.append(stdout)
 if (stderr is not None):
  readers.append(stderr)
  errors.append(stderr)
 while readers:
  (outputs, inputs, err) = no_interrupt(select.select, readers, [], errors, 1)
  for stream in outputs:
   log.debug('%r ready to be read from', stream)
   done = stream.read()
   if done:
    readers.remove(stream)
  for stream in err:
   pass
  if (timeout_event and timeout_event.is_set()):
   break
  if stop_output_event.is_set():
   break
 alive = True
 while alive:
  quit.wait(1)
  (alive, _) = is_alive()
 if stdout:
  stdout.close()
 if stderr:
  stderr.close()

def output_thread ( log , stdout , stderr , timeout_event , is_alive , quit , stop_output_event ) : readers = [ ] errors = [ ] if ( stdout is not None ) : readers . append ( stdout ) errors . append ( stdout ) if ( stderr is not None ) : readers . append ( stderr ) errors . append ( stderr ) while readers : ( outputs , inputs , err ) = no_interrupt ( select . select , readers , [ ] , errors , 1 ) for stream in outputs : log . debug ( '%r ready to be read from' , stream ) done = stream . read ( ) if done : readers . remove ( stream ) for stream in err : pass if ( timeout_event and timeout_event . is_set ( ) ) : break if stop_output_event . is_set ( ) : break alive = True while alive : quit . wait ( 1 ) ( alive , _ ) = is_alive ( ) if stdout : stdout . close ( ) if stderr : stderr . close ( )
this function is run in a separate thread .