Module scalaris :: Class ConnectionPool
[hide private]
[frames] | no frames]

Class ConnectionPool

source code


Implements a simple (thread-safe) connection pool for Scalaris connections.

Instance Methods [hide private]
 
__init__(self, max_connections)
Create a new connection pool with the given maximum number of connections.
source code
 
_new_connection(self)
Creates a new connection for the pool.
source code
 
_get_connection(self)
Gets a connection from the pool.
source code
 
get_connection(self, timeout=None)
Tries to get a valid connection from the pool waiting at most the given timeout.
source code
 
release_connection(self, connection)
Puts the given connection back into the pool.
source code
 
close_all(self)
Close all connections to scalaris.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, max_connections)
(Constructor)

source code 

Create a new connection pool with the given maximum number of connections.

Overrides: object.__init__

_new_connection(self)

source code 

Creates a new connection for the pool. Override this to use some other connection class than JSONConnection.

_get_connection(self)

source code 

Gets a connection from the pool. Creates a new connection if necessary. Returns <tt>None</tt> if the maximum number of connections has already been hit.

get_connection(self, timeout=None)

source code 

Tries to get a valid connection from the pool waiting at most the given timeout. If timeout is an integer, it will be interpreted as a number of milliseconds. Alternatively, timeout can be given as a datetime.timedelta. Creates a new connection if necessary and the maximum number of connections has not been hit yet. If the timeout is hit and no connection is available, <tt>None</tt> is returned.