31 Dec
2012
31 Dec
'12
5:35 p.m.
On 30/12/2012 9:52pm, Antoine Pitrou wrote:
If you have an object with a __del__ method as a module global, the cyclic gc will refuse to consider the module globals at all (which means it will affect unrelated objects).
So, yes, I think the shutdown purge is still necessary. Perhaps there are ways to make it smarter.
With my earlier suggestion a module deleted from sys.modules before shutdown can have an unreclaimable global dict (if it contains a global with a __del__ method). Perhaps, instead, modules could use a weakrefable subclass of dict for their globals dicts. The module destructor could save the global dicts of deleted modules in a registry. At shutdown any remaining globals dicts can be purged. -- Richard