Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Lack of built-in retry mechanism for handling transient network errors and rate limits

Đang mở
#20 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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:

  1. Transient Network Errors: Minor network drops, socket timeouts, or DNS hiccups fail immediately.
  2. Temporary Server Overloads: Gateway errors (HTTP 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout) trigger immediate crashes.
  3. 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:

  1. Exponential Backoff: Gradually increase wait times between retries (e.g. wait 1s, then 2s, then 4s) to give the server time to recover.
  2. Jitter (Randomized Noise): Add random variation to the sleep durations to prevent multiple clients from hitting the server at the exact same millisecond.
  3. Smart Rate-Limit Handling: Automatically detect HTTP 429 status codes, parse the Retry-After header if available, and sleep for the requested duration before retrying.
  4. 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_retries to 0 guarantees 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openapi/openapi-python-sdk

Tất cả issue của openapi/openapi-python-sdk

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.