在以下程序中,我如何定期检查:
代码是:
from multiprocessing import Pool
import time
def f(x):
time.sleep(x)
return x*x
if __name__ == '__main__':
pool = Pool(processes=4) # start 4 worker processes
ar = pool.map_async(f, range(10)) # prints "[0, 1, 4,..., 81]"
pool.close()
pool.join()
ar.wait()
print ar.get()
答案 0 :(得分:1)
这是你想要的吗?
ar._number_left