python parallel programming
hi i need some guidelines how to write programm that executes other python programm but in maximum for example 6 times at once and always try to be 6 process be running even if one ends up
also i would like to know what is happening to those processes right know but i dont want to wait to any process to finish
what is the pid of just created process? and its still running? or there has been an error? or it finish sucessfully?
some job manager ...
import subprocess
def start():
proc = {}
for i in range (0,6):
proc[i] = subprocess.Popen(
['python', 'someprogramm.py', '--env', 'DEVELOPMENT', '-l'],
shell = True,
stdout = subprocess.PIPE,
开发者_StackOverflow社区 stderr = subprocess.STDOUT
)
if __name__ == '__main__':
start()
Use celery.
Have a look at supervisord. It sounds like it will do what you want.
Maybe you can try with the multiprocessing module, it can handles pool of worker processes that seems similar to what you try to achieve.
You can use the poll()
method to check if a process is still running. You'd have to loop through each process and check if it runs, and otherwise, run a new process.
精彩评论