I am using multiprocessing
library of python and also emcee
which also uses different threads to implement MCMC
. The problem is that even when I close
the pool
still it seems python uses the processors and slows down the cores and I have no idea what is the efficient way to release the cores after the job is done. Could anybody give me an idea of what I should do?
Update:
My code has been already posted here.
问问题
1454 次
1 回答
4
关闭 aPool
并不会阻止它工作,它只会阻止将新的工作项添加到其中:
关()
防止任何更多的任务被提交到池中。完成所有任务后,工作进程将退出。
因此,如果您有很多排队的任务,关闭它们Pool
不会对资源使用产生任何影响 - 所有工作人员都会继续使用这些排队的任务,直到它们消失。如果您想立即中止所有工作项,则必须使用pool.terminate
:
终止()
立即停止工作进程而不完成未完成的工作。当池对象被垃圾回收时,
terminate()
将立即调用。
于 2014-08-26T15:31:18.937 回答