Skip to content

PYTHON-5300 - Fix unraisable error failure for test_infinite_loop_exc… - #3010

Merged
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-5300
Aug 27, 2026
Merged

PYTHON-5300 - Fix unraisable error failure for test_infinite_loop_exc…#3010
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-5300

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

…eeds_max_recursion_depth

PYTHON-5300

Changes in this PR

The test_infinite_loop_exceeds_max_recursion_depth test can occasionally fail if garbage collection happens while the stack is exhausted. This can cause an unraisable RecursionError which fails the test. This PR fixes the issue by disabling GC during the intentional recursion exhaustion.

Test Plan

Test changes.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage?
  • Is any followup work tracked in a JIRA ticket? If so, add link(s).

Checklist for Reviewer

  • Does the title of the PR reference a JIRA Ticket?
  • Do you fully understand the implementation? (Would you be comfortable explaining how this code works to someone else?)
  • Is all relevant documentation (README or docstring) updated?

Copilot AI lite review requested due to automatic review settings August 27, 2026 14:07
@NoahStapp
NoahStapp requested a review from a team as a code owner August 27, 2026 14:07
@NoahStapp
NoahStapp requested a review from blink1073 August 27, 2026 14:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gc usage to proactively gc.collect() and temporarily gc.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.

Comment thread test/test_custom_types.py
Comment thread test/asynchronous/test_custom_types.py
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@blink1073 blink1073 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@NoahStapp
NoahStapp merged commit 1cbb9ae into mongodb:main Aug 27, 2026
88 of 90 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants