# asyncio队列异常：队列为空

- **ID:** `python/asyncio-queue-empty`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在空的asyncio.Queue上调用queue.get_nowait()。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.7 | active | — | — |
| 3.8 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   if not q.empty(): item = q.get_nowait()
   ```
2. **** (100% 成功率)
   ```
   item = await q.get()
   ```

## 无效尝试

- **** — get() is a coroutine and must be awaited; otherwise it raises a different error. (90% 失败率)
- **** — May lead to null pointer issues if not handled properly. (50% 失败率)
