BaseService.prepare_request() and BaseService.send() perform requests directly, rather than through a requests.Session() object, which makes it difficult to add a Transport Adapter to implement exponential backoff.
It is possible to implement retries through abuse of the http_config dict, using request hooks to perform recursive calls, but this solution is worse than wrapping a request.
Request wrapping is undesirable because the implementation will inevitably be worse than the one implemented in urllib3, and introduce noise and boilerplate into every request written.
Similarly to this blogpost, if a requests.Session() object is used to perform all requests, this allows users to simply mount a Transport Adapter, which will allow them to easily implement global retries and timeouts according to their needs.
I've written a PR for the change, which should be very low impact and backwards-compatible.
BaseService.prepare_request()
andBaseService.send()
performrequests
directly, rather than through arequests.Session()
object, which makes it difficult to add a Transport Adapter to implement exponential backoff.It is possible to implement retries through abuse of the
http_config
dict, using request hooks to perform recursive calls, but this solution is worse than wrapping a request. Request wrapping is undesirable because the implementation will inevitably be worse than the one implemented inurllib3
, and introduce noise and boilerplate into every request written.Similarly to this blogpost, if a
requests.Session()
object is used to perform all requests, this allows users to simply mount a Transport Adapter, which will allow them to easily implement global retries and timeouts according to their needs.I've written a PR for the change, which should be very low impact and backwards-compatible.