[SDK Sentinel] Fix sandbox importer module-lock race - #1889
Open
sdk-sentinel-bot wants to merge 1 commit into
Open
sdk-sentinel-bot wants to merge 1 commit into
sdk-sentinel-bot wants to merge 1 commit into
Conversation
This branch has not been deployed
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Caution
This PR contains untrusted AI-generated code. Do not approve or run CI until a maintainer has reviewed the diff. SDK Sentinel verified that GitHub Actions remained approval-gated with zero executable jobs when this PR was opened.
Summary
Fix intermittent Python 3.10 sandbox workflow validation failures seen in the [first captured target-branch failure](https://github.com/temporalio/sdk-python/actions/runs/35488741770/job/106019795452). No preceding equivalent success was captured.
Root cause
The sandbox importer routed ordinary imports of already-completed modules back through importlib. On CPython 3.10/3.11, a garbage-collection finalizer import can re-enter
_ModuleLock.acquire, remove the outer acquisition's thread bookkeeping, and raiseKeyError.Fix
Return completed modules from the sandbox's
sys.modulesview for plain absolute imports. Relative, fromlist, missing, and still-initializing modules continue through importlib. Tests cover the fast path, fallback conditions, and module-lock reproduction.Validation
The causal test failed before and passed after the change. The focused importer suite passed with the runtime-specific test skipped on Python 3.14, both affected transfer tests passed, and fixed repository validation passed. Python 3.10 CI remains required. A separate Windows full-suite timeout is unresolved.
Validation status:
ci-validation-requiredhighhighmediumstandard— 3 changed files; 9.5 KiBunavailable— The exact failure requires CPython 3.10/3.11, which is not installed locally. The causal importlib re-entry behavior was demonstrated on Python 3.14.fail-before-pass-after— The loaded-module fast-path test failed before the source change and passed afterward; the exact module-lock test is present but skips on Python 3.14.Poe lint, bridge lint, and editable build) — passedPoe lint, bridge lint, and editable build) — passedInvestigator-run checks
poe test -s -k workflow_sandbox_importer_repeat_import_skips_import_machinery— passed; 2 attempt(s). The causal check failed before the source change because repeated imports re-entered importlib, then passed after the fast path was added.poe test -s -k 'workflow_sandbox_importer_repeat_import_skips_import_machinery or loaded_module_fast_path_requires_completed_modules or workflow_sandbox_importer_loaded_module_import_inside_module_lock'— passed; 1 attempt(s). Two tests passed; the Python 3.10/3.11-specific module-lock test skipped on Python 3.14.poe test -s -k workflow_sandbox_importer— passed; 1 attempt(s). Seven tests passed and the runtime-specific regression test skipped.poe test -s -k transfer_types_workflow_signal— passed; 1 attempt(s). Both workflow-signal parameterizations passed on Python 3.14..ci-flake-runtime/input/validate.sh— passed; 1 attempt(s). Lint, type checks, docstyle, bridge clippy, and editable bridge build passed.Required target CI
Residual risks
Automation provenance
eb642b14947bd8bcdf8816cffb6a63869803f5c6If this finding should not be fixed, apply the
sdk-sentinel:false-positivelabel and close the PR. Sentinel will suppress the finding until its affected source changes.SDK Sentinel recurrence history
2026-09-20 04:25 UTC2026-09-20 04:25 UTC