PYTHON-5300 - Fix unraisable error failure for test_infinite_loop_exc… - #3010
Merged
Conversation
…eeds_max_recursion_depth
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes intermittent failures in test_infinite_loop_exceeds_max_recursion_depth by preventing garbage collection from running while the call stack is intentionally exhausted (which can otherwise trigger an unraisable RecursionError and fail the test suite).
Changes:
- Add
gcusage to proactivelygc.collect()and temporarilygc.disable()during the recursion-exhaustion portion of the test. - Apply the same test fix to both asynchronous and generated synchronous test variants.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/asynchronous/test_custom_types.py | Disables GC around the intentional recursion exhaustion to prevent unraisable RecursionError flakiness. |
| test/test_custom_types.py | Mirrors the async test change in the synchronous/generated test file. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
…eeds_max_recursion_depth
PYTHON-5300
Changes in this PR
The
test_infinite_loop_exceeds_max_recursion_depthtest can occasionally fail if garbage collection happens while the stack is exhausted. This can cause an unraisableRecursionErrorwhich fails the test. This PR fixes the issue by disabling GC during the intentional recursion exhaustion.Test Plan
Test changes.
Checklist
Checklist for Author
Checklist for Reviewer