HappyBase Connection Pool#
Google Cloud Bigtable HappyBase pool module.
-
class
google.cloud.happybase.pool.
ConnectionPool
(size, **kwargs)[source]# Bases:
object
Thread-safe connection pool.
Note
All keyword arguments are passed unmodified to the
Connection
constructor except forautoconnect
. This is because theopen
/closed
status of a connection is managed by the pool. In addition, ifinstance
is not passed, the default / inferred instance is determined by the pool and then passed to eachConnection
that is created.Parameters: Raises: TypeError
ifsize
is non an integer.ValueError
ifsize
is 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
timeout
is omitted, this method waits forever for a connection to become available from the local queue.Yields an active
Connection
from the pool.Parameters: timeout (int) – (Optional) Time (in seconds) to wait for a connection to open. Raises: NoConnectionsAvailable
if 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.RuntimeError
Exception 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.