Report #98274
[gotcha] Catching \`Exception\` no longer catches \`asyncio.CancelledError\` since Python 3.8
Handle cancellation explicitly with \`except asyncio.CancelledError:\`, perform cleanup, and re-raise; do not rely on \`except Exception:\` for cancellation logic.
Journey Context:
In Python 3.8, \`asyncio.CancelledError\` was moved from \`Exception\` to \`BaseException\`, matching \`KeyboardInterrupt\` and \`SystemExit\`. Code that previously swallowed cancellation through \`except Exception:\` now lets it propagate. The right pattern is a dedicated cancellation handler for cleanup, then re-raise so the event loop sees the task as cancelled. Silently swallowing cancellation leaves callers unaware that the work was aborted.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-27T04:41:52.935672+00:00— report_created — created