Lack of built-in retry mechanism for handling transient network errors and rate limits
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 38/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Pouca atividade
- Stack de tecnologia
- python
- Domínio
- backend-api-design
Direção de pesquisa
Read the synchronous and asynchronous client constructors and the HTTP request paths for Client, AsyncClient, OauthClient, and AsyncOauthClient. Check how the SDK handles network errors, response status codes, and Retry-After headers, then identify the tests covering those paths. Done means opt-in retries work across all four clients with backoff, jitter, rate-limit handling, and the stated defaults.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Currently, the OpenAPI Python SDK is designed with low-level HTTP primitives. If an API request fails due to a transient error, the client raises an error or fails immediately:
- Transient Network Errors: Minor network drops, socket timeouts, or DNS hiccups fail immediately.
- Temporary Server Overloads: Gateway errors (HTTP
502 Bad Gateway,503 Service Unavailable,504 Gateway Timeout) trigger immediate crashes. - Rate Limits (HTTP 429): If the client hits API rate limits, it fails instantly rather than waiting for the reset window.
To handle these scenarios, developers using the SDK must write custom retry loops and catch blocks in their application code, leading to unnecessary boilerplate.
Proposed Feature
Implement an optional, built-in retry mechanism for both synchronous and asynchronous clients (Client, AsyncClient, OauthClient, and AsyncOauthClient).
This retry mechanism should feature:
- Exponential Backoff: Gradually increase wait times between retries (e.g. wait 1s, then 2s, then 4s) to give the server time to recover.
- Jitter (Randomized Noise): Add random variation to the sleep durations to prevent multiple clients from hitting the server at the exact same millisecond.
- Smart Rate-Limit Handling: Automatically detect HTTP 429 status codes, parse the
Retry-Afterheader if available, and sleep for the requested duration before retrying. - Customizable Configuration: Allow developers to configure the retries during client initialization, with safe defaults.
Proposed API Design
Add optional retry parameters to the client constructors:
client = Client(
token="your_token",
max_retries=3, # Number of retry attempts (0 to disable)
backoff_factor=1.0, # Multiplier for exponential sleep delay
retry_on_status=[429, 502, 503, 504] # Status codes that trigger a retry
)
To ensure 100% backward compatibility, max_retries should default to 0 (disabled), ensuring no existing production code or tests are affected unless the developer explicitly opts in.
Benefits
- Resilience: SDK handles transient internet drops and brief server downtime gracefully.
- Ease of Use: Reduces boilerplate code in the consumer's application.
- Backward-Compatible: Defaulting
max_retriesto0guarantees existing behavior is preserved.
- Linguagem predominante
- Python
- Estrelas
- 18
- Forks
- 4
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de openapi/openapi-python-sdk
-
Rename package to openapi-sdk (PyPI approval in progress)Talvez já em andamento @francescobianco assumiu há 108 dias. Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 15/100
-
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 56/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 42/100
-
good first issue help wanted
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 55/100
openapi/openapi-python-sdk#9 · 7 comentários ·
Todas as issues de openapi/openapi-python-sdk
Issues semelhantes
-
`burr` fails to start when the Python path has a space in itTalvez já em andamento @enekoreto assumiu hoje. Abertastatus/needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 5 dias
-
gemini 出现了新的域名需要加入Aberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 72/100
-
Dificuldade 2/5 Meio dia Facilidade para iniciantes 72/100
debpalash/VoiceStudio#2903 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
dagster-io/community-integrations#367 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
aws-samples/sample-per-model-bedrock#243 ·
Mantenedores costumam responder em até 1 dia