Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-29001 Update handlers.py to address abnormal behavior when using RotatingFileHandler under gunicorn multiple workers #9616

Closed
wants to merge 1 commit into from

Conversation

pathakumesh
Copy link

@pathakumesh pathakumesh commented Sep 28, 2018

For RotatingFileHandler,

For gunicorn running with multiple workers, each worker will have separate RotatingFileHandler instances. Due to this, when rollover occurs, the effect is reflected only for the current worker. Due to this, while rotation, multiple new .log file is being created and the new logs keep emitting in these new files (Unexpected!). The situation is illustrated here too.
https://bugs.python.org/issue29001

Hence, as a solution, to propagate the rollover for all workers, both stream_size and file_size has to be checked and take action accordingly.

https://bugs.python.org/issue29001

For RotatingFileHandler,

For gunicorn running with multiple workers, each worker will have separate RotatingFileHandler instances. Due to this, when rollover occurs, the effect is reflected only for the current worker. Due to this, while rotation, multiple new .log file is being created and the new logs keep emitting in these new files (Unexpected!). The situation is illustrated here too.
`https://bugs.python.org/issue29001`

Hence, as a solution, to propagate the rollover for all workers, both stream_size and file_size has to be checked and take action accordingly.
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for your contribution, we look forward to reviewing it!

@csabella
Copy link
Contributor

csabella commented Sep 28, 2018

Hi @pathakumesh Please update the title of your pull request to start with bpo-xxxxx:, where xxxx is the issue number. Thanks!

@pathakumesh pathakumesh changed the title Update handlers.py to address abnormal behavior when using RotatingFileHandler under gunicorn multiple workers bpo-29001 Update handlers.py to address abnormal behavior when using RotatingFileHandler under gunicorn multiple workers Sep 29, 2018
@vsajip
Copy link
Member

vsajip commented Sep 29, 2018

I'm not sure we want to do this - it seems not to be a generic solution. As documented here, the recommendation for writing to files from multiple processes is to use a method such as SocketHandler or QueueHandler communicating with a separate process which writes to file(s).

@vsajip vsajip closed this Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants