Solution to finalisation problem [Re: fork()]

Greg Ewing greg.ewing at compaq.com
Thu Jun 17 02:14:14 CEST 1999


Graham Matthews wrote:
> 
> All
> objects will be in a state in which they can be finalised in pass 1 since
> nothing is deleted in pass 1. I don't see the problem here at all.

I think what we need at this point is some concrete examples.
What sorts of things do people actually *do* with __del__
methods at the moment?

As far as I can see, the only thing you really need a
finalizer for is freeing an external resource. (The only
non-external resource is memory, and the GC takes care
of that.)

If each external resource is wrapped up in an object which
encapsulates everything needed to identify that resource,
then that object can have a finaliser which does its job
without caring about the state of any other object.

The only way I can see that the 2-pass collection scheme
can fail is if the finaliser of object A destroys something
needed by the finaliser of object B. But if each object
having a finaliser looks after just one external resource,
how can that happen?

Anyone have a real-world example?

Greg




More information about the Python-list mailing list