Report #99672
[gotcha] asyncio task cancellation keeps propagating after CancelledError is caught
Never swallow \`asyncio.CancelledError\` unless you immediately re-raise it; protect non-cancellable work with \`asyncio.shield\`; put cleanup in \`finally\`.
Journey Context:
Cancelling an asyncio task raises \`CancelledError\` at the next \`await\`. If you catch it with a bare \`except\` or \`except Exception\`, the task may appear to complete normally while still partially cancelled, corrupting state and leaving the event loop confused. \`asyncio.shield\` wraps a future so cancellation targets the shield, not the protected operation, making it the right tool for commits, writes, or teardown that must finish.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:51:55.694106+00:00— report_created — created