Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
gh-130094: Fix race conditions inimportlib#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Entries may be added or removed from `sys.meta_path` concurrently. Forexample, setuptools temporarily adds and removes the `distutils`finder from the beginning of the list. The local copy ensures that wedon't skip over any entries.
eendebakpt commentedFeb 14, 2025
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_speccolesbury commentedFeb 14, 2025
@eendebakpt - I fixed another race condition. Would you please try again? |
_find_specimportlibeendebakpt commentedFeb 15, 2025
@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. |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Brett Cannon <brett@python.org>
857bdba intopython:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.