[ python-Bugs-1708538 ] TimedRotatingFileHandler's doRollover opens file in "w" mode

SourceForge.net noreply at sourceforge.net
Sun Apr 29 17:29:59 CEST 2007


Bugs item #1708538, was opened at 2007-04-27 09:30
Message generated for change (Comment added) made by fastflo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1708538&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Closed
Resolution: Invalid
Priority: 5
Private: No
Submitted By: Florian Schmidt (fastflo)
Assigned to: Vinay Sajip (vsajip)
Summary: TimedRotatingFileHandler's doRollover opens file in "w" mode

Initial Comment:
if TimedRotatingFileHandler does an doRollover() it opens the new file hardcoded with mode "w" whilst the baseclass FileHandler opens it with mode "a" if nothing else is specified in the constructor. it should use the same default behavior as FileHandler and/or give a way to specify another open-mode.

if multiple processes write to the same file, and one does the RollOver all other newly spawned processes write to the end of the new file but the still running first process who did the rollover will write from the beginning of the file - overwriting log entries from the other procs...

----------------------------------------------------------------------

>Comment By: Florian Schmidt (fastflo)
Date: 2007-04-29 17:29

Message:
Logged In: YES 
user_id=182876
Originator: YES

i think opening the log file with "w" is inconsistent and therefore should
be fixed.

as a comment: i do not need IPC/synchronisation if all processes are
writing in append-mode to the same file. i am aware that sometimes log
messages could get mixed up, but no single one will get completely lost
(just eventually scattert if its a really big one).

for now we overloaded that function in our project. thanks!

----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2007-04-28 14:50

Message:
Logged In: YES 
user_id=308438
Originator: NO

Since there is no interprocess synchronisation in Python, writing to the
same logging file from multiple processes is not supported. If you want
output from multiple processes to end up in the same file, have all your
processes send logging events to a SocketHandler, and set up a separate
socket receiver (which could be in one of the processes) to receive the
events and log to file. A working example is given here:

http://docs.python.org/lib/network-logging.html

Note that even if the system was changed to use 'a' rather than 'w', this
would not eliminate potential problems with e.g. data in unflushed buffers,
etc.

----------------------------------------------------------------------

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-28 03:40

Message:
Logged In: YES 
user_id=33168
Originator: NO

This sounds like a logging module issue.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1708538&group_id=5470


More information about the Python-bugs-list mailing list