阶段3(上):Python/asyncio/FastAPI 专题的课程、企业场景、面试题和可运行示例
This commit is contained in:
1 parent
b8010a74f3
commit
7f52513ffc
24 files changed
+2817
-33
No files matched your search
@@ -4,12 +4,38 @@ title: asyncio 异步编程
|
||||
type: index
|
||||
domain: python
|
||||
stack: [asyncio]
|
||||
tags: []
|
||||
tags: [asyncio, 协程, 并发, 超时]
|
||||
week: [4, 5, 12]
|
||||
---
|
||||
|
||||
# asyncio 异步编程
|
||||
|
||||
协程、任务、并发控制、超时与取消。
|
||||
AI 应用的大部分时间在“等”:等模型生成、等检索、等数据库。asyncio 让一个进程同时等很多件事。你熟悉 JS 的 `async/await` 和 Promise,概念几乎可以直接迁移;不同点在于 Python **需要显式运行事件循环**、**同步阻塞调用会卡住整个循环**、以及任务取消和超时的写法。
|
||||
|
||||
> 本专题建设中:课程、企业场景、面试题和示例代码会陆续补充。
|
||||
## 学习路线
|
||||
|
||||
| 顺序 | 课程 | 级别 | 预计 |
|
||||
| --- | --- | --- | --- |
|
||||
| 1 | [协程、任务和事件循环:和 JS Promise 对照](01-coroutines-tasks.md) | 基础 | 2 小时 |
|
||||
| 2 | [并发控制:gather / TaskGroup、Semaphore、超时、取消、阻塞调用](02-concurrency-control.md) | 进阶 | 3 小时 |
|
||||
|
||||
## 企业场景
|
||||
|
||||
- [并发调用多个模型和外部接口:限并发、超时、重试、部分失败](scenarios/concurrent-llm-calls.md)
|
||||
|
||||
## 面试题
|
||||
|
||||
- [asyncio 面试题](interview.md)
|
||||
|
||||
## 示例代码
|
||||
|
||||
- [examples/fanout](examples/fanout/):并发上限、单次超时、指数退避重试、部分失败、整体截止时间取消,附 6 个测试,只用标准库
|
||||
|
||||
## 在 16 周计划中
|
||||
|
||||
- [第 4 周:Python 速成(asyncio 是重点)](../../../plan/week04-python.md)、[第 5 周:RAG 服务](../../../plan/week05-rag-1.md)、[第 12 周:Agent 持久化](../../../plan/week12-agent-m3-persistence.md)
|
||||
|
||||
## 官方资料
|
||||
|
||||
- asyncio 文档(中文):https://docs.python.org/zh-cn/3/library/asyncio.html
|
||||
- 协程与任务:https://docs.python.org/zh-cn/3/library/asyncio-task.html
|
||||
Reference in new issue
Block a user