GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing github.com — Accessing attributes of a lazily-loaded module is not thread-safe · Issue #114763 · python/cpython Closed Labels DescriptionBug reportBug description:Attempting to access an attribute of a lazily-loaded module causes the module's import importlib.util import sys import threading import time # Lazy load http spec = importlib.util.find_spec("http") module = importlib.util.module_from_spec(spec) http = sys.modules["http"] = module loader = importlib.util.LazyLoader(spec.loader) loader.exec_module(module) def check(): time.sleep(0.2) return http.HTTPStatus.ACCEPTED == 202 def multicheck(): for _ in range(10): threading.Thread(target=check).start() if sys.argv[1:] == ["single"]: check() else: multicheck() The issue is here: Lines 168 to 177 in 6de8aa3
When attempting to access an attribute, the module's Assuming this is considered a bug, the two fixes I can think of are:
My suspicion is that one lock is enough, so I would suggest going with 1. CPython versions tested on:3.8, 3.10, 3.11, 3.12 Operating systems tested on:Linux Linked PRsActivity
MetadataMetadataAssigneesLabelsProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |