[Python-Dev] module shutdown procedure

Georg Brandl g.brandl at gmx.net
Thu Jul 22 16:13:49 CEST 2010


Am 22.07.2010 13:29, schrieb Antoine Pitrou:
> Le jeudi 22 juillet 2010 à 07:23 -0500, Benjamin Peterson a écrit :
>> 2010/7/22 Antoine Pitrou <solipsis at pitrou.net>:
>> > On Thu, 22 Jul 2010 08:51:57 +0100
>> > Brett Cannon <brett at python.org> wrote:
>> >>
>> >> That's an option. I just remember Tim bringing up something about that
>> >> approach that didn't quite work as a complete replacement for __del__.
>> >>
>> >> Basically the whole setting a module's globals to None was done before gc
>> >> came into the language. Now that it's there it seems that it might work to
>> >> simply let gc clean up the module itself.
>> >
>> > There is a patch at http://bugs.python.org/issue812369 for GC-based
>> > module shutdown, but it doesn't actually remove the setting of module
>> > globals to None. I think further testing and experimentation would be
>> > required to validate it.
>> 
>> Also, it seems to have been stalled by static globals in extension
>> modules that the gc doesn't know about.
> 
> Is it the reason why? With the new module creation API in 3.x, extension
> modules should be able to handle deletion of their own internal
> resources.

Yes, but as Martin noted at the summit, nobody since went through all the
extension modules and changed them to use a struct instead of globals.

Georg

-- 
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.



More information about the Python-Dev mailing list