多处理/进程 - 如何管理 queue/manager?
Multiprocessing / Process - How to manage the queue/manager?
目前我执行的作业,然后会同时启动3个进程
def someFunctionJob(x,y,**kwargs):
..... Code which will do some job
def manager(x,values):
y = uuid.uuid4().hex
pr = Process(target=someFunctionJob,args=(x,y,),kwargs=values)
pr.start()
def main(x,values,settings):
for i in settings:
if xyz in ["abc"]:
manager(x,values)
elif lender in ["abc1"]:
manager(lender,product)
elif lender in ["abc2"]:
manager(x,values)
我需要的是会被queue管理:
如果 workers = 2
执行会是这样:
process 1
process 2
waiting till any of the processes will be finished
process 3
processes=[]
for _ in range(2):
p = Process(target=something )
p.start()
processes.append(p)
for process in processes:
process.join()
p = Process(target=something )
p.start()
这段代码的作用是执行上面的 2 个进程,然后等待它们完成,然后 运行 另一个单独的进程。
目前我执行的作业,然后会同时启动3个进程
def someFunctionJob(x,y,**kwargs):
..... Code which will do some job
def manager(x,values):
y = uuid.uuid4().hex
pr = Process(target=someFunctionJob,args=(x,y,),kwargs=values)
pr.start()
def main(x,values,settings):
for i in settings:
if xyz in ["abc"]:
manager(x,values)
elif lender in ["abc1"]:
manager(lender,product)
elif lender in ["abc2"]:
manager(x,values)
我需要的是会被queue管理:
如果 workers = 2
执行会是这样:
process 1
process 2
waiting till any of the processes will be finished
process 3
processes=[]
for _ in range(2):
p = Process(target=something )
p.start()
processes.append(p)
for process in processes:
process.join()
p = Process(target=something )
p.start()
这段代码的作用是执行上面的 2 个进程,然后等待它们完成,然后 运行 另一个单独的进程。