python
config_error
ai_generated
true
WARNING: WatchFiles 检测到 'app/main.py' 的更改。正在重载……(无限重复)
WARNING: WatchFiles detected changes in 'app/main.py'. Reloading... (repeated infinitely)
ID: python/starlette-uvicorn-reload-loop
80%修复率
86%置信度
0证据数
2024-08-30首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 0.30+ | active | — | — | — |
根因分析
热重载监视的目录被应用自身写入(日志、sqlite、上传),触发无限重载循环。
English
Hot reload watches a directory written to by the app itself (logs, sqlite, uploads), triggering an endless reload loop.
解决方案
-
93% 成功率
uvicorn app.main:app --reload --reload-exclude '*.log' --reload-exclude 'data/*'
-
90% 成功率
LOG_DIR = os.environ.get('LOG_DIR', '/var/log/myapp')
无效尝试
常见但无效的做法:
-
70% 失败
Loop resumes once the app writes again.
-
85% 失败
Suppresses log output but watcher still fires.