index in the pool python

Solutions on MaxInterview for index in the pool python by the best coders in the world

showing results for - "index in the pool python"
Edoardo
13 Oct 2016
1import os
2from multiprocessing import current_process, Pool
3
4
5def x(a):
6    p = current_process()
7    print('process counter:', p._identity[0], 'pid:', os.getpid())
8
9
10if __name__ == '__main__':
11    with Pool(2) as p:
12        r = p.map(x, range(4))
13    p.join()