FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Prevent sys.modules cleanup during concurrent imports by itscloud0 · Pull Request #2250 · coveragepy/coveragepy · GitHub

Prevent sys.modules cleanup during concurrent imports - #2250

Open
itscloud0 wants to merge 2 commits into
coveragepy:mainfrom
itscloud0:fix-2247-import-safety
Open

Prevent sys.modules cleanup during concurrent imports#2250
itscloud0 wants to merge 2 commits into
coveragepy:mainfrom
itscloud0:fix-2247-import-safety

Conversation

Copy link
Copy Markdown
Contributor

Summary

Prevent sys_modules_saved() from removing a module while another thread is still importing it. The context now holds Python's import lock through the save/restore window, with a regression test covering the interleaving.

Fixes #2247

Verification

  • Ran the issue's deterministic reproducer against current main; it fails before the fix and prints no failure with the branch.
  • uv run --with-editable . --with-requirements requirements/pytest.pip --with-requirements requirements/pip.pip pytest tests/test_misc.py -q
  • uv run --with ruff ruff format --check coverage/misc.py tests/test_misc.py
  • git diff --check

itscloud0 marked this pull request as ready for review August 4, 2026 16:07
itscloud0 force-pushed the fix-2247-import-safety branch from 5652a65 to 5167afe Compare August 18, 2026 04:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

module import breaks when using threads

1 participant


Back | FazBrowse Home | New Git URL