Process from multiprocessing python code example
Example 1: python multiprocessing
import multiprocessing
def worker1(i):
print(i, "Process started")
def worker2(i):
print(i, "Process started")
if __name__ == '__main__':
p = multiprocessing.Process(target=worker1, args("nice",))
q = multiprocessing.Process(target=worker2, args("nice2",))
q.start()
p.start()
Example 2: python multiprocessing
from multiprocessing import Pool
def f(x):
return x*x
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1, 2, 3]))