multiprocessing

2018-12-07  本文已影响0人  木一乎
def task(pid):
    # do something
    return result

def main():
    multiprocessing.freeze_support()
    pool = multiprocessing.Pool()
    ntasks = 200;
    results = []
    for i in xrange(0, ntasks):
        result = pool.apply_async(task, args=(i,))
        results.append(result)
    pool.close()
    pool.join()

for result in results:
    print(result.get())
上一篇下一篇

猜你喜欢

热点阅读