Skip to content

Add 429 retry/backoff to Grain API client - #5

Draft
dplakon wants to merge 1 commit into
mainfrom
fix/grain-client-429-retry-backoff
Draft

Add 429 retry/backoff to Grain API client#5
dplakon wants to merge 1 commit into
mainfrom
fix/grain-client-429-retry-backoff

Conversation

@dplakon

@dplakon dplakon commented Jul 23, 2026

Copy link
Copy Markdown

Problem

The daily meeting-processing pipeline (grainiac-orchestrator) failed at the fetch_daily_meetings.py step with HTTP Error 429: Too Many Requests. The Grain client (scripts/grain_client.py) paginated through recordings by firing requests back-to-back with no throttling, and _get raised immediately on any HTTPError. Grain rate-limits bursty pagination, so the fetch reliably died after the first page and no meetings could be processed.

Change

  • Add a shared _urlopen_with_retry helper that retries 429 and transient 5xx responses with exponential backoff, honoring the Retry-After response header when present.
  • Route both recording listing (_get) and transcript fetching (get_transcript_text) through the helper.
  • Make retry behavior tunable via GRAINIAC_MAX_RETRIES (default 6) and GRAINIAC_BACKOFF_SECONDS (default 2).

Verification

With this change, python scripts/fetch_daily_meetings.py today retried the rate-limited pages and completed successfully, fetching all recordings and identifying the day's external customer meetings.

Conversation: https://app.warp.dev/conversation/4479e69b-9f6b-482a-b74f-5f79c31a9354

Run: https://oz.warp.dev/runs/019f8d58-5046-706a-aa0e-a74b287fb1e0

This PR was generated with Oz.

The Grain client fired paginated requests back-to-back with no
throttling and raised immediately on any HTTPError. Grain rate-limits
bursty pagination, so the daily fetch reliably failed with HTTP 429
after the first page, blocking the meeting-processing pipeline.

Add a shared `_urlopen_with_retry` helper that retries 429 and
transient 5xx responses with exponential backoff, honoring the
Retry-After header when present. Both recording listing and transcript
fetches now go through it. Retry count and base backoff are tunable via
GRAINIAC_MAX_RETRIES and GRAINIAC_BACKOFF_SECONDS.

Co-Authored-By: Oz <oz-agent@warp.dev>
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.

1 participant