René's URL Explorer Experiment


Title: Parallel import of modules causes a ModuleNotFoundError · Issue #130094 · python/cpython · GitHub

Open Graph Title: Parallel import of modules causes a ModuleNotFoundError · Issue #130094 · python/cpython

X Title: Parallel import of modules causes a ModuleNotFoundError · Issue #130094 · python/cpython

Description: Bug report Bug description: Using the free-threading build parallel import of modules causes a ModuleNotFoundError. The module that cannot be found can differ. A minimal reproducer: import sys from threading import Thread, Barrier from i...

Open Graph Description: Bug report Bug description: Using the free-threading build parallel import of modules causes a ModuleNotFoundError. The module that cannot be found can differ. A minimal reproducer: import sys from...

X Description: Bug report Bug description: Using the free-threading build parallel import of modules causes a ModuleNotFoundError. The module that cannot be found can differ. A minimal reproducer: import sys from...

Opengraph URL: https://github.com/python/cpython/issues/130094

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Parallel import of modules causes a ModuleNotFoundError","articleBody":"# Bug report\n\n### Bug description:\n\nUsing the free-threading build parallel import of modules causes a `ModuleNotFoundError`. The module that cannot be found can differ. A minimal reproducer:\n```python\nimport sys\nfrom threading import Thread, Barrier\nfrom importlib import import_module, reload\nimport time\n\n\n# Setup threads\nt0 = time.perf_counter()\nnumber_of_threads = 8\nbarrier = Barrier(number_of_threads)\n\npmods = []\n\n\ndef work(ii):\n    # Method doing the actual import\n    barrier.wait()\n    while True:\n        try:\n            m = pmods.pop()\n            mod = import_module(m)\n            # print(f'  {ii}: {m} done')\n        except IndexError:\n            return\n\n\nworker_threads = []\nfor ii in range(number_of_threads):\n    worker_threads.append(Thread(target=work, args=[ii]))\n\ndt = time.perf_counter() - t0\nprint(f\"setup threads {dt*1e3:.2f}\")\n\n\ndef parallel_import(modules: list[str]):\n    global pmods\n    pmods += modules\n    for t in worker_threads:\n        t.start()\n    for t in worker_threads:\n        t.join()\n\n\ndef seq_import(modules: list[str]):\n    for m in modules:\n        mod = import_module(m)\n\n\nimport_method = seq_import\nimport_method = parallel_import\n\nmods = [\n    \"abc\",\n    \"functools\",\n    \"weakref\",\n    \"linecache\",\n    \"glob\",\n    \"annotationlib\",\n    \"argparse\",\n    \"fnmatch\",\n    \"itertools\",\n    \"operator\",\n    \"string\",\n    \"re\",\n    \"collections\",\n    \"sqlite3\",\n    \"pathlib\",\n    \"urllib\",\n    \"typing\",\n    \"csv\",\n    \"uuid\",\n]\n\nmods += [\n    \"setuptools\",\n    \"sympy\",\n    \"django\",\n    \"boto3\",\n]  # these are some packages that need to be installed. without these the reproduction is the issue is much harder\n\nt0 = time.perf_counter()\nimport_method(mods)\ndt = time.perf_counter() - t0\nprint(f\"{import_method.__name__} {dt*1e3:.2f}\")\n```\nNote: this script fails on my system about 1 in 4 times. Changing the modules imported (or the order, or the number of threads) can effect this.\n\nModules that have given issues: `collections.abs`, `glob`, `sympy`, `django.utils.regex_helper`. This suggests it is a general issue, and not a particular package.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nWindows\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-130101\n* gh-155915\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/eendebakpt","@type":"Person","name":"eendebakpt"},"datePublished":"2025-02-13T19:49:05Z","url":"https://github.com/python/cpython/issues/130094"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:99b017ae-d5d6-ef65-a901-a7af74a11eea
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8486:182799:5F39BF:7F0FC4:6AED1E07
html-safe-nonce7c65e4439ca5c85e85c2b15bbfd93d43fdb48556b8f027794cc963df6c17d047
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDg2OjE4Mjc5OTo1RjM5QkY6N0YwRkM0OjZBRUQxRTA3IiwidmlzaXRvcl9pZCI6IjYzODk4MjEwNDM2MTM5NjU4MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac24b09af0b62205bb4c2a3db9539735ccbe01ca9b7c754a155b0db1847d3d333a
hovercard-subject-tagissue:2851960100
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/130094/issue_layout
twitter:imagehttps://opengraph.githubassets.com/411b2a46f6b56516d833ab095c1ca6dbb183e5b73517d3117cda8ed2c243c389/python/cpython/issues/130094
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/411b2a46f6b56516d833ab095c1ca6dbb183e5b73517d3117cda8ed2c243c389/python/cpython/issues/130094
og:image:altBug report Bug description: Using the free-threading build parallel import of modules causes a ModuleNotFoundError. The module that cannot be found can differ. A minimal reproducer: import sys from...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameeendebakpt
hostnamegithub.com
expected-hostnamegithub.com
Nonee3e0f7f63e50c6fe879198a93a0a023a648ecc0a5e9bc3b5e033ac57172237e6
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release707a24b346ac8a82878b9c084efaa38a997660cb
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/130094#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F130094
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F130094
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/130094
Reloadhttps://github.com/python/cpython/issues/130094
Reloadhttps://github.com/python/cpython/issues/130094
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.3k (2.3k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/pulse
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/130094
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/130094
Parallel import of modules causes a ModuleNotFoundErrorhttps://github.com/python/cpython/issues/130094#top
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/eendebakpt
eendebakpthttps://github.com/eendebakpt
on Feb 13, 2025https://github.com/python/cpython/issues/130094#issue-2851960100
gh-130094: Fix race conditions in importlib #130101https://github.com/python/cpython/pull/130101
[3.13] gh-130094: Fix race conditions in importlib (gh-130101) #155915https://github.com/python/cpython/pull/155915
eendebakpthttps://github.com/eendebakpt
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Feb 13, 2025https://github.com/python/cpython/issues/130094#event-16301900264
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Feb 14, 2025https://github.com/python/cpython/issues/130094#issuecomment-2657977475
https://gist.github.com/colesbury/90493ef5b6f818bbbfde6922ffc8ea8ahttps://gist.github.com/colesbury/90493ef5b6f818bbbfde6922ffc8ea8a
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Feb 14, 2025https://github.com/python/cpython/issues/130094#issuecomment-2657980585
https://github.com/pypa/setuptools/blob/a3cc40f4b8fc90e8f57e3a59a54980fb1f408207/_distutils_hack/__init__.py#L226-L234https://github.com/pypa/setuptools/blob/a3cc40f4b8fc90e8f57e3a59a54980fb1f408207/_distutils_hack/__init__.py#L226-L234
cpython/Lib/importlib/_bootstrap.pyhttps://github.com/python/cpython/blob/05e89c34bd8389f87bd6c9462d5a06ef9e1a65ab/Lib/importlib/_bootstrap.py#L1254-L1262
05e89c3https://github.com/python/cpython/commit/05e89c34bd8389f87bd6c9462d5a06ef9e1a65ab
colesburyhttps://github.com/colesbury
on Feb 14, 2025https://github.com/python/cpython/issues/130094#event-16304385167
pythongh-130094: Fix race condition in `_find_spec`https://github.com/colesbury/cpython/commit/194beca4474ccf381d88f0797f9d6a0a85c41cd0
pythongh-130094https://github.com/python/cpython/issues/130094
194becahttps://github.com/colesbury/cpython/commit/194beca4474ccf381d88f0797f9d6a0a85c41cd0
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Feb 14, 2025https://github.com/python/cpython/issues/130094#issuecomment-2657997317
@eendebakpthttps://github.com/eendebakpt
#130101https://github.com/python/cpython/pull/130101
colesburyhttps://github.com/colesbury
on Feb 18, 2025https://github.com/python/cpython/issues/130094#event-16356680520
gh-130094: Fix race conditions in `importlib` (gh-130101)https://github.com/python/cpython/commit/857bdba0ac66ed7963e9fca45ab1a5f7a32b4bfb
gh-130094https://github.com/python/cpython/issues/130094
gh-130101https://github.com/python/cpython/pull/130101
857bdbahttps://github.com/python/cpython/commit/857bdba0ac66ed7963e9fca45ab1a5f7a32b4bfb
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Feb 18, 2025https://github.com/python/cpython/issues/130094#issuecomment-2667119993
colesburyhttps://github.com/colesbury
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Feb 18, 2025https://github.com/python/cpython/issues/130094#event-16356685786
gpsheadhttps://github.com/gpshead
needs backport to 3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22needs%20backport%20to%203.13%22
needs backport to 3.13only security fixeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22needs%20backport%20to%203.13%22
on Jan 10, 2026https://github.com/python/cpython/issues/130094#event-21961637079
zsaladinhttps://github.com/zsaladin
on Aug 17, 2026https://github.com/python/cpython/issues/130094#event-29538443982
[3.13] pythongh-130094: Fix race conditions in `importlib` (pythongh-…https://github.com/zsaladin/cpython/commit/f45ca688e0fd90ba891ff794c154fff8a42e51bc
pythongh-130094https://github.com/python/cpython/issues/130094
pythongh-…https://github.com/python/cpython/pull/130101
f45ca68https://github.com/zsaladin/cpython/commit/f45ca688e0fd90ba891ff794c154fff8a42e51bc
corona10https://github.com/corona10
on Aug 17, 2026https://github.com/python/cpython/issues/130094#event-29539357977
[3.13] gh-130094: Fix race conditions in `importlib` (gh-130101) (gh-…https://github.com/python/cpython/commit/b0a181d8fcf691f4d9eaabc6d39de1eefc863272
gh-130094https://github.com/python/cpython/issues/130094
gh-130101https://github.com/python/cpython/pull/130101
gh-…https://github.com/python/cpython/pull/155915
b0a181dhttps://github.com/python/cpython/commit/b0a181d8fcf691f4d9eaabc6d39de1eefc863272
L3n41chttps://github.com/L3n41c
on Oct 9, 2026https://github.com/python/cpython/issues/130094#event-32863090311
[CONTINT-3239] Revert "[automated] Upgrade embedded Python patch vers…https://github.com/DataDog/datadog-agent/commit/e9b2b8ac339007814d00995784ba2c7ad8ef616a
e9b2b8ahttps://github.com/DataDog/datadog-agent/commit/e9b2b8ac339007814d00995784ba2c7ad8ef616a
gh-worker-dd-mergequeue-cf854dhttps://github.com/apps/gh-worker-dd-mergequeue-cf854d
on Oct 9, 2026https://github.com/python/cpython/issues/130094#event-32873248343
[CONTINT-3239] Revert "[automated] Upgrade embedded Python patch vers…https://github.com/DataDog/datadog-agent/commit/c7f76a597341d06dd004981901bce46d108f0e4a
c7f76a5https://github.com/DataDog/datadog-agent/commit/c7f76a597341d06dd004981901bce46d108f0e4a
[Backport 7.84.x] [CONTINT-3239] Revert "[automated] Upgrade embedded…https://github.com/DataDog/datadog-agent/commit/08f5458f10ee8520317e79fc86850128915b52ae
08f5458https://github.com/DataDog/datadog-agent/commit/08f5458f10ee8520317e79fc86850128915b52ae
kacper-murzynhttps://github.com/kacper-murzyn
on Oct 12, 2026https://github.com/python/cpython/issues/130094#event-33035632418
[Backport 7.85.x] [CONTINT-3239] Revert "[automated] Upgrade embedded…https://github.com/DataDog/datadog-agent/commit/4ba1361992172b2f9a62efae10fda224bd94a00b
4ba1361https://github.com/DataDog/datadog-agent/commit/4ba1361992172b2f9a62efae10fda224bd94a00b
https://github.com/gpshead
gpsheadhttps://github.com/gpshead
on Oct 14, 2026https://github.com/python/cpython/issues/130094#issuecomment-6157942065
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/130094
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/130094
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.