[issue21512] time module becomes None after raise SystemExit
Antoine Pitrou
report at bugs.python.org
Thu May 15 20:11:49 CEST 2014
Antoine Pitrou added the comment:
Well, let's call it a limitation rather than a bug.
When creating a global variable (such as "a" in your example), that variable is kept alive at least as long as the module containing it. However, modules usually live until very late in the interpreter shutdown process, *especially* the __main__ module. So, by the time "a" gets garbage-collected, other globals or modules may already have been wiped.
Unfortunately, I don't think there's much we can do to improve this. The answer to your specific problem is to use the atexit module instead, since an atexit callback is guaranteed to be called with a normal execution environment, before it starts being garbage-collected.
----------
status: pending -> open
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21512>
_______________________________________
More information about the Python-bugs-list
mailing list