circular references?
Roy Smith
roy at popmail.med.nyu.edu
Sat Dec 18 12:34:12 EST 1999
To follow up on my own question, I've changed my main loop to look
something like:
[code to set func to the right subclass]
page = apply (func, (self,))
page.show()
page.cleanup()
The page.cleanup() call is the new part, and the last thing to get
executed before page drops out of scope (i.e. the enclosing function
returns). Cleanup just breaks the circular references:
class new_domain (netdbpage):
def cleanup (self):
self.record_set = None
netdbpage.cleanup (self)
This makes everything work fine. However, I'm still mystified as to the
behavior I was observing. I can understand the memory leak problem, but
not the i/o problem. I sure would like to know what was going on for
real, but I'll admit that not understanding why my code works sure beats
not understanding why it doesn't :-)
BTW, is there any functional difference between "self.record_set = None"
and "del self.record_set", if the object in question is about to go out
of scope anyway? FAQ 4.17 says, "Normally, deleting (better: assigning
None to) sys.exc_traceback will take care of this". Why, in that
situation, the preference of one over the other?
More information about the Python-list
mailing list