There's no need to call close
and join
on the pool, since you're calling get
on all the individual AsyncResult
objects, which will block until the result is ready. So, you can just do:
V = {}
p = Pool(4)
for i in range(N):
V[i] = {}
results = []
for j in range(10):
if should_skip(i,j):
continue
results.append(p.apply_async(do_something, (V,)))
for result in results:
r = result.get() # This will block until `result` is available.
V[i][r[1]] = r[0]