[issue37292] _xxsubinterpreters: Can't unpickle objects defined in __main__

Nick Coghlan report at bugs.python.org
Sun Dec 15 07:46:28 EST 2019


Nick Coghlan <ncoghlan at gmail.com> added the comment:

There's a reason multiprocessing in spawn mode jumps through the hoops that it does: it's the only way to get __main__ pickling to work when you're not forking the entire process.

You also don't want to naively re-run __main__ in the subprocess for the same reason multiprocessing doesn't: doing so would also re-run the script parts, not just the class and function definition parts.

So while I don't think it should be implicit the way it is for multiprocessing spawn mode, I do think it would make sense to offer a way to explicitly opt-in to re-running __main__ in a child interpreter as "__si_main__", aliasing the subinterpreter's __main__ module to that, and also aliasing "__si_main__" to "__main__" in the parent interpreter.

----------
nosy: +ncoghlan

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37292>
_______________________________________


More information about the Python-bugs-list mailing list