# Task exception was never retrieved

- **ID:** `python/asyncio-task-exception-never-retrieved`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

A Task raised an exception but nobody awaited it or called task.exception(). The default loop exception handler logs this warning at garbage collection.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.8+ | active | — | — |
| 3.9+ | active | — | — |
| 3.10+ | active | — | — |
| 3.11+ | active | — | — |
| 3.12+ | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   task = asyncio.create_task(worker())
task.add_done_callback(lambda t: t.exception() if not t.cancelled() else None)
await task
   ```
2. **** (93% success)
   ```
   results = await asyncio.gather(*tasks, return_exceptions=True)
for r in results:
    if isinstance(r, Exception):
        log.error('task failed', exc_info=r)
   ```

## Dead Ends

- **** — It's logged via loop.call_exception_handler, not the warnings module; the underlying failure persists. (90% fail)
- **** — The exception happens asynchronously inside the task, not at creation time. (85% fail)
