Skip to content

Commit 0aefc6c

Browse files
committed
PYTHON-1434 Update max cluster time even when heartbeats fail
1 parent 1fa894d commit 0aefc6c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pymongo/monitor.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ def _check_with_socket(self, sock_info):
173173
Can raise ConnectionFailure or OperationFailure.
174174
"""
175175
start = _time()
176-
return (sock_info.ismaster(self._pool.opts.metadata,
177-
self._topology.max_cluster_time()),
178-
_time() - start)
176+
try:
177+
return (sock_info.ismaster(self._pool.opts.metadata,
178+
self._topology.max_cluster_time()),
179+
_time() - start)
180+
except OperationFailure as exc:
181+
# Update max cluster time even when isMaster fails.
182+
self._topology.receive_cluster_time(
183+
exc.details.get('$clusterTime'))
184+
raise

0 commit comments

Comments
 (0)