I wonder if they ever fixed the CPickle bug which broke it if you were using CPickle from multiple threads.
I wonder if they ever fixed the CPickle bug which broke it if you were using CPickle from multiple threads.
my_foo = interpreterX.pass_object(my_foo)
(The assignment being required to delete the originating reference from the source interpreter.) The interface would be obligated to check that there are no references that escape to the current interpreter and then my_foo and all referenced objects could be handed off to the other interpreter in whole.I don't have any intuitions for if that would be cheaper than copying or not, and getting it right is certainly more difficult than serialization. (Because of the complexity, it's not worth having if it isn't cheaper.)
It's not a theoretical problem, just a very likely pragmatic observation. (Meaning, we'll see bugs in both the interpreter and the code using this feature.)
Plus if one of the threads crashes, the whole process aborts. (Sure, the interpreter can handle a lot of faults gracefully, but not all.)
I'm not claiming any originality here — the author of the article recognizes this problem and describes it, starting with:
> Because CPython has been implemented with a single interpreter for so long, many parts of the code base use the “Runtime State” instead of the “Interpreter State”, so if PEP554 were to be merged in it’s current form there would still be many issues.
There is nothing preventing you from adding this support to an existing dynamic linker and using it for your program, though.
This is supported in ld-linux by using the dlmopen() glibc function and distinct namespaces. Loading the same .so file multiple times is one of the use cases explicitly mentioned in the manual page[1].
[1]: http://man7.org/linux/man-pages/man3/dlmopen.3.html#NOTES
One caveat seems to be:
> The glibc implementation supports a maximum of 16 namespaces.