# RuntimeError: Task got Future attached to a different loop

- **ID:** `python/fastapi-sync-endpoint-blocking`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在 FastAPI 的同步端点中使用了异步库或跨线程操作，导致事件循环冲突。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   from starlette.concurrency import run_in_threadpool; result = await run_in_threadpool(sync_func)
   ```
2. **** (95% success)
   ```
   async def endpoint(): await async_func()
   ```

## Dead Ends

- **** — 如果库是同步的，会阻塞事件循环，但不会导致此错误。 (30% fail)
- **** — 线程和事件循环不兼容，导致 Future 跨循环。 (90% fail)
