If a new requests session is instantiated in different methods like so ...
myutil.py
import requests
def method1():
s1 = requests.Session()
def method2():
s1 = requests.Session()
Where is the requests.packages.urllib3.poolmanager.PoolManager
bound? Is it bound globally so that the connection pool is shared between s1 and s2, or is it bound to each method's stack so that s1 and s2 have different connection pools?
If it is bound to each method's stack, what options do I have to share the connection pool? For example, should I create a transport adapter and then share than between the methods:
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)
I have done some testing and it seems that the pool does NOT get bound globally.
See here for more info.