The program is below, I use the function imap_unorder in the package multiprocessing for python
from multiprocessing import Pool
def f(x):
return x,x*x
x_list = []
y_list = []
with Pool(processes=2) as pool:
for x,y in pool.imap_unordered(f, range(4)):
x_list.append(x)
y_list.append(y)
Is the x_list and y_list keeping consistent ?
i know that the funciton imap_unordered doesn't process the input iterator orderly. but when outputing x and y, can them appended to the list at the same time?
x_list = [0,3,1,2]
and y_list = [0,9,1,4]
is a right example
but i don't want to output such as x_list = [0,3,1,2]
and y_list = [0,1,9,4]
thanks a lot