summaryrefslogtreecommitdiff
path: root/kombu/transport/mongodb.py
diff options
context:
space:
mode:
authorMikhail Elovskikh <wronglink@gmail.com>2017-06-08 21:41:15 +0500
committerAsif Saifuddin Auvi <auvipy@users.noreply.github.com>2017-06-08 22:41:15 +0600
commitba873ba4f2d768ee33357dc044c98c5cc6bd4bfd (patch)
tree5983ed6cef7764d02b3750fda930f20744380b90 /kombu/transport/mongodb.py
parent645bbd3078932de139dd002462a28ef3b7550f84 (diff)
downloadkombu-ba873ba4f2d768ee33357dc044c98c5cc6bd4bfd.tar.gz
Fix readpreference option parsing in MongoDB transport (#751)
* Fix readpreference option parsing in MongoDB transport * Update changelog
Diffstat (limited to 'kombu/transport/mongodb.py')
-rw-r--r--kombu/transport/mongodb.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/kombu/transport/mongodb.py b/kombu/transport/mongodb.py
index 2a7f8ff3..75372ab0 100644
--- a/kombu/transport/mongodb.py
+++ b/kombu/transport/mongodb.py
@@ -274,18 +274,21 @@ class Channel(virtual.Channel):
if self.connect_timeout else None),
}
options.update(parsed['options'])
+ options = self._prepare_client_options(options)
return hostname, dbname, options
def _prepare_client_options(self, options):
if pymongo.version_tuple >= (3,):
options.pop('auto_start_request', None)
+ if isinstance(options.get('readpreference'), int):
+ modes = pymongo.read_preferences._MONGOS_MODES
+ options['readpreference'] = modes[options['readpreference']]
return options
def _open(self, scheme='mongodb://'):
- hostname, dbname, options = self._parse_uri(scheme=scheme)
+ hostname, dbname, conf = self._parse_uri(scheme=scheme)
- conf = self._prepare_client_options(options)
conf['host'] = hostname
env = _detect_environment()