We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b2900d commit ac12b55Copy full SHA for ac12b55
pymongo/topology_description.py
@@ -324,6 +324,14 @@ def apply_selector(
324
description = self.server_descriptions().get(address)
325
return [description] if description else []
326
327
+ # Primary selection fast path.
328
+ if self.topology_type == TOPOLOGY_TYPE.ReplicaSetWithPrimary and isinstance(
329
+ selector, TOPOLOGY_TYPE.Primary
330
+ ):
331
+ for sd in self._server_descriptions.values():
332
+ if sd.server_type == SERVER_TYPE.RSPrimary:
333
+ return [sd]
334
+
335
selection = Selection.from_topology_description(self)
336
# Ignore read preference for sharded clusters.
337
if self.topology_type != TOPOLOGY_TYPE.Sharded:
0 commit comments