Skip to content

PYTHON-6117 Remove cyclic object reference between _ClientReadCheckou… - #3058

Merged
sleepyStick merged 2 commits into
mongodb:mainfrom
sleepyStick:PYTHON-6117
Sep 22, 2026
Merged

sleepyStick merged 2 commits into
mongodb:mainfrom
sleepyStick:PYTHON-6117

Conversation

@sleepyStick

@sleepyStick sleepyStick commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

…t and _PoolCheckout

PYTHON-6117

Changes in this PR

Test Plan

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?

@codecov

codecov Bot commented Sep 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@sleepyStick
sleepyStick marked this pull request as ready for review September 21, 2026 20:05
@sleepyStick
sleepyStick requested a review from a team as a code owner September 21, 2026 20:05
@sleepyStick
sleepyStick requested review from blink1073 and a lite review from Copilot September 21, 2026 20:05

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.

Copilot review overview

🟡 Changes recommended

Async cleanup can raise or be cancelled before the cycle-breaking assignment executes.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Removes the client/pool checkout reference cycle after context-manager cleanup.

Changes:

  • Clears _pool_checkout in synchronous and asynchronous clients.
File Description
pymongo/​synchronous/​mongo_client.py Breaks the checkout cycle on sync exit.
pymongo/​asynchronous/​mongo_client.py Breaks the checkout cycle on async exit.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pymongo/asynchronous/mongo_client.py Outdated
Comment on lines +2755 to +2757
if self._pool_checkout is not None:
await self._pool_checkout.__aexit__(exc_type, exc_val, exc_tb)
self._pool_checkout = None # to break the reference cycle

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

did this change myself so i could run synchro and port it over to the sync file too :)

@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!

@sleepyStick
sleepyStick merged commit ce8dce6 into mongodb:main Sep 22, 2026
92 of 94 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