この質問は、私が尋ねた以前の質問に関連しており、単純な質問のように思えますが、マルチプロセッシングのトピックに関する有用な情報やチュートリアルを見つけるのに苦労しています。
私の問題は、生成されたデータを 1 つの大きな配列に結合し、それを hdf ファイルに保存したいということです。
def Simulation(i, output):
# make a simulation which outputs it resutlts in A. with shape 4000,3
A = np.array([4000,3])
output.put(A)
def handle_output(output):
hdf = pt.openFile('simulation.h5',mode='w')
hdf.createGroup('/','data')
# Here the output should be joined somehow.
# I would like to get it in the shape [4000,3,10]
output.get()
hdf.createArray('/data','array',A)
hdf.close()
if __name__ == '__main__':
output = mp.Queue()
jobs = []
proc = mp.Process(target=handle_output, args=(output, ))
proc.start()
for i in range(10):
p = mp.Process(target=Simulation, args=(i, output))
jobs.append(p)
p.start()
for p in jobs:
p.join()
output.put(None)
proc.join()