I have seen something like this in a few code snippets and in the Requests documentation:
import requests
sess = requests.Session()
adapter = requests.adapters.HTTPAdapter(max_retries=20)
sess.mount('https://', adapter)
I am trying to get a better sense of what .mount()
does here. In this case, is it only to increase the number of allowed retries for all calls to sess.request()
? Is it emulating something like:
for _ in range(max_retries):
try:
return sess.request(...)
except:
pass
or is there more going on?
I know that requests.Session
instances are initialized with adapters that have max_retries=0
, so the above is just a hunch based on that.
It would just be helpful to know how specifically .mount()
is altering the session object's behavior in this case.