Skip to content

gh-154561: Check module dict after trying to load submodule#154742

Open
johnslavik wants to merge 2 commits into
python:mainfrom
johnslavik:gh-154561
Open

gh-154561: Check module dict after trying to load submodule#154742
johnslavik wants to merge 2 commits into
python:mainfrom
johnslavik:gh-154561

Conversation

@johnslavik

@johnslavik johnslavik commented Jul 26, 2026

Copy link
Copy Markdown
Member

Locally I bumped the test to use 100 threads for higher failure reproducibility:

diff --git a/Lib/test/test_lazy_import/__init__.py b/Lib/test/test_lazy_import/__init__.py
index 899ecec1ba2..3d44d2d04c9 100644
--- a/Lib/test/test_lazy_import/__init__.py
+++ b/Lib/test/test_lazy_import/__init__.py
@@ -1794,7 +1794,7 @@ def test_concurrent_lazy_import_reification(self):
         """Multiple threads racing to reify the same lazy import should succeed."""
         from test.test_lazy_import.data import basic_unused
 
-        num_threads = 10
+        num_threads = 100
         results = [None] * num_threads
         errors = []
         barrier = threading.Barrier(num_threads)

I cannot reproduce failures after the proposed change: after trying to load the submodule, we re-check the module dict in case a different thread beat us to it, in which case the attribute can be returned directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant