【发布时间】:2022-12-27 20:11:14
【问题描述】:
I am using pathos.multiprocessing to run a function in parallel processes and with different input arguments per process. Here is a minimum working example:
import pathos.multiprocessing as mp
from time import sleep
def my_func(x, y):
for i in range(x):
print(y+i)
sleep(.2)
return i + y
seq = [(100, 4), (100, 5)]
processes = 2
print ("Multiprocessing...")
pool = mp.Pool(processes)
resultsObj = pool.starmap_async(my_func, seq )
pool.close()
results = resultsObj.get()
As expected, the results are printed mixed up from the 2 processes, like so:
Multiprocessing...
4
5
5
6
7
6
7
8
8
9
10
9
10
11
Is there a way to drive the results to 2 different terminal to watch the progress? Or any other way to have the results printed in a "per process" fashion?
【问题讨论】:
标签: printing multiprocessing pathos