I am trying to execute below code in parallel using multiprocessing but I am not getting proper output.
Iteration with 1 and iteration with 5 should happen in parallel
from multiprocessing import Pool
def func1(x):
i = x
while i < 10:
print(str(i)+" fun1")
i +=1
if __name__ == '__main__':
pool = Pool(processes=1)
pool.map(func1, [1,5])
Result I got: happening more iterations
1 fun1 2 fun1 3 fun1 4 fun1 5 fun1 6 fun1 7 fun1 8 fun1 9 fun1 5 fun1 6 fun1 7 fun1 8 fun1 9 fun1
Expected output: both iterations should happen in parallel
1 fun1 5 fun1 2 fun1 6 fun1 3 fun1 7 fun1 4 fun1 8 fun1 5 fun1 9 fun1 6 fun1 7 fun1 8 fun1 9 fun1