OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.78k stars 6.57k forks source link

[REQ] Add basic retries to asyncio Python REST client #17011

Open rad-pat opened 12 months ago

rad-pat commented 12 months ago

Is your feature request related to a problem? Please describe.

The synchronous version of REST client supports basic retries through urllib3 library using the retries configuration parameter. The asyncio version should support the same behaviour such that the retries parameter can be honoured in this version.

I attempted a change to the template files that would appear to handle the case using the aiohttp-retry library. There were no tests for retry in the synchronous version so I have not added any to this change. Please feel free to improve upon this, the feature would be useful.

https://github.com/rad-pat/openapi-generator/tree/add-basic-retry-asyncio

wing328 commented 12 months ago

can you please file a PR to start with? we'll review the enhancement accordingly

imrehg commented 2 months ago

While the generated Python asyncio library has retries since #17014, it is not effective due to the choices of the retry options (namely start_timeout and factor). Setting them both to 0 will effectively run all the retries in a batch in quick succession.

These parameters should have some saner defaults (so there's actually some retry behaviour in the generated code) in the short term, and potentially configurable values on the long term.

rad-pat commented 2 months ago

Just FYI, the original PR was to replicate the behaviour in the sync version of the API, which I believe didn't set any values for backoff or factor (using urllib3 defaults of zero). The new PR makes the async version behave differently to the sync version.