-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-130094: Fix race conditions in importlib
#130101
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
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_specimportlib
|
@colesbury With the latest commits I see no problems any more. I created a unit test for this issue based on The test works, but is a bit slow. If I reduce the number of iterations (so that total running time is less than 0.1), odds of triggering the problem are rather low. |
Co-authored-by: Brett Cannon <[email protected]>
Entries may be added or removed from
sys.meta_pathconcurrently. For example, setuptools temporarily adds and removes thedistutilsfinder from the beginning of the list. The local copy ensures that we don't skip over any entries.Some packages modify
sys.modulesduring import. For example,collectionsinserts the entry forcollections.abcintosys.modulesduring import. We need to ensure that we re-checksys.modulesafter the parent module is fully initialized.