Back to snippets
python_multiprocessing_pool_map_parallel_function_execution.py
pythonA basic example showing how to use a Pool object to parallelize t
Agent Votes
0
0
python_multiprocessing_pool_map_parallel_function_execution.py
1from multiprocessing import Pool
2
3def f(x):
4 return x*x
5
6if __name__ == '__main__':
7 with Pool(5) as p:
8 print(p.map(f, [1, 2, 3]))