Guest User

Untitled

a guest
Jul 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import multiprocessing
  2. from itertools import repeat
  3. import ctypes
  4.  
  5. list_1 = ["bob", "joe", "fred"]
  6. list_index = [0, 1, 2]
  7.  
  8. def function_1(index_num, name, shared_array):
  9. shared_array[index_num] = name
  10.  
  11. if __name__ == "__main__":
  12. pool = multiprocessing.Pool(processes = 3)
  13. shared_arr = multiprocessing.Array(ctypes.c_wchar_p, ["", "", ""])
  14. pool.starmap(function_1, zip(list_index, list_1, repeat(shared_arr, 3)))
  15. pool.close()
  16. pool.join()
  17.  
  18. import multiprocessing
  19. from itertools import repeat
  20. import ctypes
  21.  
  22. list_1 = ["bob", "joe", "fred"]
  23. list_index = [0, 1, 2]
  24. shared_arr = multiprocessing.Array(ctypes.c_wchar_p, ["", "", ""])
  25.  
  26. def function_1(index_num, name):
  27. shared_arr[index_num] = name
  28.  
  29. if __name__ == "__main__":
  30. pool = multiprocessing.Pool(processes = 3)
  31. pool.starmap(function_1, zip(list_index, list_1))
  32. pool.close()
  33. pool.join()
  34. print(shared_arr[0])
Add Comment
Please, Sign In to add comment