feat(python): enhance retry configuration in REST client

Merged
TI
9mo ago
+58-37

Description

Updated the retries parameter in the Python client Configuration so its type depends on the HTTP library:

  • urllib3: Retry | int | None — passed through to the pool as connection pool kwargs (key_retries).
  • asyncio: int | aiohttp_retry.RetryOptionsBase | None — int is turned into ExponentialRetry; otherwise the given RetryOptionsBase instance is used.

Type annotation: Optional[Union[int, Any]]. No isinstance checks in the urllib3 client as it does not require one; retries are passed through as-is.

Implements #17011

Other python generators, like httpx, tornado, etc. are out of scope as they either have no native retry mechanism or no maintained third party libraries


Checklist (unchanged from your template):

  • Read the contribution guidelines
  • Pull Request title clearly describes the work and description provides detail
  • Run the following to build the project:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    Commit all changed files. CI verifies all generator outputs.
  • File the PR against the correct branch
  • If your PR solves a reported issue, reference it using GitHub's linking syntax
  • If your PR targets a particular programming language, @mention the technical committee

Summary by cubic

Make the Python client's retry config transport-aware. Configuration.retries now accepts int or library-specific options for urllib3 and asyncio, enabling custom retry strategies and addressing #17011.

  • New Features
    • urllib3: accepts int or urllib3 Retry; value passed through unchanged.
    • asyncio: accepts int or aiohttp_retry.RetryOptionsBase; int converts to ExponentialRetry and is reused.
    • Updated type hints/docs to Optional[Union[int, Any]] and clarified behavior in Configuration.