def run_tpaa(n, body):
"""ThreadPool.apply_async"""
from multiprocessing.pool import ThreadPool
global reused_pool, numthreads
if 'reused_pool' not in globals():
log.debug("Creating ThreadPool(%s) for apply_async()" % numthreads)
reused_pool = ThreadPool(int(numthreads))
reused_pool.map(body, range(n))
wait_list = []
for i in n:
b = tbb_job(i, body)
a = reused_pool.apply_async(b)
wait_list.append(a)
for a in wait_list:
a.wait()
评论列表
文章目录