MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _check_with_socket

Method _check_with_socket

pymongo/asynchronous/monitor.py:354–375  ·  view source on GitHub ↗

Return (Hello, round_trip_time). Can raise ConnectionFailure or OperationFailure.

(self, conn: AsyncConnection)

Source from the content-addressed store, hash-verified

352 return sd
353
354 async def _check_with_socket(self, conn: AsyncConnection) -> tuple[Hello, float]: # type: ignore[type-arg]
355 """Return (Hello, round_trip_time).
356
357 Can raise ConnectionFailure or OperationFailure.
358 """
359 start = time.monotonic()
360 if conn.more_to_come:
361 # Read the next streaming hello (MongoDB 4.4+).
362 response = Hello(await conn._next_reply(), awaitable=True)
363 elif (
364 self._stream and conn.performed_handshake and self._server_description.topology_version
365 ):
366 # Initiate streaming hello (MongoDB 4.4+).
367 response = await conn._hello(
368 self._server_description.topology_version,
369 self._settings.heartbeat_frequency,
370 )
371 else:
372 # New connection handshake or polling hello (MongoDB <4.4).
373 response = await conn._hello(None, None)
374 duration = _monotonic_duration(start)
375 return response, duration
376
377
378class SrvMonitor(MonitorBase):

Callers 1

_check_onceMethod · 0.95

Calls 4

HelloClass · 0.90
_monotonic_durationFunction · 0.70
_next_replyMethod · 0.45
_helloMethod · 0.45

Tested by

no test coverage detected