(编辑:也许我对这个错误的含义有误。这是否表明我的 CLIENT 上的连接池已满?或者 SERVER 上的连接池已满,这是我的客户端出现的错误?)
我正在尝试使用 python threading
和 requests
模块同时发出大量 http
请求。我在日志中看到此错误:
WARNING:requests.packages.urllib3.connectionpool:HttpConnectionPool is full, discarding connection:
如何增加请求的连接池大小?
最佳答案
这应该可以解决问题:
import requests.adapters
session = requests.Session()
adapter = requests.adapters.HTTPAdapter(pool_connections=100, pool_maxsize=100)
session.mount('http://', adapter)
response = session.get("/mypage")
关于python - 在线程中更改 Python 的 "requests"模块的连接池大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18466079/