📜  jupyter notebook 中的多处理 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.563000             🧑  作者: Mango

代码示例1
import multiprocessing

def double(a):
    return a * 2

def driver_func():
    PROCESSES = 4
    with multiprocessing.Pool(PROCESSES) as pool:
        params = [(1, ), (2, ), (3, ), (4, )]
        results = [pool.apply_async(double, p) for p in params]

        for r in results:
            print('\t', r.get())