2121import logging
2222import time
2323import weakref
24- from typing import TYPE_CHECKING , Any , Mapping , Optional , cast
24+ from typing import TYPE_CHECKING , Any , Optional
2525
2626from pymongo import common , periodic_executor
2727from pymongo ._csot import MovingMinimum
28- from pymongo .errors import NetworkTimeout , NotPrimaryError , OperationFailure , _OperationCancelled
28+ from pymongo .errors import NetworkTimeout , _OperationCancelled
2929from pymongo .hello import Hello
3030from pymongo .lock import _async_create_lock
3131from pymongo .logger import _SDAM_LOGGER , _debug_log , _SDAMStatusMessage
@@ -255,13 +255,7 @@ async def _check_server(self) -> ServerDescription:
255255 self ._conn_id = None
256256 start = time .monotonic ()
257257 try :
258- try :
259- return await self ._check_once ()
260- except (OperationFailure , NotPrimaryError ) as exc :
261- # Update max cluster time even when hello fails.
262- details = cast (Mapping [str , Any ], exc .details )
263- await self ._topology .receive_cluster_time (details .get ("$clusterTime" ))
264- raise
258+ return await self ._check_once ()
265259 except ReferenceError :
266260 raise
267261 except Exception as error :
@@ -358,7 +352,6 @@ async def _check_with_socket(self, conn: AsyncConnection) -> tuple[Hello, float]
358352
359353 Can raise ConnectionFailure or OperationFailure.
360354 """
361- cluster_time = self ._topology .max_cluster_time ()
362355 start = time .monotonic ()
363356 if conn .more_to_come :
364357 # Read the next streaming hello (MongoDB 4.4+).
@@ -368,13 +361,12 @@ async def _check_with_socket(self, conn: AsyncConnection) -> tuple[Hello, float]
368361 ):
369362 # Initiate streaming hello (MongoDB 4.4+).
370363 response = await conn ._hello (
371- cluster_time ,
372364 self ._server_description .topology_version ,
373365 self ._settings .heartbeat_frequency ,
374366 )
375367 else :
376368 # New connection handshake or polling hello (MongoDB <4.4).
377- response = await conn ._hello (cluster_time , None , None )
369+ response = await conn ._hello (None , None )
378370 duration = _monotonic_duration (start )
379371 return response , duration
380372
0 commit comments