Skip to content

PYTHON-6014 Move internal pool classes into pool_shared.py - #3020

Merged
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6014
Aug 31, 2026
Merged

PYTHON-6014 Move internal pool classes into pool_shared.py#3020
NoahStapp merged 1 commit into
mongodb:mainfrom
NoahStapp:PYTHON-6014

Conversation

@NoahStapp

Copy link
Copy Markdown
Contributor

PYTHON-6014

Changes in this PR

See ticket.

Test Plan

Existing test suite.

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 31, 2026 18:33
@NoahStapp
NoahStapp requested a review from a team as a code owner August 31, 2026 18:33
@NoahStapp
NoahStapp requested a review from aclark4life August 31, 2026 18:33

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

This PR refactors PyMongo’s connection pool implementation by relocating a few shared internal pool helpers (generation/state tracking and closed-pool error) into pymongo/pool_shared.py, and updates imports across synchronous/asynchronous pool code and the related test utilities.

Changes:

  • Moved _PoolClosedError, _PoolGeneration, and PoolState definitions into pymongo/pool_shared.py.
  • Updated pymongo.synchronous.pool and pymongo.asynchronous.pool to import those shared helpers from pool_shared.
  • Updated tests/utilities to import the moved helpers from pymongo.pool_shared instead of the per-implementation pool modules.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pymongo/pool_shared.py Adds shared internal pool classes (_PoolClosedError, _PoolGeneration, PoolState) so both pool implementations can reuse them.
pymongo/synchronous/pool.py Removes local definitions and imports the shared pool helpers from pool_shared.
pymongo/asynchronous/pool.py Removes local definitions and imports the shared pool helpers from pool_shared.
test/utils.py Switches sync test utilities to import _CancellationContext / _PoolGeneration from pool_shared.
test/utils_shared.py Switches shared test utilities to import _CancellationContext / _PoolGeneration from pool_shared.
test/test_transactions.py Updates sync transactions tests to import PoolState from pool_shared.
test/test_connection_monitoring.py Updates sync CMAP tests to import PoolState / _PoolClosedError from pool_shared.
test/asynchronous/utils.py Switches async test utilities to import _CancellationContext / _PoolGeneration from pool_shared.
test/asynchronous/test_transactions.py Updates async transactions tests to import PoolState from pool_shared.
test/asynchronous/test_connection_monitoring.py Updates async CMAP tests to import PoolState / _PoolClosedError from pool_shared.

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

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@aclark4life aclark4life 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.

nice!

@NoahStapp
NoahStapp merged commit c3206a3 into mongodb:main Aug 31, 2026
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