homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients benjamin.peterson, pitrou, ryder.lewis
Date 2014年05月15日.18:11:48
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1400177509.13.0.360502811535.issue21512@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2014年05月15日 18:11:49pitrousetrecipients: + pitrou, benjamin.peterson, ryder.lewis
2014年05月15日 18:11:49pitrousetmessageid: <1400177509.13.0.360502811535.issue21512@psf.upfronthosting.co.za>
2014年05月15日 18:11:49pitroulinkissue21512 messages
2014年05月15日 18:11:48pitroucreate

AltStyle によって変換されたページ (->オリジナル) /