Reliably call code after object no longer exists or is "unreachable"?
drsalists at gmail.com
Thu Apr 28 03:11:57 CEST 2011
On Wed, Apr 27, 2011 at 5:54 PM, Thomas 'PointedEars' Lahn <
PointedEars at web.de> wrote:
> Jack Bates wrote:
> > Faced with the real potential for reference cycles, how can you reliably
> > call code - but wait until an object no longer exists or is
> > "unreachable"?
> For normal program termination, the solution is the `atexit' module (as
> e.g. in <
> management-with-autoclose/>, however it is considered better style to
> explicitly call methods that free resources, and `del' object references.
> As for abnormal program termination, I think there is no way to deal with
> signals that signal.signal() cannot handle.
Sometimes __enter__, __exit__ and "with" combine well for such a purpose,
depending on what the actual purpose is.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list