You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thread_unsafe_import.py: set env var PICK_API=N with N in {0,1} to demonstrate thread unsafe import and N=2 for expected behaviour
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2021-03-29.16:53:01.049>labels= ['type-bug', '3.8', '3.9', '3.10', '3.7', 'docs']
title='implementations of the deprecated load_module import loader API, as prescribed by the documentation, are not thread safe'updated_at=<Date2021-03-29.16:53:01.049>user='https://github.com/kale-smoothie'
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.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: