Hi F.e.,
I wonder if there's a way for pyext to know it's deleted, in order, for example, to remove previously created temp files before it's killed...
yes there is. Just define a _del(self) method in your pyext class. It gets called when the object is deleted.
greetings, Thomas
Hallo, Thomas Grill hat gesagt: // Thomas Grill wrote:
Just define a _del(self) method in your pyext class. It gets called when the object is deleted.
How does thie pyext._del relate to the more general __del__ method? Is it save to use the latter? I know, that __del__ also is called on delete, but I guess, using _del could be a cleaner solution?
Frank Barknecht _ ______footils.org_ __goto10.org__
Hi Frank,
How does thie pyext._del relate to the more general __del__ method? Is it save to use the latter? I know, that __del__ also is called on delete, but I guess, using _del could be a cleaner solution?
__del__ is called when the reference count of a Python object goes to zero and the object is destroyed by the garbage collector. With pyext i encountered circumstances where __del__ was delayed or never called (e.g. on reload), although i didn't find a memory leak. That's why i introduced an explicit call of a _del method. Normally __del__ will also be called afterwards, but you can never be sure....
greetings, Thomas