Add bulkhead concurrency isolation and rate-limit header parsing#282
Merged
Conversation
resilience recovers and rate_limit paces, but nothing capped simultaneous in-flight calls (a slow dependency could exhaust every worker) and the HTTP client ignored Retry-After/RateLimit-* headers. Add a bulkhead (bounded-concurrency permit that sheds load when full) and parsers for the server-advised delay (delta-seconds or HTTP-date). Non-blocking permit counting is deterministic. Wired through the facade, AC_bulkhead_run/ AC_retry_after executor commands, MCP tools and the Script Builder.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 47 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
resiliencerecovers from failures andrate_limitpaces calls, but nothing capped the number of simultaneous in-flight calls to one resource (a slow dependency could exhaust every worker), and the HTTP client readRetry-After/RateLimit-*headers but honored none of them. This adds both.Bulkhead(max_concurrent, name=)—try_enter/release, context manager,run(func); rejects withBulkheadFullErrorwhen full (load-shedding / fault isolation). Non-blocking permit counting → deterministic, no threads in tests.parse_retry_after(headers)— delta-seconds or HTTP-date;parse_ratelimit(headers)—RateLimit-Limit/Remaining/Reset;next_delay(response)— the wait a flow should observe after 429/503.Pure stdlib (
threading+email.utils).Five-layer wiring
je_auto_control/utils/bulkhead/__init__.py+__all__AC_bulkhead_run(named bulkhead wraps an action list),AC_retry_afterac_bulkhead_run,ac_retry_afterTests & docs
test/unit_test/headless/test_bulkhead_batch.py(9 tests: permit/reject, context manager, run, bad max, Retry-After delta/date/case, RateLimit parse, next_delay sources)Lint clean: ruff / pylint / bandit / radon.