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/
(popens)
| 123 | |
| 124 | |
| 125 | def pipe_wait(popens): |
| 126 | """ |
| 127 | Given an array of Popen objects returned by the |
| 128 | pipe method, wait for all processes to terminate |
| 129 | and return the array with their return values. |
| 130 | |
| 131 | Taken from http://www.enricozini.org/2009/debian/python-pipes/ |
| 132 | |
| 133 | """ |
| 134 | # Avoid mutating the passed copy |
| 135 | popens = copy.copy(popens) |
| 136 | results = [0] * len(popens) |
| 137 | while popens: |
| 138 | last = popens.pop(-1) |
| 139 | results[len(popens)] = last.wait() |
| 140 | return results |