2

I have looked at other posts but I still don't know how to set an object attribute inside a multiprocessing pool.

It works when I use threading but not with multiprocessing, and I don't know how to include the Manager object in my code. When I try I obtain the same result as if I did not use it.

       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

This is the function I pool with

pool.map(self.protein_object_creator_pooled, top_hpa_protein_dict_list)

Only works (adds the "protein_object_list" attribute to the tissue element when I use ThreadPool, not Pool).

  • Relevant [sharing-a-result-queue-among-several-processes](https://stackoverflow.com/questions/9908781/sharing-a-result-queue-among-several-processes) – stovfl Feb 12 '19 at 18:09
  • How do I implement Queue with map and object list creation? – Jesus Portillo Feb 12 '19 at 22:33
  • *"How do I implement ..."*: Your `top_hpa_protein_dict_list` becomes `(top_hpa_protein, ), , ...` and `self.protein_object_creator` becomes `self.protein_object_creator(protein, queue):`. Example: [multiprocessing-queue](https://stackoverflow.com/questions/26405221/iterable-multiprocessing-queue-not-exiting) – stovfl Feb 13 '19 at 08:10
  • Thank you @stovfl ! – Jesus Portillo Feb 13 '19 at 16:15

0 Answers0