1 def worker(procnum, return_dict): '''worker function''' print str(procnum) ' represent!' return_dict[procnum] = procnum
if name == 'main': manager = Manager() return_dict = manager.dict() jobs = [] for i in range(5): p = multiprocessing.Process(target=worker, args=(i,return_dict)) jobs.append(p) p.start()
代码语言:javascript复制for proc in jobs:
proc.join()
print return_dict.values()
2 p = multiprocessing.Pool(1) rslt = p.map(test,('world',)) print rslt