Follow-up · depth 10
How do you make Decorators safer under partial failure?
How do you make Decorators safer under partial failure?
Answers use simple, clear English.
Quick interview answer
Harden Decorators with timeouts, retries with jitter, isolation, and graceful degradation. Mitigate first, then root-cause. Check symptoms against: Forgetting @wraps; decorator not returning wrapper function..
Detailed answer
Resilience for Decorators under partial failure: • Timeouts + budgets on every dependency call • Retries only when idempotent, with jitter/backoff • Isolation: bulkheads/queues so one failure does not cascade • Degradation: serve stale/cached/limited mode when needed Practices: Use wraps; accept *args/**kwargs in generic decorators; prefer parameterized factory pattern. Parent context: Mitigate first, then root-cause. Check symptoms against: Forgetting @wraps; decorator not returning wrapper function..
Full explanation
Partial failure is the default in distributed systems — show how Decorators stays useful anyway. Decorators wrap functions: @decorator applies decorator(func). functools.wraps preserves __name__/__doc__. Common for logging, auth, caching, retries.
Follow-up questions
Only answered follow-ups are shown — click to open with full answers
Parent context — Decorators
Mitigate first, then root-cause. Check symptoms against: Forgetting @wraps; decorator not returning wrapper function..
View full parent question →