johnthexiii的解决方案会在第一次运行worker函数时终止该模型。您可以提供单独的销毁功能:
import timedef g(x): # destroy function del model time.sleep(1) # to ensure, this worker does not pick too many return None
在
pool.close()添加之前
pool.map_async(g, range(2), 1) # if specified to have two processes before
我认为这不是一个非常“干净”的解决方案,但它应该可以工作。



