[Python-Dev] Better module shutdown procedure

Neil Schemenauer nas at arctrix.com
Fri Oct 16 03:06:59 CEST 2009

On Wed, Oct 14, 2009 at 02:16:35PM -0600, Neil Schemenauer wrote:
> The procedure implemented by http://bugs.python.org/issue812369
> seems to be a better idea.

After some experimentation I realize this idea is not ready yet.
The main problem comes from references to Python objects that
modules keep but don't expose to the garbage collector. For example,
gcmodule.c has a static pointer "tmod" that is a reference to the
"time" module. This reference prevents the "time" module from being
freed during interpreter shutdown.

Ideally, I suppose modules should be treated like any other object
and have tp_traverse and tp_clear methods that deal with these sorts
of pointers. They would have to delegated to the instance since each
module would have its own implementation.


More information about the Python-Dev mailing list