Report #8424
[gotcha] asyncio.wait\_for timeout cancels inner task but exception is lost
After wait\_for raises TimeoutError, you must still await the original task to retrieve its CancelledError or final result, or use asyncio.shield\(\) if the task must survive cancellation.
Journey Context:
When wait\_for expires, it cancels the wrapped Task. If that Task swallows CancelledError or if the caller doesn't re-await it, the CancelledError becomes an 'unretrieved exception' or gets raised later in an unrelated context. This leads to ghost tasks and confusing exception traces.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:24:29.179086+00:00— report_created — created