Esempio n. 1
0
    def __init__(self, size, **kwargs):
        if not isinstance(size, six.integer_types):
            raise TypeError('Pool size arg must be an integer')

        if size < _MIN_POOL_SIZE:
            raise ValueError('Pool size must be positive')

        self._lock = threading.Lock()
        self._queue = six.moves.queue.LifoQueue(maxsize=size)
        self._thread_connections = threading.local()

        connection_kwargs = kwargs
        connection_kwargs['autoconnect'] = False
        if 'instance' not in connection_kwargs:
            connection_kwargs['instance'] = _get_instance(
                timeout=kwargs.get('timeout'))

        for _ in six.moves.range(size):
            connection = Connection(**connection_kwargs)
            self._queue.put(connection)
Esempio n. 2
0
 def _callFUT(self, timeout=None):
     from gcloud.bigtable.happybase.connection import _get_instance
     return _get_instance(timeout=timeout)