This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients chn, eric.snow, grahamd, loewis, pitrou, python-dev, r.david.murray, terry.reedy
Date 2012-01-18.10:56:48
SpamBayes Score 6.41647e-08
Marked as misclassified No
Message-id <1326884100.3395.7.camel@localhost.localdomain>
In-reply-to <>
> That said, for mod_wsgi I have extended sub interpreter destruction so
> that atexit callbacks registered in sub interpreters are called. For
> mod_wsgi though, sub interpreters are only destroyed on process
> shutdown. For the general case, a sub interpreter could be destroyed
> at any time during the life of the process. If one called atexit
> callbacks on such sub interpreter destruction, it notionally changes
> the meaning of atexit, which is in process exit and not really sub
> interpreter exit.

Well the atexit docs say "Functions thus registered are automatically
executed upon normal interpreter termination".

My reasoning is:
- atexit functions are already called at interpreter destruction (*),
not at process shutdown. If you call Py_Initialize and Py_Finalize
several times in a row, you will have several atexit calls.

- registering a function in an interpreter and calling it in another is
undefined and potentially dangerous. That function can for example refer
to global objects which are different from the calling interpreter's
global objects. These objects or their internal structures could have
become invalid when the sub-interpreter was shut down.

I expect uses of sub-interpreters to be quite rare apart from mod_wsgi,
so following mod_wsgi makes sense IMO.

(*) note atexit functions are even called *before* module globals are
garbage collected. It's quite early in the cleanup phase.
Date User Action Args
2012-01-18 10:56:49pitrousetrecipients: + pitrou, loewis, terry.reedy, grahamd, r.david.murray, python-dev, eric.snow, chn
2012-01-18 10:56:48pitroulinkissue6531 messages
2012-01-18 10:56:48pitroucreate