A lot of answers say that I should put pool
under a with
statement, which I already have. I failed to find any related topics, let alone available solutions.
p.s.: I am spawning 100 processes (the n_games
in the code) on a 48-core CPU in Linux.
The code is basically
with mp.Pool(mp.cpu_count() - 1) as pool:
jobs = [pool.apply_async(
game.start_play,
(player1, player2, i % 2, 0)
) for i in range(n_games)]
for job in jobs:
win_cnt[job.get()] += 1
pool.close()
pool.join()