在下面的程序中,我如何定期检查:
- 尚未开始的任务数
- 当前工作的 worker 数
- 已完成的任务数
- 他们的状态(如果他们超时)
代码是:
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()
最佳答案
这是你想要的吗?
ar._number_left
关于python - 使用 Python 的 multiprocessing.Pool 和 map_asynch,如何获取有关工作人员的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16966514/