python - 使用 gevent 池时出现 `NewConnectionError`

标签 python concurrency gevent

在尝试使用 gevent 并行化 IO 绑定(bind)工作时,我收到了大量以下错误消息:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='blabla.com', port=80): Max retries exceeded with url: /bla (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 16] Device or resource busy'))

我的代码看起来使用了这样的实用程序:

def run_parallel(f, it):
    return pool.Group().map(f, it)

避免这些错误的正确方法是什么?

最佳答案

显然我错过了猴子补丁部分。

from gevent import monkey
monkey.patch_all()

关于python - 使用 gevent 池时出现 `NewConnectionError`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58592515/

相关文章:

python - 有时 request.session.session_key 是 None

python - python读取多个json

c++ - 通用输出类签名的正确类型

python - 如何在与主程序不同的线程中编写套接字服务器(使用gevent)?

python - 在虚拟环境中安装 gevent

python - Gunicorn 和 Gevent 使 Heroku 上的 Flask 应用程序崩溃

python - 将 [ ] 替换为 raw_input

python - Python 中的 CURL 替代方案

java - 在 Brian Goetz 的 Concurrency In Practice 中,为什么可伸缩缓存的最后一个例子中有 while(true)?

c++ - 多次使用 std::async 对小任务性能友好吗?