返回 Bug 清单
BUG-0086project-09低已修复dev-watch-reload
uvicorn watchfiles reload Windows 不稳定
发现:2026-09-30验证:2026-10-27置信度:85%
症状
([cursor_202606072236.md:582-741](file://d:/chemindra/cursor_202606072236.md#L582),至少 **5 次** 重现):
`uvicorn --reload` 下修改代码文件后出现大量 `KeyboardInterrupt` 及子进程崩溃,典型的 WatchFiles 触发链:
```
WatchFiles detected changes in 'app/models/project.py'. Reloading...
→ KeyboardInterrupt (子进程启动阶段)
→ INFO: Started server process [xxx] (短暂恢复)
→ WatchFiles detected changes in 'app/schemas/molecule.py'. Reloading...
→ KeyboardInterrupt (再次崩溃)
```
每次 auto-reload 约 1~3 次崩溃后才能稳定。
根因
Windows 上 uvicorn 的 WatchFilesReload 使用 `multiprocessing.spawn` 启动子进程。文件变更触发 reload 时,子进程在 `importlib._bootstrap` 阶段被上一个 `KeyboardInterrupt` 竞争中断。这是 watchfiles + multiprocessing.spawn 在 Windows 上的已知问题。
错误签名
Windows 上 uvicorn 的 WatchFilesReload 使用 `multiprocessing.spawn` 启动子进程。文件变更触发 reload 时,子进程在 `importlib._bootstrap` 阶段被上一个 `KeyboardInterrupt` 竞争中断。这是 watchfiles + multiprocessing.spawn 在 Windows 上的已知问题技术信息
来源项目
project-09
涉及文件
apps/server/app/core/deps.py, apps/server/app/models/, 所有热重载涉及的文件
标签
dev-watch-reload, project-09