[Python-Dev] finalization again

Moshe Zadka Moshe Zadka <mzadka@geocities.com>
Fri, 10 Mar 2000 07:32:41 +0200 (IST)


On Thu, 9 Mar 2000, Greg Stein wrote:

> > But I'd still like to reclaim the memory.  If this is some
> > long-running server process that is executing arbitrary Python
> > commands sent to it by clients, it's not nice to leak, period.
> 
> If an exception is raised, the top-level server loop can catch it, log the
> error, and keep going. But yes: it will leak.

And Tim's version stops the leaking if the server is smart enough:
occasionally, it will call gc.get_dangerous_cycles(), and nuke everything
it finds there. (E.g., clean up dicts and lists). Some destructor raises
an exception? Ignore it (or whatever). And no willy-nilly "but I'm using a
silly OS which has hardly any concept of stderr" problems! If the server
wants, it can just send a message to the log.

rooting-for-tim-ly y'rs, Z.
--
Moshe Zadka <mzadka@geocities.com>. 
http://www.oreilly.com/news/prescod_0300.html