[Python-Dev] PEP 442 aftermath: module globals at shutdown

Antoine Pitrou solipsis at pitrou.net
Wed Jul 31 08:21:50 CEST 2013


On Wed, 31 Jul 2013 13:30:58 +1200
Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
> Antoine Pitrou wrote:
> > - it is held alive through builtins: the site module patches builtins
> >   with additional objects, which themselves keep references to the site
> >   module's globals,
> 
> The module probably *should* stay alive in that case, since
> it's still accessible via those patched builtins.

Of course. I'm not gonna kill reachable modules like a cowboy on the
loose :-)
The problem is that its global objects will get finalized very late.

Anyway, the solution is to unpatch builtins through an atexit handler
in the site module.

(my patch still has a last step where surviving modules get their
globals wiped, though)

Regards

Antoine.




More information about the Python-Dev mailing list