Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
Logging in __del__()
 

Index | Next | Previous | View Flat


robert.rawlins at thinkbluemedia

Jul 15, 2008, 4:32 AM


Views: 133
Permalink
Logging in __del__()

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

Subject User Time
Logging in __del__() robert.rawlins at thinkbluemedia Jul 15, 2008, 4:32 AM
    Re: Logging in __del__() fredrik at pythonware Jul 15, 2008, 4:42 AM
        RE: Logging in __del__() robert.rawlins at thinkbluemedia Jul 15, 2008, 5:51 AM
    Re: Logging in __del__() vinay_sajip at yahoo Jul 15, 2008, 6:56 AM
    RE: Logging in __del__() robert.rawlins at thinkbluemedia Jul 16, 2008, 4:38 AM
    Re: Logging in __del__() bj_666 at gmx Jul 16, 2008, 7:35 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.