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.shutdown() exception
Type: Stage:
Components: Extension Modules Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: jvickroy, vinay.sajip
Priority: normal Keywords:

Created on 2003-11-14 15:38 by jvickroy, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
t_xb.py jvickroy, 2003-11-14 15:38 a script that demonstrates the problem
Messages (2)
msg18998 - (view) Author: j vickroy (jvickroy) Date: 2003-11-14 15:38
Python version:
Python 2.3 (#46, Jul 29 2003, 18:54:32) [MSC v.1200 
32 bit (Intel)] on win32

Operating System:
MS Windows 2000 Professional with all latest patches

Synopsis:

When reassigning a handler (RotatingFileSystem) to a 
logger during execution, close() must be invoked against 
the current handler.  Failure to do so causes the 
following exception to be raised:

 Traceback (most recent call last):
   File
 "C:\Python23\lib\site-
packages\Pythonwin\pywin\framework\scriptutils.py",
 line 310, in RunScript
     exec codeObject in __main__.__dict__
   File "E:\$PROJECTS\experimental\Py Logging\t_xc.py", 
line 61, in ?
     log.error('testing Python logging module')
   File "C:\Python23\lib\logging\__init__.py", line 923, in 
error
     apply(self._log, (ERROR, msg, args), kwargs)
   File "C:\Python23\lib\logging\__init__.py", line 994, in 
_log
     self.handle(record)
   File "C:\Python23\lib\logging\__init__.py", line 1004, in 
handle
     self.callHandlers(record)
   File "C:\Python23\lib\logging\__init__.py", line 1037, in 
callHandlers
     hdlr.handle(record)
   File "C:\Python23\lib\logging\__init__.py", line 592, in 
handle
     self.emit(record)
   File "C:\Python23\lib\logging\handlers.py", line 105, in 
emit
     self.doRollover()
   File "C:\Python23\lib\logging\handlers.py", line 90, in 
doRollover
     os.rename(self.baseFilename, dfn)
 OSError: [Errno 13] Permission denied

If close() is applied to each handler, except the final 
assigned handler, then logging.shutdown() raises the 
following exception when it is applied prior to application 
termination:

Traceback (most recent call last):
  File "D:\$PROJECTS\experimental\Py Logging\t_xb.py", 
line 63, in ?
    shutdown()
  File "C:\Python23\lib\logging\__init__.py", line 1195, in 
shutdown
    h.flush()
  File "C:\Python23\lib\logging\__init__.py", line 661, in 
flush
    self.stream.flush()
ValueError: I/O operation on closed file

apparently, because it is attempting to close previously-
closed handlers.

Please, see attachment for a relevant script.

If it is agreed that this is an appropriate use of the 
logging system (and I think it is <smile>), I would be 
willing to attempt a patch if that is preferable.

Thanks for your time.
msg18999 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2004-02-20 17:56
Logged In: YES 
user_id=308438

Problem was caused because shutdown() tried to close 
already closed handlers.

Solved by close() removing handler from an internal list which 
is used by shutdown().

Fixed in CVS.
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39549
2003-11-14 15:38:54jvickroycreate