Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. def create_list_of_attribute_dicts():
  2. ...
  3. return list_of_dicts
  4.  
  5. for each_dict in list_of_dicts:
  6. instance = SC(each_dict)
  7. p = mp.Process(target=instance.queen_bee(),args=(each_dict,))
  8. p.start()
  9. ...
  10.  
  11. ...
  12. pool = mp.Pool()
  13. jobs = pool.map(SC.queen_bee(),list_of_dicts)
  14.  
  15. from multiprocessing import Pool as ThreadPool
  16.  
  17. # ...
  18.  
  19. def parallel_function(list_of_dictionaries,threads=20):
  20. thread_pool = ThreadPool(threads)
  21. results = thread_pool.map(SC.queen_bee() ,list_of_dictionaries)
  22. thread_pool.close()
  23. thread_pool.join()
  24. return results
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement