(self)
Call ismaster once or twice. Reset server's pool on error.

        Returns a ServerDescription.
Call ismaster once or twice. Reset server's pool on error.
Call ismaster once or twice . Reset server s pool on error .
def _check_with_retry(self):
        """Call ismaster once or twice. Reset server's pool on error.

        Returns a ServerDescription.
        """
        # According to the spec, if an ismaster call fails we reset the
        # server's pool. If a server was once connected, change its type
        # to Unknown only after retrying once.
        address = self._server_description.address
        retry = True
        metadata = None
        if self._server_description.server_type == SERVER_TYPE.Unknown:
            retry = False
            metadata = self._pool.opts.metadata

        start = _time()
        try:
            # If the server type is unknown, send metadata with first check.
            return self._check_once(metadata=metadata)
        except ReferenceError:
            raise
        except Exception as error:
            error_time = _time() - start
            if self._publish:
                self._listeners.publish_server_heartbeat_failed(
                    address, error_time, error)
            self._topology.reset_pool(address)
            default = ServerDescription(address, error=error)
            if not retry:
                self._avg_round_trip_time.reset()
                # Server type defaults to Unknown.
                return default

            # Try a second and final time. If it fails return original error.
            start = _time()
            try:
                return self._check_once(metadata=self._pool.opts.metadata)
            except ReferenceError:
                raise
            except Exception as error:
                error_time = _time() - start
                if self._publish:
                    self._listeners.publish_server_heartbeat_failed(
                        address, error_time, error)
                self._avg_round_trip_time.reset()
                return default
def _check_with_retry ( self ) : # According to the spec, if an ismaster call fails we reset the # server's pool. If a server was once connected, change its type # to Unknown only after retrying once. address = self . _server_description . address retry = True metadata = None if self . _server_description . server_type == SERVER_TYPE . Unknown : retry = False metadata = self . _pool . opts . metadata start = _time ( ) try : # If the server type is unknown, send metadata with first check. return self . _check_once ( metadata = metadata ) except ReferenceError : raise except Exception as error : error_time = _time ( ) - start if self . _publish : self . _listeners . publish_server_heartbeat_failed ( address , error_time , error ) self . _topology . reset_pool ( address ) default = ServerDescription ( address , error = error ) if not retry : self . _avg_round_trip_time . reset ( ) # Server type defaults to Unknown. return default # Try a second and final time. If it fails return original error. start = _time ( ) try : return self . _check_once ( metadata = self . _pool . opts . metadata ) except ReferenceError : raise except Exception as error : error_time = _time ( ) - start if self . _publish : self . _listeners . publish_server_heartbeat_failed ( address , error_time , error ) self . _avg_round_trip_time . reset ( ) return default