errors in _del__ during python shutdown
Michael Hudson
mwh21 at cam.ac.uk
Mon Apr 3 12:25:47 EDT 2000
gidi_avrahami at my-deja.com writes:
> I have a large Python system with wrappers to some SWIG'ed C code.
> Some objects need to do some cleanup in their __del__ , e.g.:
>
> from myBasics import Object
> import myCToolkit
> kit = myCToolkit
>
> class SomeObject(Object):
> def __init__(self, *args):
> Object.__init__(self, *args)
> self._vec = kit.float_array(6)
> def __del__(self):
> kit.float_destroy(self._vec)
> Object.__del__(self)
>
> My problem is that when I shut python down (by typing EOF to the prompt), the
> SomeObject.__del__ method gets called in a funny state, where 'kit' and even
> 'Object' are None! It would appear that Python is "winding down" and starts
> killing off modules, even though some objects that refer to these modules
> are still alive.
>
> Any ideas?
Do this:
def __del__(self,kit=kit,Object=Object):
kit.float_destroy(self._vec)
Object.__del__(self)
must be a FAQ, but I can't be bothered to track the entry down just
now, sorry.
Cheers,
M.
--
well, take it from an old hand: the only reason it would be easier
to program in C is that you can't easily express complex problems
in C, so you don't. -- Erik Naggum, comp.lang.lisp
More information about the Python-list
mailing list