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

Method _raise_if_not_ready

pymongo/asynchronous/pool.py:1175–1199  ·  view source on GitHub ↗
(self, checkout_started_time: float, emit_event: bool)

Source from the content-addressed store, hash-verified

1173 await self.checkin(conn)
1174
1175 def _raise_if_not_ready(self, checkout_started_time: float, emit_event: bool) -> None:
1176 if self.state != PoolState.READY:
1177 if emit_event:
1178 duration = time.monotonic() - checkout_started_time
1179 if self.enabled_for_cmap:
1180 assert self.opts._event_listeners is not None
1181 self.opts._event_listeners.publish_connection_check_out_failed(
1182 self.address, ConnectionCheckOutFailedReason.CONN_ERROR, duration
1183 )
1184 if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG):
1185 _debug_log(
1186 _CONNECTION_LOGGER,
1187 message=_ConnectionStatusMessage.CHECKOUT_FAILED,
1188 clientId=self._client_id,
1189 serverHost=self.address[0],
1190 serverPort=self.address[1],
1191 reason="An error occurred while trying to establish a new connection",
1192 error=ConnectionCheckOutFailedReason.CONN_ERROR,
1193 durationMS=duration,
1194 )
1195
1196 details = _get_timeout_details(self.opts)
1197 _raise_connection_failure(
1198 self.address, AutoReconnect("connection pool paused"), timeout_details=details
1199 )
1200
1201 async def _get_conn(
1202 self, checkout_started_time: float, handler: Optional[_MongoClientErrorHandler] = None

Callers 1

_get_connMethod · 0.95

Calls 5

_debug_logFunction · 0.90
_get_timeout_detailsFunction · 0.90
AutoReconnectClass · 0.90

Tested by

no test coverage detected