On Tue, 16 Jan 2018 17:18:06 -0800 Nathaniel Smith <njs@pobox.com> wrote:
On Tue, Jan 16, 2018 at 5:06 PM, Yury Selivanov <yselivanov.ml@gmail.com> wrote:
I think it would be a very fragile thing In practice: if you have even one variable in the context that isn't pickleable, your code that uses a ProcessPool would stop working. I would defer Context pickleability to 3.8+.
There's also a more fundamental problem: you need some way to match up the ContextVar objects across the two processes, and right now they don't have an attached __module__ or __qualname__.
They have a name, though. So perhaps the name could serve as a unique identifier? Instead of being serialized as a bunch of ContextVars, the Context would then be serialized as a {name: value} dict. Regards Antoine.