IBM / python-sdk-core

The python-sdk-core repository contains core functionality required by Python code generated by the IBM OpenAPI SDK Generator.
Apache License 2.0
20 stars 27 forks source link

Implementing retries in `BaseService` #83

Closed illeatmyhat closed 3 years ago

illeatmyhat commented 3 years ago

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.

ibm-devx-automation commented 3 years ago

:tada: This issue has been resolved in version 3.5.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: