memsql/common/random_aggregator_pool.py
def _connect(self):
        """ Returns an aggregator connection. """
        with self._lock:
            if self._aggregator:
                try:
                    return self._pool_connect(self._aggregator)
                except PoolConnectionException:
                    self._aggregator = None

            if not len(self._aggregators):
                with self._pool_connect(self._primary_aggregator) as conn:
                    self._update_aggregator_list(conn)
                    conn.expire()

            random.shuffle(self._aggregators)

            last_exception = None
            for aggregator in self._aggregators:
                self.logger.debug('Attempting connection with %s:%s' % (aggregator[0], aggregator[1]))

                try:
                    conn = self._pool_connect(aggregator)
                    # connection successful!
                    self._aggregator = aggregator
                    return conn
                except PoolConnectionException as e:
                    # connection error
                    last_exception = e
            else:
                # bad news bears...  try again later
                self._aggregator = None
                self._aggregators = []

                raise last_exception
def _connect(self):
        with self._lock:
            if self._aggregator:
                try:
                    return self._pool_connect(self._aggregator)
                except PoolConnectionException:
                    self._aggregator = None

            if not len(self._aggregators):
                with self._pool_connect(self._primary_aggregator) as conn:
                    self._update_aggregator_list(conn)
                    conn.expire()

            random.shuffle(self._aggregators)

            last_exception = None
            for aggregator in self._aggregators:
                self.logger.debug('Attempting connection with %s:%s' % (aggregator[0], aggregator[1]))

                try:
                    conn = self._pool_connect(aggregator)
                    # connection successful!
                    self._aggregator = aggregator
                    return conn
                except PoolConnectionException as e:
                    # connection error
                    last_exception = e
            else:
                # bad news bears...  try again later
                self._aggregator = None
                self._aggregators = []

                raise last_exception
def _connect ( self ) : with self . _lock : if self . _aggregator : try : return self . _pool_connect ( self . _aggregator ) except PoolConnectionException : self . _aggregator = None if not len ( self . _aggregators ) : with self . _pool_connect ( self . _primary_aggregator ) as conn : self . _update_aggregator_list ( conn ) conn . expire ( ) random . shuffle ( self . _aggregators ) last_exception = None for aggregator in self . _aggregators : self . logger . debug ( 'Attempting connection with %s:%s' % ( aggregator [ 0 ] , aggregator [ 1 ] ) ) try : conn = self . _pool_connect ( aggregator ) # connection successful! self . _aggregator = aggregator return conn except PoolConnectionException as e : # connection error last_exception = e else : # bad news bears...  try again later self . _aggregator = None self . _aggregators = [ ] raise last_exception
Returns an aggregator connection.
Returns an aggregator connection .