# SyntaxError: 'await' outside async function

- **ID:** `python/asyncio-await-in-non-async`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using the await keyword inside a synchronous function or at module level without an enclosing async def, violating Python syntax rules.

## Version Compatibility

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

## Workarounds

1. **Define the function with async def** (100% success)
   ```
   async def fetch_data(): return await some_async_func()
   ```
2. **Use asyncio.run() at module level with a wrapper** (95% success)
   ```
   async def main(): await fetch_data()
if __name__ == '__main__': asyncio.run(main())
   ```

## Dead Ends

- **Decorating the function with @asyncio.coroutine** — The @asyncio.coroutine decorator is deprecated and does not make a function async; await still requires async def. (90% fail)
- **Using yield from instead of await** — yield from works with generators, not async functions; it will raise a different error. (70% fail)
