[Python-Dev] Better module shutdown procedure
Neil Schemenauer
nas at arctrix.com
Wed Oct 14 23:42:30 CEST 2009
On Wed, Oct 14, 2009 at 04:13:12PM -0500, Daniel Stutzbach wrote:
> Based on the description, it still resorts to zapping module globals by
> setting them to None. It zaps them to weakrefs first, which means that
> globals are more likely to be valid during __del__, but it still cannot make
> any guarantees and referencing globals from __del__ is still a bad idea. Is
> that a correct synopsis?
Yes, it does still resort to setting globals to None. However, the
weakref step makes it much more likely that __del__ methods run
before that happens. After this change, referencing global variables
from __del__ methods is okay. What is not a good idea is creating
__del__ methods that are part of a reference cycle (i.e. an island
of references) and also refer to that cycle somehow. That has never
been a good idea and those __del__ methods will never get run,
before or after the proposed change.
HTH,
Neil
More information about the Python-Dev
mailing list