Brett Cannon <br...@python.org> added the comment:

So first, don't import from threads. It's non-deterministic as you have seen. 
You should do all imports **before** you start running multi-threaded code if 
multiple threads are going to access the 

Second, tossing in pickle is just asking for more trouble. 😉

The key thing to know is the master copy of a module is kept in `sys.modules`. 
But classes keep a reference to the module they were loaded from, not what 
`sys.modules` happens to have at that moment. So due to threading indeterminism 
it's quite possible to end up unpickling in such a way that the module that 
eventually ends up in `sys.modules` is not what your unpickled class is 
referencing.

As such, I'm closing as "wont fix".

----------
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue44916>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to