Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-28 Thread Gregory Ewing
Jack Bates wrote: Python's __del__ or destructor method works (above) - but only in the absence of reference cycles (below). An object, with a __del__ method, in a reference cycle, causes all objects in the cycle to be "uncollectable". Store a weak reference to the object somewhere with a call

Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Dan Stromberg
On Wed, Apr 27, 2011 at 5:54 PM, Thomas 'PointedEars' Lahn < pointede...@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 termina

Re: Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Thomas 'PointedEars' Lahn
Jack Bates wrote: > Python's __del__ or destructor method works (above) - but only in the > absence of reference cycles (below). An object, with a __del__ method, > in a reference cycle, causes all objects in the cycle to be > "uncollectable". This can cause memory leaks and because the object is

Reliably call code after object no longer exists or is "unreachable"?

2011-04-27 Thread Jack Bates
In Python, how can you reliably call code - but wait until an object no longer exists or is "unreachable"? I want to ensure that some code is called (excluding some exotic situations like when the program is killed by a signal not handled by Python) but can't call it immediately. I want to wait un