HappyBase Connection Pool#
Warning
gRPC is required for using the Cloud Bigtable API. As of May 2016,
grpcio is only supported in Python 2.7, so importing
gcloud.bigtable in other versions of Python will fail.
Google Cloud Bigtable HappyBase pool module.
-
class
gcloud.bigtable.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.Parameters: timeout (int) – (Optional) Time (in seconds) to wait for a connection to open. Return type: ConnectionReturns: An active connection from the pool. Raises: NoConnectionsAvailableif no connection can be retrieved from the pool before thetimeout(only if a timeout is specified).
-
-
exception
gcloud.bigtable.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.