Repository navigation
PYTHON-6029 Consolidate non-IO code in Pool and Connection into shared base class - #3129
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| self.last_timeout = timeout | ||
| self.conn.get_conn.settimeout(timeout) | ||
|
|
||
| def apply_timeout(self, cmd: Optional[MutableMapping[str, Any]]) -> Optional[float]: |
There was a problem hiding this comment.
I've removed the unused client parameter to avoid additional type complexity with the consolidation, but it does mean this PR has changes across usages. I could see instead moving that removal to a follow-up PR, but that leaves the codebase in an intermediate state where we have known dead code in-between.
There was a problem hiding this comment.
🟢 Approval recommended
Static review identified no blocking regressions in the extraction or updated callers; tests were not run.
0 open findings
What changed in this PR
Consolidates shared, non-I/O pool and connection logic to reduce duplication between PyMongo’s synchronous and asynchronous drivers.
Changes:
- Extracts common state and methods into generic base classes.
- Removes the unused client argument from
apply_timeoutand updates callers. - Moves the telemetry protocol import under
TYPE_CHECKING.
| File | Description |
|---|---|
pymongo/synchronous/pool.py |
Uses shared base classes. |
pymongo/synchronous/command_runner.py |
Updates timeout call. |
pymongo/synchronous/client_bulk.py |
Updates client bulk timeout call. |
pymongo/synchronous/bulk.py |
Updates collection bulk timeout call. |
pymongo/pool_shared.py |
Adds common pool and connection implementations. |
pymongo/message.py |
Updates shared calls and removes obsolete type ignores. |
pymongo/asynchronous/pool.py |
Uses shared base classes. |
pymongo/asynchronous/command_runner.py |
Updates timeout call. |
pymongo/asynchronous/client_bulk.py |
Updates client bulk timeout call. |
pymongo/asynchronous/bulk.py |
Updates collection bulk timeout call. |
pymongo/_telemetry.py |
Makes protocol import type-checking-only. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
aclark4life
left a comment
There was a problem hiding this comment.
Probably fine to remove unused client parameter, LGTM
PYTHON-6029
Changes in this PR
See ticket.
Test Plan
Existing test suite.
Checklist
Checklist for Author
[ ] Did you update the changelog (if necessary)?[ ] Is any followup work tracked in a JIRA ticket? If so, add link(s).Checklist for Reviewer