def follow_files(follow_paths, outstream, lastlines_dirpath=None, waitsecs=5):
 (procs, pipes) = launch_tails(follow_paths, lastlines_dirpath)
 while pipes:
  (lines, bad_pipes) = poll_tail_pipes(pipes, lastlines_dirpath, waitsecs)
  for bad in bad_pipes:
   pipes.pop(bad)
  try:
   outstream.writelines((['\n'] + lines))
   outstream.flush()
  except (IOError, OSError) as e:
   break
 snuff(procs.values())

def follow_files ( follow_paths , outstream , lastlines_dirpath = None , waitsecs = 5 ) : ( procs , pipes ) = launch_tails ( follow_paths , lastlines_dirpath ) while pipes : ( lines , bad_pipes ) = poll_tail_pipes ( pipes , lastlines_dirpath , waitsecs ) for bad in bad_pipes : pipes . pop ( bad ) try : outstream . writelines ( ( [ '\n' ] + lines ) ) outstream . flush ( ) except ( IOError , OSError ) as e : break snuff ( procs . values ( ) )
launch tail on a set of files and merge their output into outstream .