# RuntimeError: Timeout context manager should be used inside a task

- **ID:** `python/asyncio-timeout-no-current-event-loop`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

asyncio.timeout() (3.11+) or asyncio.wait_for() was used outside a Task context, e.g. directly in loop.run_until_complete() without wrapping in create_task.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.11+ | active | — | — |
| 3.12+ | active | — | — |

## Workarounds

1. **** (93% success)
   ```
   task = asyncio.create_task(do_work())
try:
    async with asyncio.timeout(5):
        await task
except TimeoutError:
    task.cancel()
   ```
2. **** (92% success)
   ```
   try:
    result = await asyncio.wait_for(do_work(), timeout=5)
except asyncio.TimeoutError:
    ...
   ```

## Dead Ends

- **** — Blocks the loop and defeats async concurrency. (90% fail)
- **** — Debug flag is unrelated; the check is unconditional. (85% fail)
