[issue31901] atexit callbacks only called for current subinterpreter

2017-11-08 Thread Graham Dumpleton
Graham Dumpleton added the comment: FWIW, that atexit callbacks were not called for sub interpreters ever was a pain point for mod_wsgi. What mod_wsgi does is override the destruction sequence so that it will first go through each sub interpreter when and shutdown threading explicitly, then

[issue31901] atexit callbacks only called for current subinterpreter

2017-11-08 Thread Petr Viktorin
Petr Viktorin added the comment: When you destroy a subinterpreter before Py_Finalize is called, Python can't start calling its atexit callbacks – they no longer have a subinterpreter to run in. Therefore I think callbacks for a particular subinterpreter should be called when (and only when)

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-31 Thread Petr Viktorin
Petr Viktorin added the comment: I'm not sure where the concept of "main subinterpreter" comes in, with respect to this issue. I thnik the issue of atexit callbacks could be solved by something like keeping info about each callback's subinterpreter, and switching subinterpreters before runni

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-31 Thread Nick Coghlan
Nick Coghlan added the comment: I guess we allow an unhandled SystemExit in a child thread to propagate to (and hence terminate) the main thread, so allowing a Py_Finalize call in a subinterpreter to terminate the main interpreter would be comparable to that. My main rationale for *requiring*

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-31 Thread Petr Viktorin
Petr Viktorin added the comment: I don't have a reason to think Py_Finalize is not *destroying* the other subinterpreters. But it's not calling their atexit callbacks. (Is there any reason Py_Finalize couldn't switch to the main interpreter itself? Assuming it's even necessary.) --

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-31 Thread Nick Coghlan
Nick Coghlan added the comment: For the main interpreter, Py_Finalize should be destroying all other subinterpreters as one of the first things it does, so if we're *not* currently doing that, it would make sense to fix it as part of Eric's subinterpreters PEP. -- ___

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-31 Thread Nick Coghlan
Nick Coghlan added the comment: Hmm, I don't think calling Py_Finalize in any interpreter other than the main one is actually defined at all, so I'm inclined to just make it an error, rather than trying to figure out how it should work. It would then be up to the embedding application to make

[issue31901] atexit callbacks only called for current subinterpreter

2017-10-30 Thread Marcel Plch
New submission from Marcel Plch : `Py_FinalizeEx()` only executes callbacks from the subinterpreter from which Py_FinalizeEx is called. What is the expected behavior here? Should the callbacks be specific to individual subinterpreters? -- components: Extension Modules messages: 305233