On Jan 7, 12:42 pm, Eric Snow <es...@verio.net> wrote: > I was reading in the documentation about __del__ and have a couple of > questions. Here is what I was looking at: > > http://docs.python.org/reference/datamodel.html#object.__del__ > > My second question is about the following: > > "It is not guaranteed that __del__() methods are called for objects > that still exist when the interpreter exits." > > I understand that and have seen it too. That's fine. But how do any > of you deal with things that are left open because you did not get a > chance to close them? How do you clean up after the fact? Do you > simply keep track externally the things that need to be cleaned up if > __del__ doesn't get a chance? Any ideas? Thanks > > -eric
So I see a couple of options here. Thanks for all the suggestions everyone. Here is what I have: - use try/finally to clean things up - set a handler using signal.signal to clean everything up There is also having try/except for more specific behvaior, like for KeyboardInterrupt, but I am not sure I need that much specificity. Again, thanks for all the great help. Really cleared things up for me. -eric -- http://mail.python.org/mailman/listinfo/python-list