HappyBase Connection Pool#
Google Cloud Bigtable HappyBase pool module.
-
class
google.cloud.happybase.pool.ConnectionPool(size, **kwargs)[source]# Bases:
objectThread-safe connection pool.
Note
All keyword arguments are passed unmodified to the
Connectionconstructor except forautoconnect. This is because theopen/closedstatus of a connection is managed by the pool. In addition, ifinstanceis not passed, the default / inferred instance is determined by the pool and then passed to eachConnectionthat is created.Parameters: Raises: TypeErrorifsizeis non an integer.ValueErrorifsizeis not positive.-
connection(*args, **kwds)[source]# Obtain a connection from the pool.
Must be used as a context manager, for example:
with pool.connection() as connection: pass # do something with the connection
If
timeoutis omitted, this method waits forever for a connection to become available from the local queue.Yields an active
Connectionfrom the pool.Parameters: timeout (int) – (Optional) Time (in seconds) to wait for a connection to open. Raises: NoConnectionsAvailableif no connection can be retrieved from the pool before thetimeout(only if a timeout is specified).
-
-
exception
google.cloud.happybase.pool.NoConnectionsAvailable[source]# Bases:
exceptions.RuntimeErrorException raised when no connections are available.
This happens if a timeout was specified when obtaining a connection, and no connection became available within the specified timeout.