-
Notifications
You must be signed in to change notification settings - Fork 1.1k
PYTHON-2554 Support $merge and $out executing on secondaries #774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
8580e36
c35081f
627dc35
54159da
cb68e06
276ea06
9249ecc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
|
||
from pymongo import common | ||
from pymongo.errors import ConfigurationError | ||
from pymongo.read_preferences import ReadPreference | ||
from pymongo.read_preferences import ReadPreference, _AggWritePref | ||
from pymongo.server_description import ServerDescription | ||
from pymongo.server_selectors import Selection | ||
from pymongo.server_type import SERVER_TYPE | ||
|
@@ -263,21 +263,24 @@ def apply_selector(self, selector, address=None, custom_selector=None): | |
selector.min_wire_version, | ||
common_wv)) | ||
|
||
if isinstance(selector, _AggWritePref): | ||
selector.selection_hook(self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially I was expecting to place the "selection_hook" logic inside So "selection_hook" is what I came up with instead. |
||
|
||
if self.topology_type == TOPOLOGY_TYPE.Unknown: | ||
return [] | ||
elif self.topology_type in (TOPOLOGY_TYPE.Single, | ||
TOPOLOGY_TYPE.LoadBalanced): | ||
# Ignore selectors for standalone and load balancer mode. | ||
return self.known_servers | ||
elif address: | ||
if address: | ||
# Ignore selectors when explicit address is requested. | ||
description = self.server_descriptions().get(address) | ||
return [description] if description else [] | ||
elif self.topology_type == TOPOLOGY_TYPE.Sharded: | ||
# Ignore read preference. | ||
selection = Selection.from_topology_description(self) | ||
else: | ||
selection = selector(Selection.from_topology_description(self)) | ||
|
||
selection = Selection.from_topology_description(self) | ||
# Ignore read preference for sharded clusters. | ||
if self.topology_type != TOPOLOGY_TYPE.Sharded: | ||
selection = selector(selection) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This bit is just a small cleanup with no functional change. |
||
|
||
# Apply custom selector followed by localThresholdMS. | ||
if custom_selector is not None and selection: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is required because
read_preference
might be a _AggWritePref.