Lack of built-in retry mechanism for handling transient network errors and rate limits
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 38/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- python
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 18
- Forks
- 4
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de openapi/openapi-python-sdk
-
Rename package to openapi-sdk (PyPI approval in progress)Posiblemente ocupada @francescobianco la tomó hace 108 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 15/100
-
Dificultad 4/5 1-2 días Aptitud para principiantes 56/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
good first issue help wanted
Dificultad 2/5 1-3 horas Aptitud para principiantes 55/100
openapi/openapi-python-sdk#9 · 7 comentarios ·
Todos los issues de openapi/openapi-python-sdk
Issues similares
-
Path subtraction removes repeated suffix characters instead of one suffixPosiblemente ocupada @Gwerdonatus la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
joke2k/django-environ#671 ·
-
good first issue help wanted windows
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
-
test_pgbouncer deploys the server under test from Charmhub instead of the local build (track/1.31)Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
canonical/temporal-k8s-operator#195 · 1 comentario ·
Los mantenedores suelen responder en 4 días
-
`burr` fails to start when the Python path has a space in itPosiblemente ocupada @enekoreto la tomó hoy. Abiertostatus/needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 5 días
-
device support request
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
zigpy/zha-device-handlers#5461 ·
Los mantenedores suelen responder en 4 días