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 kale-smoothie
Recipients docs@python, kale-smoothie
Date 2021-03-29.16:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1617036781.07.0.980162704543.issue43658@roundup.psfhosted.org>
In-reply-to
Content
Unless I've misread or misunderstood, the documentation at https://docs.python.org/3/reference/import.html#loaders for the deprecated `load_module` method doesn't indicate any requirements or caveats for thread safe importing. As it stands, I think it is not thread-safe, since the module is not protected against concurrent imports by the internal implementation marker `__spec__._initializing = True`.

Additionally, the deprecated function decorator, `importlib.util.module_for_loader` seems to implement the marker incorrectly (sets `__initializing__` directly on the module).

I think this behaviour should either be documented as a major caveat, or internal details exposed to allow thread-safe implementations, or the old API removed entirely.
History
Date User Action Args
2021-03-29 16:53:01kale-smoothiesetrecipients: + kale-smoothie, docs@python
2021-03-29 16:53:01kale-smoothiesetmessageid: <1617036781.07.0.980162704543.issue43658@roundup.psfhosted.org>
2021-03-29 16:53:01kale-smoothielinkissue43658 messages
2021-03-29 16:53:00kale-smoothiecreate