我想从一个函数中初始化并在另一个函数中启动的多个进程中获取返回值。
import multiprocessing
import time
class Auto:
def __init__(self):
self.msf = 0
def auto(self, return_dict, i):
# print "hello"
return_dict["hello"] = "hello{}".format(i)
def msf1(self):
man = multiprocessing.Manager()
self.return_dict = man.dict()
self.a= multiprocessing.Process(target=self.auto, args=(self.return_dict, 1, ))
self.b= multiprocessing.Process(target=self.auto, args=(self.return_dict, 1, ))
self.c= multiprocessing.Process(target=self.auto, args=(self.return_dict, 1, ))
def msf2(self):
self.a.start()
self.b.start()
self.c.start()
return self.return_dict.values()