Answers for "index in the pool python"

0

index in the pool python

import os
from multiprocessing import current_process, Pool


def x(a):
    p = current_process()
    print('process counter:', p._identity[0], 'pid:', os.getpid())


if __name__ == '__main__':
    with Pool(2) as p:
        r = p.map(x, range(4))
    p.join()
Posted by: Guest on June-01-2020

Python Answers by Framework

Browse Popular Code Answers by Language