code: def pipe_wait(popens):
      
      # Avoid mutating the passed copy
      popens = copy.copy(popens)
      results = [0] * len(popens)
      while popens:
          last = popens.pop(-1)
          results[len(popens)] = last.wait()
      return results
docs: Given an array of Popen objects returned by the
      pipe method, wait for all processes to terminate
      and return the array with their return values.
  
      Taken from http://www.enricozini.org/2009/debian/python-pipes/