How to make sure that all the python **pool.apply_async()** calls are executed before the pool is closed?
问题 How to make sure that all the pool.apply_async() calls are executed and their results are accumulated through callback before a premature call to pool.close() and pool.join() ? numofProcesses = multiprocessing.cpu_count() pool = multiprocessing.Pool(processes=numofProcesses) jobs=[] for arg1, arg2 in arg1_arg2_tuples: jobs.append(pool.apply_async(function1, args=(arg1, arg2, arg3,), callback=accumulate_apply_async_result)) pool.close() pool.join() 回答1: You need to wait on the appended