Repository navigation
More 0.2.0 features: stale-while-revalidate, cache stores, retry budget, periodic, OpenTelemetry, pickling - #6
Merged
Merged
Conversation
…n-extensions and mkdocs-material
RetryBudget caps retries at a fraction of traffic, shared across functions,
threads and event loops; retry/retrying accept budget= (also configurable via
configure(retry={"budget": ...})). retry_if_result retries on bad return
values and returns the last value when retries run out. Async functions accept
async retry_if, retry_if_result and on_retry; sync functions reject them at
decoration time. New event: retry.budget_exhausted.
# Conflicts: # tests/test_events.py
…to memoize memoize(ttl=..., stale_ttl=...) serves a stale value while one background refresh runs (a task for async functions, a daemon thread for sync ones). memoize(store=...) keeps entries in any CacheStore. memoize(per_instance=True) caches methods per instance through weak references, so instances stay collectable and need not be hashable. New events cache.stale and cache.refresh_failed.
…ches # Conflicts: # tests/test_events.py
Periodic and AsyncPeriodic objects now pickle by module and qualified name, so every decorated module-level function can be sent to a spawn-context process pool. CircuitBreaker, RateLimiter, Bulkhead, RetryBudget, Transaction, Policy and FakeClock raise a clear TypeError when pickled or copied, since their state belongs to one process. Adds tests/test_pickling.py and a docs section.
- AsyncPeriodic.stop() no longer swallows a cancellation aimed at its caller - stop() from inside an async run ends the loop without waiting a tick - timeout(cleanup_grace=) keeps outside cancellations as CancelledError and waits for and consumes the child task when the caller is cancelled - log an on_error="raise" error that a restart would otherwise drop - document cleanup_grace contextvars and disable_retries budget deposits
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.
Adds to the unreleased 0.2.0:
stale_ttl(stale-while-revalidate),store=with theCacheStoreprotocol,per_instance=True(weakly held per-instance method caches); async hits about 35% faster.RetryBudgetshared across functions,retry_if_result=, asyncretry_if/on_retry/result predicates,async with attemptinretrying.periodic: drift-free background loop for sync and async functions with clean start/stop.trace(otel=True): optional OpenTelemetry spans (lazy import, still zero runtime dependencies).timeout(cleanup_grace=): bounded async cleanup after the limit.periodic.stopandcleanup_grace).Local checks: 992 tests on 3.12-3.14 and 3.14t (986 on 3.10/3.11), stress suite on 3.14t, mypy strict, ruff, 210 doc examples, strict docs build, twine check.