[Tutor] Python __del__ method

Steven D'Aprano steve at pearwood.info
Tue Jul 11 20:54:33 EDT 2017


On Tue, Jul 11, 2017 at 07:34:16PM -0500, boB Stepp wrote:
> On Tue, Jul 11, 2017 at 7:24 PM, Alan Gauld via Tutor <tutor at python.org> wrote:

> I am assuming that when the OP ran his code from a file, that upon the
> script's completion, both object instances were garbage collected.
> Surely upon program completion, everything _is_ garbage collected?

Yes. But some things might not be garbage collected until the shut down 
process has already started garbage collecting other modules and code 
that your __del__ method relies on.

I believe that __del__ has become more reliable recently and will now be 
successfully called in situations that it didn't previously be called, 
but the interation of garbage collectors with destructor methods is 
still fraught with difficulties.


-- 
Steve


More information about the Tutor mailing list