__del__ doesn't work
Peter Abel
PeterAbel at gmx.net
Sun Feb 15 14:41:07 EST 2004
More information about the Python-list mailing list
Sun Feb 15 14:41:07 EST 2004
- Previous message (by thread): __del__ doesn't work
- Next message (by thread): __del__ doesn't work
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I have an application, which is an instance of a class with a deeply nested object hierarchy. Among others one method will be executed as a thread, which can be stopped. Everything works fine except that when deleting the main instance - after the thread has been stopped - the __del__ method will not be carried out. Tough a simple example works as expected: >>> class A: ... def __init__(self): ... print 'Constructor of A()' ... def __del__(self): ... print 'Destructor of A()' ... >>> a=A() Constructor of A() >>> del a Destructor of A() After all I know I can't expect that the __del__ method is executed imediatly when deleting the instance e.g. "del a" as in the example. But the statements import gc and gc.collect() should assure that when the reference counter goes to zero some time the __del__ method is executed. But it never does. So am I expecting something wrong or am I doing something not in the right way? The code is too complex to post it here or even a snippet. But I think it's not a matter code but a matter of philosophy that I may not have understood. Any help would be appreciated. Regards Peter
- Previous message (by thread): __del__ doesn't work
- Next message (by thread): __del__ doesn't work
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list