Eric Snow <ericsnowcurren...@gmail.com> added the comment:

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.

----------

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

Reply via email to