uvicorn.run() not respecting the reload_excludes parameter? #1656
-
I am using FastAPI with Python built-in logging module. Whenever the log file is updated, the program reloads as well, creating an infinite loop. (I am using uvicorn.run() for debugging as suggested in the FastAPI doc) Maybe I made a mistake somewhere? Here is my script: from fastapi import FastAPI
import uvicorn, logging
from logging.handlers import TimedRotatingFileHandler
logger = logging.getLogger()
logger.setLevel(logging.INFO)
logHandler = TimedRotatingFileHandler(
"api.log",
when="D",
backupCount=10,
encoding="utf-8",
)
logHandler.setFormatter(
logging.Formatter(
"%(asctime)s %(levelname)-8s %(name)-15s %(message)s",
datefmt="%H:%M:%S",
)
)
logger.addHandler(logHandler)
app = FastAPI()
@app.get("/")
async def root():
return {"message": "Hello World"}
if __name__ == "__main__":
uvicorn.run(
"__main__:app",
host="0.0.0.0",
port=8000,
reload=True,
reload_excludes="*.log"
) Note: I have |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 9 replies
-
how do you run uvicorn ? what exclude parameters are you passing ? what is the directory structure like, where the log file is located ? |
Beta Was this translation helpful? Give feedback.
-
cant reproduce on linux though the api.log file is filled wuite rapidely with |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
reload_excludes
just tells uvicorn not to trigger a reload if there is a change in the file, which is what is happening: api.log is changing and uvicorn does not reload itself, so everything works fine to me.