Based on your comment, you would like to run fun1, fun2, fun3 in parallel for x=1, wait until they all finish, then move on to x=2 and repeat. This can be achieved like this:
import multiprocessing as mp
a = [1,2,3,4,5,6,7,8,9,10]
def fun1(x):
....
def fun2(x):
....
def fun3(x):
....
for x in a:
# Create separate process for each function
p1 = mp.Process(target=fun1, args=(x))
p2 = mp.Process(target=fun2, args=(x))
p3 = mp.Process(target=fun3, args=(x))
# Start all processes
p1.start()
p2.start()
p3.start()
# Wait till they all finish and close them
p1.join()
p2.join()
p3.join()
Alternatively, if you would like to run fun1 for all x in a, the run fun2 then fun3, you can use a multiprocessing pool instead:
import multiprocessing as mp
a = [1,2,3,4,5,6,7,8,9,10]
pool = mp.Pool(mp.cpu_count())
def fun1(x):
....
def fun2(x):
....
def fun3(x):
....
# Run fun1 for all values in a
pool.map(fun1, a)
# Run fun2 for all values in a
pool.map(fun2, a)
# Run fun3 for all values in a
pool.map(fun3, a)
# Close pool
pool.close()
pool.join()
In the multiprocessing pool case, pool.map(fun2, a) will not run unless pool.map(fun1, a) finishes running. For more information on Python's multiprocessing module, I highly recommend reading the documentation
fun1to run for allxina, then after it finishes you executefun2andfun3? Or do you wantfun1,2,3to run in parallel whenx=1, then forx=2, and so on?