3
如果一個新的會話請求以不同的方法,像這樣實例化......哪裏是urllib3連接池綁定?
myutil.py
import requests
def method1():
s1 = requests.Session()
def method2():
s1 = requests.Session()
哪裏requests.packages.urllib3.poolmanager.PoolManager
約束?它是否在全局綁定,以便連接池在s1和s2之間共享,還是綁定到每個方法的堆棧,以便s1和s2具有不同的連接池?
如果它綁定到每個方法的堆棧,我有什麼選擇來共享連接池?舉例來說,我應該創建一個transport adapter然後佔有率比方法之間:
myutil.py
import requests
from requests.adapters import HTTPAdapter
httpAdapter = HTTPAdapter(pool_connections=10, pool_maxsize=100)
def method1():
s1 = requests.Session()
s1.mount('https://', httpAdapter)
def method2():
s1 = requests.Session()
s2.mount('https://', httpAdapter)