gpt4 book ai didi

python - python中的并行API请求

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:12 24 4
gpt4 key购买 nike

我希望实现此处建议的线程解决方案:What is the fastest way to send 100,000 HTTP requests in Python?

我的问题是,如果我在进行 URL 调用后“做某事”是将新行附加到列表(使用 data.append)——这会导致任何问题吗?

此外,我还将使用 Python 2 并使用 urllib2——如果是 urllib2 而不是 httplib,推荐的解决方案是否会完全改变?

最佳答案

由于您正在尝试实现 IO 绑定(bind)操作,我建议您使用 gevent .这是 example .

或者使用this回答。 Gevent 不仅支持 Python 2 和 Python 3,还支持 PyPy,它也可以加速你的程序。

关于python - python中的并行API请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36439245/

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