Fix MPI test teardown failure caused by unpicklable pytest tmpdir fixture#655
Draft
Copilot wants to merge 1 commit into
Draft
Fix MPI test teardown failure caused by unpicklable pytest tmpdir fixture#655Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
Copilot
AI
changed the title
[WIP] Fix failing GitHub Actions job user_cpu_tests_linux (mpi4py, 3.10)
Fix MPI test teardown failure caused by unpicklable pytest tmpdir fixture
Jun 22, 2026
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.
test_loggingMPIwas failing withAttributeError: Can't pickle local object '_BaseExitStack._create_cb_wrapper.<locals>._exit_wrapper'in all MPI ranks.Root cause
Using pytest's
tmpdirfixture triggersTempPathFactory.getbasetemp(), which registers callbacks on an internalExitStack. In pytest ≥8.1, these callbacks are wrapped in_create_cb_wrapper.<locals>._exit_wrapper— a local function that cannot be pickled.pytest-isolate-mpiattempts to pickle all session-scoped fixtures (includingtmp_path_factory) during teardown via_cache_fixture_result, causing the teardown to error.Fix
Replace the
tmpdirfixture dependency intest_loggingMPIwithtempfile.mkdtemp(), avoidingtmp_path_factoryentirely. Rank 0 creates the directory, broadcasts the path string to all ranks, and cleans up after the test.