eventlet.monkey_patch(socket=True)
。不幸的是,这是因为
RecursionError: maximum recursion depth exceeded
代码段requests.Session().get()
有任何可能的方法使
import requests
from requests.adapters import HTTPAdapter
s = requests.Session()
s.mount('https://', HTTPAdapter(pool_connections=2))
s.get('https://stackoverflow.com/questions/34837026/whats-the-meaning-of-pool-connections-in-requests-adapters-httpadapter')
# <Response [200]>
import eventlet
eventlet.monkey_patch(socket=True)
s.get('https://stackoverflow.com/questions/34837026/whats-the-meaning-of-pool-connections-in-requests-adapters-httpadapter')
# <Response [200]>
s.get('https://www.google.com/')
# RecursionError: maximum recursion depth exceeded
s.get('https://stackoverflow.com/questions/34837026/whats-the-meaning-of-pool-connections-in-requests-adapters-httpadapter')
# <Response [200]>
用修补
urllib3.HTTPSConnection.connect(self)
socket
。 我发现唯一的窍门是在应用monkey_patch之前热身连接池。我必须与
eventlet.monkey_patch(socket=True)
打交道。它不是用
gevent
或重写替换的选项。
也是一个类似的问题。 问题是我猴子修补了太晚。 猴子补丁应该是您要做的第一件事(在导入请求之前)