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 eric.snow
Recipients LewisGaul, crusaderky, eric.snow
Date 2019-11-25.17:20:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1574702441.4.0.783500846674.issue37292@roundup.psfhosted.org>
In-reply-to
Content
In the meantime that leaves the workarounds that @crusaderky originally identified.  You could also:

* manually run __main__ in the subinterpreter first (sort of like multiprocessing does automatically); this works because the namespace of __main__ is not reset for each run_string() call
* (for -m) update __module__ of the relevant objects to be the actual module name rather than "__main__"

In the case of that second point, it relates to PEP 499 (which will ensure that the module is added to sys.modules in the -m case).  However, that PEP doesn't say anything about updating __module__ for objects.  I'll bring that up there.  With that solution the problem in this issue would go away.

Note that it won't help for objects in the __main__ of subinterpreters, since they do not correspond to executed modules.  Hmm, maybe it could still work...

Regardless, I'll open issues over on https://github.com/ericsnowcurrently/multi-core-python to track these possible future enhancements.
History
Date User Action Args
2019-11-25 17:20:41eric.snowsetrecipients: + eric.snow, crusaderky, LewisGaul
2019-11-25 17:20:41eric.snowsetmessageid: <1574702441.4.0.783500846674.issue37292@roundup.psfhosted.org>
2019-11-25 17:20:41eric.snowlinkissue37292 messages
2019-11-25 17:20:40eric.snowcreate