Skip to content

Feat: timeout and retries#5

Merged
MWals merged 4 commits into
mainfrom
feat-timeout-and-retries
Mar 6, 2026
Merged

Feat: timeout and retries#5
MWals merged 4 commits into
mainfrom
feat-timeout-and-retries

Conversation

@felixodelga

Copy link
Copy Markdown
Contributor

Default request timeout (120s): All HTTP requests now have a 120-second timeout by default (via DEFAULT_REQUEST_TIMEOUT), aligned with weclapp's recommendation of at least one minute. This covers both _send_request() and the direct count endpoint call in threaded get_all. Callers can still override per-request.

429 retry with exponential backoff: Added HTTP 429 (Too Many Requests) to the existing urllib3 Retry status_forcelist alongside 5xx errors. Uses the new DEFAULT_BACKOFF_FACTOR (0.3s) constant for exponential backoff. Retry-After headers are respected by default.

Request timing logging: Every API call now logs method, endpoint path, status code, and duration in milliseconds. Requests taking >= 2000ms log at WARNING level with [API_SLOW] prefix; others log at INFO with [API] prefix. The slow threshold is configurable via slow_threshold_ms in the constructor. Query parameters are stripped from logged paths for security.

felixodelga and others added 4 commits February 10, 2026 12:38
- Added logging for API calls, including method, endpoint path, status code, and duration.
- Introduced slow request detection, logging calls taking >= 2000ms at WARNING level.
- Made slow threshold configurable via `slow_threshold_ms` parameter in `Weclapp.__init__()`.
- Ensured query parameters are stripped from logged paths for security.
@felixodelga felixodelga requested a review from MWals February 12, 2026 09:01
@MWals MWals merged commit 9d8f946 into main Mar 6, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants