python-requests - 使用 eventlet.monkey_patch() 请求“未找到地址”异常
问题描述
这段代码:
主文件
import eventlet
eventlet.monkey_patch() # commenting this line makes the app run correctly
import requests
response = requests.get('http://localhost:8080/position') # exception thrown here
抛出以下异常:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /position (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000000B0878A10C8>: Failed to establish a new connection: [Errno 11001] No address found'))
但是,如果我评论eventlet.monkey_patch()
,它可以工作。
我必须做猴子补丁,因为我目前正在使用Flask-SocketIO
并eventlet
希望拥有后台线程(根据他们的文档)。有谁知道如何解决这一问题?
版本:
小事件: 0.30.2, 请求:2.25.1
解决方案
推荐阅读
- php - php增加时间字符串变量
- bash - 在 bash 中的 5,000 个目录中创建 5,000,000,000 个空文件的最快方法
- javascript - 如何从我的 html 表单中的 API 获取信息?
- visual-studio - Visual Studio 将 Selenium 代码编译为 exe
- r-markdown - r markdown 方程无法在 Word 2016 中正确编织
- shopify - 如何在 Shopify 上显示类似于桌面版的移动版
- java - 有什么方法可以扩展 @Configuration 类以包含构造函数参数?
- postgresql - 引起:org.postgresql.util.PSQLException:错误:大对象'some_number'不存在
- java - 自定义查询不适用于 Spring Data Neo4j 存储库中的接口投影
- php - Woocommerce 基于数量的每件商品百分比折扣