20
20
import logging
21
21
import time
22
22
import weakref
23
- from typing import TYPE_CHECKING , Any , Mapping , Optional , cast
23
+ from typing import TYPE_CHECKING , Any , Optional
24
24
25
25
from pymongo import common
26
26
from pymongo ._csot import MovingMinimum
27
27
from pymongo .asynchronous import periodic_executor
28
28
from pymongo .asynchronous .periodic_executor import _shutdown_executors
29
- from pymongo .errors import NetworkTimeout , NotPrimaryError , OperationFailure , _OperationCancelled
29
+ from pymongo .errors import NetworkTimeout , _OperationCancelled
30
30
from pymongo .hello import Hello
31
31
from pymongo .lock import _create_lock
32
32
from pymongo .logger import _SDAM_LOGGER , _debug_log , _SDAMStatusMessage
@@ -245,13 +245,7 @@ async def _check_server(self) -> ServerDescription:
245
245
"""
246
246
start = time .monotonic ()
247
247
try :
248
- try :
249
- return await self ._check_once ()
250
- except (OperationFailure , NotPrimaryError ) as exc :
251
- # Update max cluster time even when hello fails.
252
- details = cast (Mapping [str , Any ], exc .details )
253
- self ._topology .receive_cluster_time (details .get ("$clusterTime" ))
254
- raise
248
+ return await self ._check_once ()
255
249
except ReferenceError :
256
250
raise
257
251
except Exception as error :
@@ -345,7 +339,6 @@ async def _check_with_socket(self, conn: AsyncConnection) -> tuple[Hello, float]
345
339
346
340
Can raise ConnectionFailure or OperationFailure.
347
341
"""
348
- cluster_time = self ._topology .max_cluster_time ()
349
342
start = time .monotonic ()
350
343
if conn .more_to_come :
351
344
# Read the next streaming hello (MongoDB 4.4+).
@@ -355,13 +348,13 @@ async def _check_with_socket(self, conn: AsyncConnection) -> tuple[Hello, float]
355
348
):
356
349
# Initiate streaming hello (MongoDB 4.4+).
357
350
response = await conn ._hello (
358
- cluster_time ,
351
+ None ,
359
352
self ._server_description .topology_version ,
360
353
self ._settings .heartbeat_frequency ,
361
354
)
362
355
else :
363
356
# New connection handshake or polling hello (MongoDB <4.4).
364
- response = await conn ._hello (cluster_time , None , None )
357
+ response = await conn ._hello (None , None , None )
365
358
duration = _monotonic_duration (start )
366
359
return response , duration
367
360
0 commit comments