【发布时间】:2019-01-23 12:47:45
【问题描述】:
我正在尝试根据已完成任务的结果提交进一步的任务:
with concurrent.futures.ThreadPoolExecutor() as executor:
future = executor.submit(my_task)
def callback(future):
for another_task in future.result():
future = executor.submit(another_task)
future.add_done_callback(callback)
future.add_done_callback(callback)
但我得到了:
RuntimeError: 关机后无法安排新的未来
让执行程序等待回调的最佳方法是什么?信号量?
如果将ThreadPoolExecutor 替换为ProcessPoolExecutor,理想情况下解决方案应该可以很好地转移。
【问题讨论】:
标签: python multithreading multiprocessing