Apr-05-2019, 04:27 PM
Trying to run twice pool map cycle.
from multiprocessing import Pool
b=["0","0","0","0","0","0"]
def f(c):
b[5]=c
return b
for i1 in range(1,3):
if __name__ == '__main__':
p = Pool(1)
print(p.map(f, ["f", "n","x"]))
b[2]="3"The program displays the following response:Output:[['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']]
[['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']]And I need it to be:Output:[['0', '0', '0', '0', '0', 'f'], ['0', '0', '0', '0', '0', 'n'], ['0', '0', '0', '0', '0', 'x']]
[['0', '0', '3', '0', '0', 'f'], ['0', '0', '3', '0', '0', 'n'], ['0', '0', '3', '0', '0', 'x']]Why does the first line print 3 ?
