Lack of built-in retry mechanism for handling transient network errors and rate limits
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 18
- Fork
- 4
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của openapi/openapi-python-sdk
-
Rename package to openapi-sdk (PyPI approval in progress)Có thể đã có người làm @francescobianco đã nhận 107 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 15/100
-
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 56/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 55/100
openapi/openapi-python-sdk#9 · 7 bình luận ·
Tất cả issue của openapi/openapi-python-sdk
Issue tương tự
-
Agentic
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Imbad0202/academic-research-skills#979 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
reflex-dev/reflex#7561 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
prometheus-community/ansible#906 · 2 bình luận ·