Here is the code I am trying to do. The output text file should contain 500 data. But it is always less than 500 (450 or 476 or 429 when I run). Any idea why this is happening and what should I do to get 500 data in output. It will be very helpful if I get output in order.
def foo(j): output=[j] f=open('output.txt','a') f.write(' ') np.savetxt(f,output) f.close() if __name__=='__main__': pool = Pool(processes=4) pool.map(foo,range(500))
Try creating chunks before hand. For example
def f_amp(inputs): chunks = [inputs for inputs in range(500)] pool = Pool(processes=4) result = pool.map(f, chunks)
Also you can refer here for solutions.
1.4m articles
1.4m replys
5 comments
57.0k users