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

Method _handle_connection_error

pymongo/asynchronous/pool.py:994–1007  ·  view source on GitHub ↗
(self, error: BaseException)

Source from the content-addressed store, hash-verified

992 self.size_cond.notify()
993
994 def _handle_connection_error(self, error: BaseException) -> None:
995 # Handle system overload condition for non-sdam pools.
996 # Look for errors of type AutoReconnect and add error labels if appropriate.
997 if self.is_sdam or type(error) not in (AutoReconnect, NetworkTimeout):
998 return
999 assert isinstance(error, AutoReconnect) # Appease type checker.
1000 # If the original error was a DNS, certificate, or SSL error, ignore it.
1001 if isinstance(error.__cause__, (_CertificateError, SSLErrors, socket.gaierror)):
1002 # End of file errors are excluded, because the server may have disconnected
1003 # during the handshake.
1004 if not isinstance(error.__cause__, (ssl.SSLEOFError, ssl.SSLZeroReturnError)):
1005 return
1006 error._add_error_label("SystemOverloadedError")
1007 error._add_error_label("RetryableError")
1008
1009 async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> AsyncConnection:
1010 """Connect to Mongo and return a new AsyncConnection.

Callers 1

connectMethod · 0.95

Calls 1

_add_error_labelMethod · 0.80

Tested by

no test coverage detected