Re: Resource cleanup

2006-12-03 Thread Robin Becker
Diez B. Roggisch wrote: ... >> >> I have a vague feeling that I came across problems in the past about >> the order in which modules were finalized. > > I'm a bit on unsure ground here - so take it with a grain of salt. > > It is for sure that only executing code will refer to a global - the

Re: Resource cleanup

2006-12-03 Thread Diez B. Roggisch
> but am wondering exactly what 'resources' are left available when the > r.close method is called in the __del__ method of RealTypeResourceCleaner. > > In particular, can I rely on the module globals of r still being present > if the RealType instance is going away because the main script has

Resource cleanup

2006-12-03 Thread Robin Becker
I'm thinking of using Tim Peters' excellent approach to resource clean up see http://mail.python.org/pipermail/python-dev/2006-April/063425.html > class _RealTypeResourceCleaner: > def __init__(self, *resources): > self.resources = resources > > def __del__(self): > if s