termios disappears during object deletion
Fredrik Lundh
fredrik at pythonware.com
Sat Sep 4 05:22:07 EDT 1999
Brien Barton <brien_barton at hotmail.com> wrote:
> Can anyone explain this behavior?? For some reason, the termios and TERMIOS
> modules get wiped out when python is running the __del__ method during
> program termination. I've tried this with Python 1.5.1 on Linux and with
> Python 1.5.2 on SGI IRIX. If you explicitly delete the object, you don't
> have this problem.
>
> ~> cat test.py
> import math, termios, TERMIOS
>
> print 'math=', math
> print 'termios=', termios
> print 'TERMIOS=', TERMIOS
>
> class Test:
> def __del__(self):
> print 'deleting Test object ...'
> print 'math=', math
> print 'termios=', termios
> print 'TERMIOS=', TERMIOS
starting with 1.5.1, Python performs a relatively aggressive
cleanup when the interpreter is shut down:
http://www.python.org/doc/essays/cleanup.html
among other things, this means that destructors must hang
on to all global resources they are using, e.g.:
def __del__(self, math=math, termios=termios, TERMIOS=TERMIOS):
...
</F>
More information about the Python-list
mailing list