[Python-Dev] Better module shutdown procedure (original) (raw)

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