Class AbstractSessionPool (3.6.0)

AbstractSessionPool(labels=None)

Specifies required API for concrete session pool implementations.

Parameter

NameDescription
labels dict (str -> str) or None

(Optional) user-assigned labels for sessions created by the pool.

Properties

labels

User-assigned labels for sessions created by the pool.

Returns
TypeDescription
dict (str -> str)labels assigned by the user

Methods

bind

bind(database)

Associate the pool with a database.

Parameter
NameDescription
database Database

database used by the pool to create sessions when needed. Concrete implementations of this method may pre-fill the pool using the database.

Exceptions
TypeDescription
NotImplementedErrorabstract method

clear

clear()

Delete all sessions in the pool.

Concrete implementations of this method are allowed to raise an error to signal that the pool is full, or to block until it is not full.

Exceptions
TypeDescription
NotImplementedErrorabstract method

get

get()

Check a session out from the pool.

Concrete implementations of this method are allowed to raise an error to signal that the pool is exhausted, or to block until a session is available.

Exceptions
TypeDescription
NotImplementedErrorabstract method

put

put(session)

Return a session to the pool.

Parameter
NameDescription
session Session

the session being returned. Concrete implementations of this method are allowed to raise an error to signal that the pool is full, or to block until it is not full.

Exceptions
TypeDescription
NotImplementedErrorabstract method

session

session(**kwargs)

Check out a session from the pool.

Returns
TypeDescription
SessionCheckouta checkout instance, to be used as a context manager for accessing the session and returning it to the pool.