Python 使用多进程映射和池时,如何在进程之间共享对象?
我看过其他文章,但仍然不知道如何在多处理池中设置对象属性 当我使用线程而不是多处理时,它可以工作,我不知道如何在代码中包含Manager对象。当我尝试时,我得到了与我没有使用它相同的结果Python 使用多进程映射和池时,如何在进程之间共享对象?,python,bioinformatics,Python,Bioinformatics,我看过其他文章,但仍然不知道如何在多处理池中设置对象属性 当我使用线程而不是多处理时,它可以工作,我不知道如何在代码中包含Manager对象。当我尝试时,我得到了与我没有使用它相同的结果 def protein_object_creator_pooled(protein_dict): tissue = protein_dict['tissue'] protein_object_list = [] for hpa_protein in
def protein_object_creator_pooled(protein_dict):
tissue = protein_dict['tissue']
protein_object_list = []
for hpa_protein in protein_dict['protein']:
protein_object_list.append(t.Tissue.protein_object_list_creator(hpa_protein))
tissue.protein_object_list = protein_object_list
这就是我使用的函数
pool.map(self.protein_object_creator_pooled, top_hpa_protein_dict_list)
仅起作用(当我使用ThreadPool而不是Pool时,将“蛋白质对象列表”属性添加到组织元素)。相关我如何使用映射和对象列表创建来实现队列?“我如何实现…”:您的
top_hpa_蛋白质目录列表
变为(top_hpa_蛋白质,),…
和self.protein\u object\u creator
变成self.protein\u object\u creator(protein,queue):
。示例:谢谢@stovfl!