This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: logging.handlers.RotatingFileHandler missing error handling
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: sdahlbac, vinay.sajip
Priority: normal Keywords:

Created on 2004-07-21 09:40 by sdahlbac, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg21735 - (view) Author: Simon Dahlbacka (sdahlbac) Date: 2004-07-21 09:40
If i open('logfile','r') in one shell and in my program
use a RotatingFileHandler using the same 'logfile', then 

os.rename(self.baseFilename, dfn) # line 86 in handlers.py

will fail and no log open, thus subsequent logging
attempts will  trigger a ValueError and render the
application in an unusable state.
(File "C:\Python23\lib\logging\handlers.py", line 103,
in emit
    self.stream.seek(0, 2)  #due to non-posix-compliant
Windows feature
ValueError: I/O operation on closed file)

I would have created a patch, but I am unsure of what
the correct behaviour should be?

- one possibility would be to continue logging to the
same file (skip rollover), but that is not ideal behaviour
msg21736 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2004-07-22 11:18
Logged In: YES 
user_id=308438

Unfortunately, there is no ideal behaviour. There is a "fix" for 
this problem in CVS - the handler calls handleError() if an 
exception is raised during emitting. If raiseExceptions is true, 
the exception is propagated up. If not, the exception is 
swallowed silently. There is no one universally agreed way of 
dealing with something like this - the best approach is for the 
application developer to provide custom handling via an 
overridden handleError() method in a derived handler class.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40609
2004-07-21 09:40:57sdahlbaccreate