You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python ProcessPoolExecutor.map()执行时无限等待问题咨询

问题描述
  • 调用ProcessPoolExecutor.map()方法时,参数n取值10000至20000区间程序可正常运行,但设为100000时程序无响应,需强制终止
  • 相同代码在4核、32GB内存的其他机器上能正常执行,仅当前机器出现异常(机器配置见截图)
  • 已尝试的排查操作:移除tqdm进度条、提高ulimit限制、将Python版本从3.9更换至3.10,均未解决问题

测试代码

from concurrent.futures import ProcessPoolExecutor
from tqdm import tqdm

def test_func(x):
    return x+1

if __name__ == '__main__':
    n = 100000
    with ProcessPoolExecutor(4) as p:
        lst = list( tqdm( p.map( test_func,
                                 [i for i in range(n)]
                                 ),
                          total = n,
                          leave = True
                          )
                    )
        # 也曾尝试去掉tqdm进度条运行
        #lst = list(      p.map( test_func,
        #                        [i for i in range(n)]
        #                        )
        #                 )

内容的提问来源于stack exchange,提问作者suchang

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 22:52:02