Skip to content

Restore throttle buckets after expiration - #389

Open
Doyoubelieveinfate wants to merge 1 commit into
grantjenks:masterfrom
Doyoubelieveinfate:fix/throttle-expired-bucket
Open

Doyoubelieveinfate wants to merge 1 commit into
grantjenks:masterfrom
Doyoubelieveinfate:fix/throttle-expired-bucket

Conversation

@Doyoubelieveinfate

Copy link
Copy Markdown

Fixes #386.

After a throttle bucket expires, cache.get(key) returns None and the next call fails while unpacking it. Use the initial (current time, count) state when the entry is missing, then consume a token through the existing transaction and update paths.

Document the expiration policy: an expired bucket starts full again. Controlled-clock tests cover expiration both before the first call and after a successful call, with non-expiring controls. Each case also exhausts the restored allowance and verifies the next call waits half a second for another token, without real sleeps.

Validation on macOS/Python 3.13.5:

  • Before the fix: two expiration regressions fail with TypeError; two controls pass.
  • Full configured suite with two workers: 255 passed, 99.04% coverage with branch measurement enabled (98% required).
  • Blue, Flake8, isort, mypy and git diff --check pass. Pylint 2.17.7 reports three diagnostics in unchanged persistent.py under Python 3.13; that check is not green locally.
  • Reviewed transaction scope, token consumption after reset, and compatibility when expiration is disabled.

This change does not include the separate tag-preservation work in #381.

Prepared, tested and reviewed with Codex at the account owner's request.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T13:41:11.204853Z aa57cb4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

throttle with expire crashes after the token bucket expires

1 participant