Call hello or read the next streaming response. Returns a ServerDescription.
(self)
| 252 | await self._rtt_monitor.close() |
| 253 | |
| 254 | async def _check_server(self) -> ServerDescription: |
| 255 | """Call hello or read the next streaming response. |
| 256 | |
| 257 | Returns a ServerDescription. |
| 258 | """ |
| 259 | self._conn_id = None |
| 260 | start = time.monotonic() |
| 261 | try: |
| 262 | return await self._check_once() |
| 263 | except ReferenceError: |
| 264 | raise |
| 265 | except Exception as error: |
| 266 | _sanitize(error) |
| 267 | sd = self._server_description |
| 268 | address = sd.address |
| 269 | duration = _monotonic_duration(start) |
| 270 | awaited = bool(self._stream and sd.is_server_type_known and sd.topology_version) |
| 271 | if self._publish: |
| 272 | assert self._listeners is not None |
| 273 | self._listeners.publish_server_heartbeat_failed(address, duration, error, awaited) |
| 274 | if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): |
| 275 | _debug_log( |
| 276 | _SDAM_LOGGER, |
| 277 | message=_SDAMStatusMessage.HEARTBEAT_FAIL, |
| 278 | topologyId=self._topology._topology_id, |
| 279 | serverHost=address[0], |
| 280 | serverPort=address[1], |
| 281 | awaited=awaited, |
| 282 | durationMS=duration * 1000, |
| 283 | failure=error, |
| 284 | driverConnectionId=self._conn_id, |
| 285 | ) |
| 286 | await self._reset_connection() |
| 287 | if isinstance(error, _OperationCancelled): |
| 288 | raise |
| 289 | await self._rtt_monitor.reset() |
| 290 | # Server type defaults to Unknown. |
| 291 | return ServerDescription(address, error=error) |
| 292 | |
| 293 | async def _check_once(self) -> ServerDescription: |
| 294 | """A single attempt to call hello. |
no test coverage detected