Message218620
| 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:49 | pitrou | set | recipients:
+ pitrou, benjamin.peterson, ryder.lewis |
| 2014年05月15日 18:11:49 | pitrou | set | messageid: <1400177509.13.0.360502811535.issue21512@psf.upfronthosting.co.za> |
| 2014年05月15日 18:11:49 | pitrou | link | issue21512 messages |
| 2014年05月15日 18:11:48 | pitrou | create |
|