fix(python): avoid interpreter shutdown panic in BackgroundExecutor#6023
Merged
fix(python): avoid interpreter shutdown panic in BackgroundExecutor#6023
Conversation
Contributor
PR Review: fix(python): avoid interpreter shutdown panic in BackgroundExecutorOverall: LGTM ✅ This is a clean fix for the interpreter shutdown panic. Replacing Reviewed aspects:
No P0/P1 issues found. |
BubbleCal
approved these changes
Feb 26, 2026
Xuanwo
added a commit
to wjones127/lance
that referenced
this pull request
Feb 26, 2026
…ance-format#6023) ## Summary - harden `BackgroundExecutor` against Python interpreter finalization by replacing unconditional `Python::attach(...)` calls with `Python::try_attach(...)` in `spawn`, `spawn_background`, `block_on`, and signal polling loops - keep behavior the same when Python is attachable, and safely degrade to `Ok(())` signal checks when Python is finalizing/unavailable - add a regression test that runs `take_blobs + close` in a subprocess and asserts no `interpreter_lifecycle` panic appears on process shutdown ## Why `take_blobs` could trigger a panic during interpreter shutdown because signal checks in the executor always called `Python::attach(...)`, which panics when Python is finalizing. This fix addresses the root cause globally in the executor instead of adding blob-specific special handling. ## Testing - `cargo check --manifest-path python/Cargo.toml --tests` - `cd python && uv sync --extra tests` - `cd python && uv run python -m pytest -q python/tests/test_blob.py`
wjones127
pushed a commit
that referenced
this pull request
Feb 26, 2026
…6023) ## Summary - harden `BackgroundExecutor` against Python interpreter finalization by replacing unconditional `Python::attach(...)` calls with `Python::try_attach(...)` in `spawn`, `spawn_background`, `block_on`, and signal polling loops - keep behavior the same when Python is attachable, and safely degrade to `Ok(())` signal checks when Python is finalizing/unavailable - add a regression test that runs `take_blobs + close` in a subprocess and asserts no `interpreter_lifecycle` panic appears on process shutdown ## Why `take_blobs` could trigger a panic during interpreter shutdown because signal checks in the executor always called `Python::attach(...)`, which panics when Python is finalizing. This fix addresses the root cause globally in the executor instead of adding blob-specific special handling. ## Testing - `cargo check --manifest-path python/Cargo.toml --tests` - `cd python && uv sync --extra tests` - `cd python && uv run python -m pytest -q python/tests/test_blob.py`
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.
Summary
BackgroundExecutoragainst Python interpreter finalization by replacing unconditionalPython::attach(...)calls withPython::try_attach(...)inspawn,spawn_background,block_on, and signal polling loopsOk(())signal checks when Python is finalizing/unavailabletake_blobs + closein a subprocess and asserts nointerpreter_lifecyclepanic appears on process shutdownWhy
take_blobscould trigger a panic during interpreter shutdown because signal checks in the executor always calledPython::attach(...), which panics when Python is finalizing.This fix addresses the root cause globally in the executor instead of adding blob-specific special handling.
Testing
cargo check --manifest-path python/Cargo.toml --testscd python && uv sync --extra testscd python && uv run python -m pytest -q python/tests/test_blob.py