-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-130094: Fix race conditions in importlib
#130101
base: main
Are you sure you want to change the base?
Conversation
Entries may be added or removed from `sys.meta_path` concurrently. For example, setuptools temporarily adds and removes the `distutils` finder from the beginning of the list. The local copy ensures that we don't skip over any entries.
This does not resolve the issue for me, although it is more difficult to trigger now. It is a bit hard to determine what is going wrong as adding simple The error I get is now always in
A minimal reproducer (no exeternal packages involved now):
When running the minimal example with a batch file 80 times, the issue is triggered with very high probability. |
_find_spec
_find_spec
@eendebakpt - I fixed another race condition. Would you please try again? |
_find_spec
importlib
Entries may be added or removed from
sys.meta_path
concurrently. For example, setuptools temporarily adds and removes thedistutils
finder from the beginning of the list. The local copy ensures that we don't skip over any entries.'Some packages modify
sys.modules
during import. For example,collections
inserts the entry forcollections.abc
intosys.modules
during import. We need to ensure that we re-checksys.modules
after the parent module is fully initialized.