fork download
  1. import multiprocessing as mp
  2.  
  3. if __name__ == '__main__':
  4.  
  5. def f(x):
  6. return x*x
  7.  
  8. num_workers = 2
  9. with mp.Pool(num_workers) as p:
  10. print(p.map(f, [1,2,3]))
  11.  
Success #stdin #stdout 0.07s 12832KB
stdin
Standard input is empty
stdout
[1, 4, 9]