Guys,
I'm trying to help trace when instances of particular classes are being
destroyed by the garbage collector and thought the cleanest way would be to
implement a logging call in __del__() on the class. However, I'm having an
issue.
I inject a logger instance into my class upon construction and set it to
self.logger, I then use this within the class to log actions going on
within, works fine.
Now, when I make the call in the __del__() method like so:
def __del__(self):
# Log the classes destruction.
self.logger.debug("Class Instance Destroyed")
I then get the following exception thrown when running my code:
Traceback (most recent call last):
File "/usr/lib/python2.5/logging/handlers.py", line 73, in emit
if self.shouldRollover(record):
File "/usr/lib/python2.5/logging/handlers.py", line 147, in shouldRollover
self.stream.seek(0, 2) #due to non-posix-compliant Windows feature
ValueError: I/O operation on closed file
Does anyone have any ideas as to what I'm doing wrong here? Is this a known
issue which has a neat little work around?
Cheers,
Robert
--
http://mail.python.org/mailman/listinfo/python-list