Issue 16244: TimedRotatingFileHandler forces "write" mode, should use "append" (original) (raw)

Issue16244

Created on 2012-10-16 05:05 by richard, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py axil,2013-12-10 21:00 Snippet demonstrating the issue
Messages (3)
msg173016 - (view) Author: Richard Jones (richard) * (Python committer) Date: 2012-10-16 05:05
The RotatingFileHandler classes force the open() mode of the new log file to be "w" even though it is initially defaulted to "a" in doRollover() methods: self.mode = 'w' self.stream = self._open() This can cause problems in systems that have multiple programs writing to the log file; they can both end up opening the new file in "w" mode and then there's loss of data. I cannot think of a reason why "w" should be forced in this manner. The fix is to remove the "self.mode = 'w'" line from the two doRollover() methods.
msg173020 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-10-16 09:33
New changeset 6fcfe701502b by Vinay Sajip in branch '2.7': Issue #16244: Remove file mode overrides. http://hg.python.org/cpython/rev/6fcfe701502b New changeset 5e770555be62 by Vinay Sajip in branch '3.2': Issue #16244: Remove file mode overrides. http://hg.python.org/cpython/rev/5e770555be62 New changeset 4f1287be26a6 by Vinay Sajip in branch '3.3': Issue #16244: Merged change from 3.2. http://hg.python.org/cpython/rev/4f1287be26a6 New changeset c20b0b5590db by Vinay Sajip in branch 'default': Closes #16244: Merged change from 3.3. http://hg.python.org/cpython/rev/c20b0b5590db
msg205858 - (view) Author: axil (axil) Date: 2013-12-10 21:00
This fix breaks the behavior of RotatingFileHandler. Maxbytes>0 can now be only used with backupCount>0 otherwise it is ignored. So all programs that are using Maxbytes>0 and backupCount=0 are now facing an infinitely growing logfile.
History
Date User Action Args
2022-04-11 14:57:37 admin set github: 60448
2013-12-10 21:00:39 axil set files: + test.pyversions: + Python 2.7nosy: + axilmessages: + type: behavior -> resource usage
2012-10-16 09:33:48 python-dev set status: open -> closednosy: + python-devmessages: + resolution: fixedstage: resolved
2012-10-16 06:57:53 ned.deily set nosy: + vinay.sajip
2012-10-16 06:15:52 hynek set nosy: + hynek
2012-10-16 05:05:37 richard create