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 sbt
Recipients brett.cannon, sbt
Date 2013-02-27.23:20:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1362007235.68.0.36863909855.issue17314@psf.upfronthosting.co.za>
In-reply-to
Content
I think this change will potentially make the main module get imported twice under different names when we transfer pickled data between processes.  The current code (which is rather a mess) goes out of its way to avoid that.

Basically the main process makes sys.modules['__mp_main__'] an alias for the main module, and other process import the parent's main module with __name__ == '__mp_main__' and make sys.modules['__main__'] an alias for that.  This means that any functions/classes defined in the main module (from whatever process) will have

    obj.__module__ in {'__main__', '__mp_main__'}

Unpickling such an object will succeed in any process without reimporting the main module.

Attached is an alternative patch which is more like the original code and seems to work.  (Maybe modifying loader.name is an abuse of the API.)
History
Date User Action Args
2013-02-27 23:20:35sbtsetrecipients: + sbt, brett.cannon
2013-02-27 23:20:35sbtsetmessageid: <1362007235.68.0.36863909855.issue17314@psf.upfronthosting.co.za>
2013-02-27 23:20:35sbtlinkissue17314 messages
2013-02-27 23:20:35sbtcreate