Vinay Sajip wrote: > flupke <flupke <at> nonexistingdomain.com> writes: > > >>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. >> > > > It all depends. If your __del__ is being called via atexit() for application > cleanup, for example, logging may not be available to you because it has been > cleaned up beforehand. > > The logging module registers an atexit() handler to flush and close handlers > before script termination. > > Vinay Sajip > >
Thanks i was able to solve it using a function registered in both the classes i used in that project. Why would one use __del__ instead of atexit then especially if the calls you make in __del__ are so unrelieable? Regards, Benedict -- http://mail.python.org/mailman/listinfo/python-list