On 04/13/2017 11:21 PM, Tim Serong wrote: > On 04/11/2017 09:17 PM, John Spray wrote: >> Doing separate sub-interpreters would also be an option that would >> give us more robustness generally in the face of python modules that >> do global things. I don't think there was any fundamental reason I >> didn't use sub-interpreters when writing this stuff originally, >> they're just a comparatively sparesely documented part of CPython. > > I think I'm liking the second option for general robustness. My best > guess right now is that's probably adding a Py_NewInterpreter() call to > MgrPyModule's constructor, and PyThreadState_Swap()s in its methods so > the right thread state is active at the right time. I reckon this'll > require some other rejigging in various places though -- note how > https://docs.python.org/2/c-api/init.html#bugs-and-caveats says that > combining sub-interpreters with the PyGILState_*() APIs "is delicate", > and further up it flat out states "The following functions use > thread-local storage, and are not compatible with sub-interpreters: > PyGILState_Ensure() ... PyGILState_Release()..." etc. > > Given the sparseness of the docs it's probably best to just try it and > see what catches on fire. I'll keep you posted. Coming back to this again, just for the record I've got something that seems to work: https://github.com/ceph/ceph/pull/14971 Note that this should be considered experimental until further notice :-) but is hopefully promising. Cheers, Tim -- Tim Serong Senior Clustering Engineer SUSE tserong@xxxxxxxx -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html