Skip to content

Commit 873dc22

Browse files
committed
PYTHON-1185 - maxStalenessSeconds can be a float.
PyMongo had cast to int before sending to mongos.
1 parent 5735cf4 commit 873dc22

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pymongo/read_preferences.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def document(self):
108108
if self.__tag_sets not in (None, [{}]):
109109
doc['tags'] = self.__tag_sets
110110
if self.__max_staleness:
111-
doc['maxStalenessSeconds'] = int(self.__max_staleness)
111+
doc['maxStalenessSeconds'] = self.__max_staleness
112112
return doc
113113

114114
@property

test/test_read_preferences.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ def test_read_preference_document(self):
519519
'tags': [{'dc': 'sf'}],
520520
'maxStalenessSeconds': 30})
521521

522+
pref = Nearest(max_staleness=1.5)
523+
self.assertEqual(
524+
pref.document,
525+
{'mode': 'nearest', 'maxStalenessSeconds': 1.5})
526+
522527
def test_maybe_add_read_preference(self):
523528

524529
# Primary doesn't add $readPreference

0 commit comments

Comments
 (0)