python
runtime_error
ai_generated
true
asyncio.exceptions.CancelledError: Task exception was never retrieved
ID: python/asyncio-task-exception-silent
80%Fix Rate
86%Confidence
0Evidence
2025-02-14First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.7 | active | — | — | — |
| 3.8 | active | — | — | — |
| 3.9 | active | — | — | — |
Root Cause
A task raises an exception but the exception is never awaited or retrieved, leading to silent failures.
generic中文
任务引发异常,但异常从未被等待或检索,导致静默失败。
Workarounds
-
90% success
task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
-
95% success
try: await task except Exception as e: print(e)
Dead Ends
Common approaches that don't work:
-
90% fail
The exception is lost, making debugging difficult.
-
60% fail
If the task is not done, it may block or raise.