__del__ not working with cyclic reference?
aahz at pythoncraft.com
Wed Jul 2 06:04:02 CEST 2003
In article <ba1e306f.0307011837.269e3d2a at posting.google.com>,
Jane Austine <janeaustine50 at hotmail.com> wrote:
>I have some code using singleton pattern. The singleton instance
>is shared as a class variable. The problem is that the singleton
>instance is not cleared automatically.
>Following is a simplified version that shows the problem:
> def __del__(self):
> print "FooBar removed"
>Why is this so? Due to the cyclic reference? Isn't python's gc
>supposed to treat it? What singleton idiom is recommended
There are two issues that you'll run into with this: gc doesn't work on
classes that define __del__(), and prior to Python 2.3, gc doesn't run
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
Usenet is not a democracy. It is a weird cross between an anarchy and a
More information about the Python-list