Async Context Manager Retry Pattern

Use when implementing retry-logic around an `async with X:` block where `X.__aenter__()` or `X.__aexit__()` performs network-IO that can fail transiently (python-telegram-bot, asyncpg pools, httpx, websockets). Iron-Law: every `async with` whose enter/exit does network-IO must sit INSIDE the retry-loop, not around it — otherwise enter-failures bypass the inner `try/except` and get caught as "Unexpected" with zero retries actually attempted. Trigger on phrases like "retry around async with", "TimedOut from __aenter__", "I implemented retry but it doesn't trigger", "context manager exception bypasses retry". Do NOT load for sync context-managers, async-with where __aenter__ does only local work (file-open, in-memory state), retry around async-iterators, or first-time-design of an async-context-manager class itself.

Ed3Design d503e4a 8.7 KB Updated

File contents

Ed3Design/ed3design-skill-bundles/tree/main/async-forensik/skills/async-context-manager-retry-pattern commit d503e4a20d

Frequently asked questions

npx skillmds@latest add ed3design/async-context-manager-retry-pattern