emmett-framework / granian

A Rust HTTP server for Python applications
BSD 3-Clause "New" or "Revised" License
2.86k stars 83 forks source link

Python Rotating File Handler Logging Error #377

Open Isildur981 opened 3 months ago

Isildur981 commented 3 months ago

Granian ver 1.5.2 Python ver 3.12.4 OS: Windows 10 Enterprise - build 19045

When I configure granian to use the Python logging RotatingFileHandler, I get an error when the first file reaches the defined maximum file size. The file is not able to be closed and renamed with the .1 file extension.

This is the error that is displayed in the console:

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\Logs\Starlette\access.log' -> 'C:\Logs\Starlette\access.log.1'

I have debugging in Starlette disabled, reload in granian is turned off, and the log level is set to info. I am only using one worker, since I'm running on Windows.

The RotatingFileHandler will work with uvicorn if I limit it to a single worker process, but I run into the same error if I use multiple workers with uvicorn. I don't know if this is pointing at the separate granian and Python processes being related to the problem, or if I have something else misconfigured. I can post my logging configuration JSON file if needed. Thanks ahead of time for any suggestions.

gi0baro commented 3 months ago

Given the issue is happening also with other libraries/configurations, I honestly doubt there's anything Granian can do for this.

Seems a good issue to open to CPython about the logging stdlib module.