python config_error ai_generated true

WARNING: WatchFiles detected changes in 'app/main.py'. Reloading... (repeated infinitely)

ID: python/starlette-uvicorn-reload-loop

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-08-30First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
0.30+ active — — —

Root Cause

Hot reload watches a directory written to by the app itself (logs, sqlite, uploads), triggering an endless reload loop.

generic

中文

热重载监视的目录被应用自身写入(日志、sqlite、上传),触发无限重载循环。

Workarounds

  1. 93% success
    uvicorn app.main:app --reload --reload-exclude '*.log' --reload-exclude 'data/*'
  2. 90% success
    LOG_DIR = os.environ.get('LOG_DIR', '/var/log/myapp')

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Loop resumes once the app writes again.

  2. 85% fail

    Suppresses log output but watcher still fires.