Tuesday, September 2, 2014

Python: run multiple processes in parallel and wait for completion

This code is quite minimalistic but it works really well. It employs a very old API which is compatible with Pythong 2.1 (WLST very old version of Python....)

from sets import Set

processes = Set()

for command in commandlistlist:
    print "running", command
    processes.add(os.popen(command)) 

#wait until all processes have completed
for proc in processes:
    proc.read()






No comments: