gpt4 book ai didi

每个子进程的 python并发.futures ProcessPoolExcutor 任务

转载 作者:行者123 更新时间:2023-12-01 03:18:36 24 4
gpt4 key购买 nike

有没有办法限制 ProcessPoolExecutor 中每个子进程的任务并发.futures 模块?

(就像在 multiprocessing.Pool 中一样)

https://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.multiprocessing.Pool

(请参阅 maxtasksperchild 参数)

最佳答案

简短的回答是否定的。没有机制可以跟踪 concurrent.futures.ProcessPoolExecutor 中工作线程执行的任务数量。因此如果不修改python的内部代码就无法做到这一点。

解决方案可能是在 loky 中实现此功能。这是一个用于改进 concurrent.futures.ProcessPoolExecutor 并修复一些错误的库。它提供了一种工作超时机制,并且很容易实现一个任务计数器,当达到 maxtasks 时“超时”。如果您需要此功能,我建议在 loky 存储库上提出问题。

关于每个子进程的 python并发.futures ProcessPoolExcutor 任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42214872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com