<br><div class="gmail_quote">On Wed, Apr 27, 2011 at 5:54 PM, Thomas 'PointedEars' Lahn <span dir="ltr"><<a href="mailto:PointedEars@web.de">PointedEars@web.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">Jack Bates wrote:<br>
> Faced with the real potential for reference cycles, how can you reliably<br>
> call code - but wait until an object no longer exists or is<br>
> "unreachable"?<br>
<br>
</div>For normal program termination, the solution is the `atexit' module (as used<br>
e.g. in <<a href="http://code.activestate.com/recipes/523007-semi-automatic-resource-%0Amanagement-with-autoclose/" target="_blank">http://code.activestate.com/recipes/523007-semi-automatic-resource-<br>
management-with-autoclose/</a>>, however it is considered better style to<br>
explicitly call methods that free resources, and `del' object references.<br>
<br>
As for abnormal program termination, I think there is no way to deal with<br>
signals that signal.signal() cannot handle.<br></blockquote><div><br>Sometimes __enter__, __exit__ and "with" combine well for such a purpose, depending on what the actual purpose is.<br> <br></div></div>