This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brett.cannon
Recipients George3d6, brett.cannon, eric.snow, ncoghlan, steven.daprano
Date 2021-08-16.16:35:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629131741.18.0.710306407231.issue44916@roundup.psfhosted.org>
In-reply-to
Content
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".
History
Date User Action Args
2021-08-16 16:35:41brett.cannonsetrecipients: + brett.cannon, ncoghlan, steven.daprano, eric.snow, George3d6
2021-08-16 16:35:41brett.cannonsetmessageid: <1629131741.18.0.710306407231.issue44916@roundup.psfhosted.org>
2021-08-16 16:35:41brett.cannonlinkissue44916 messages
2021-08-16 16:35:41brett.cannoncreate