__del__ not called?
g.horvath at gmx.at
Mon Mar 13 09:50:02 CET 2006
Duncan Booth schrieb:
> What is less obvious is that new style classes always include circular
> references, so a class is never detroyed until the garbage collector runs.
Thanks. I tried the same example with old style classes and A.__del__
gets correctly called.
> Of course, if your __del__ method actually does get invoked during program
> exit you have to be pretty careful what you do: the chances are any global
> variables you used in __del__ have already been destroyed in particular any
> modules you imported may have been deleted. In short, don't rely on
> anything much being possible from __del__ called this way.
I wanted to close a database connection, which is opend by __init__.
But what happens to my database connection (instance attributes of A)
when __del__ is never called?
More information about the Python-list