__del__ and logging

flupke flupke at nonexistingdomain.com
Fri Apr 29 03:45:05 EDT 2005


Hi,

i have a class and a class attribute log which is a logger object. In 
the __del__() function i want to log a message but it fails even if i 
use self.__class__.log.

The error i get is this:
Traceback (most recent call last):
   File "C:\Python24\lib\logging\__init__.py", line 712, in emit
     self.stream.write(fs % msg)
ValueError: I/O operation on closed file

So is there no way to use the logger object in a __del__
I wanted to use the message to clearly indicate in the logger file that 
the instance had closed ok.

Regards,
Benedict



More information about the Python-list mailing list