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

Function _raise_connection_failure

pymongo/pool_shared.py:124–148  ·  view source on GitHub ↗

Convert a socket.error to ConnectionFailure and raise it.

(
    address: Any,
    error: Exception,
    msg_prefix: Optional[str] = None,
    timeout_details: Optional[dict[str, float]] = None,
)

Source from the content-addressed store, hash-verified

122
123
124def _raise_connection_failure(
125 address: Any,
126 error: Exception,
127 msg_prefix: Optional[str] = None,
128 timeout_details: Optional[dict[str, float]] = None,
129) -> NoReturn:
130 """Convert a socket.error to ConnectionFailure and raise it."""
131 host, port = address
132 # If connecting to a Unix socket, port will be None.
133 if port is not None:
134 msg = "%s:%d: %s" % (host, port, error)
135 else:
136 msg = f"{host}: {error}"
137 if msg_prefix:
138 msg = msg_prefix + msg
139 if "configured timeouts" not in msg:
140 msg += format_timeout_details(timeout_details)
141 if (
142 isinstance(error, socket.timeout)
143 or isinstance(error, SSLErrors)
144 and "timed out" in str(error)
145 ):
146 raise NetworkTimeout(msg) from error
147 else:
148 raise AutoReconnect(msg) from error
149
150
151class _CancellationContext:

Callers 14

_connect_kmsFunction · 0.90
kms_requestMethod · 0.90
connectMethod · 0.90
_raise_if_not_readyMethod · 0.90
_connect_kmsFunction · 0.90
kms_requestMethod · 0.90
connectMethod · 0.90
_raise_if_not_readyMethod · 0.90
_async_configured_socketFunction · 0.85

Calls 3

format_timeout_detailsFunction · 0.90
NetworkTimeoutClass · 0.90
AutoReconnectClass · 0.90

Tested by

no test coverage detected