# 异步超时异常：请求超时

- **ID:** `python/starlette-request-client-timeout`
- **领域:** python
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

服务器响应时间超过客户端超时时间，通常因为端点内的数据库查询或外部API调用缓慢。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   Optimize the endpoint by adding caching, using async database drivers, or offloading heavy tasks to background workers.
   ```
2. **** (85% 成功率)
   ```
   Implement server-side timeouts and return a 504 Gateway Timeout if the operation takes too long.
   ```

## 无效尝试

- **** — Increasing client timeout doesn't fix the root cause; the server still processes slowly. (80% 失败率)
- **** — Retrying the request may eventually succeed but is inefficient and can overload the server. (70% 失败率)
