Skip to content

PYTHON-3011 Fix flaky test_connections_are_only_returned_once on PyPy#2847

Open
blink1073 wants to merge 1 commit into
mongodb:masterfrom
blink1073:PYTHON-3011
Open

PYTHON-3011 Fix flaky test_connections_are_only_returned_once on PyPy#2847
blink1073 wants to merge 1 commit into
mongodb:masterfrom
blink1073:PYTHON-3011

Conversation

@blink1073
Copy link
Copy Markdown
Member

@blink1073 blink1073 commented Jun 4, 2026

PYTHON-3011

Changes in this PR

Removes the PyPy skip from test_connections_are_only_returned_once and fixes the underlying flakiness so the test runs on PyPy.

Test Plan

  • Pre-commit hooks pass (ruff, synchro, etc.)
  • The test now runs on PyPy without the skip.

Checklist

Checklist for Author

  • Did you update the changelog (if necessary)?
  • Is there test coverage? (this PR fixes the test itself)
  • 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?

PyPy's tracing GC does not immediately call __del__ when a cursor goes
out of scope, so the pinned connection may not be returned to the pool
before the assertion. Add gc.collect() (3 rounds) before each assertEqual,
matching the identical pattern already used in _test_no_gc_deadlock and
test_session_gc in the same file.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@blink1073
Copy link
Copy Markdown
Member Author

MacOS Arm64 failures are unrelated and tracked by PYTHON-5861

@blink1073 blink1073 marked this pull request as ready for review June 4, 2026 17:28
@blink1073 blink1073 requested a review from a team as a code owner June 4, 2026 17:28
@blink1073 blink1073 requested a review from aclark4life June 4, 2026 17:28
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.

2 participants