Class BurstyPool (1.11.0)

BurstyPool(target_size=10, labels=None)

Concrete session pool implementation:

  • "Pings" existing sessions via session.exists before returning them.

  • Creates a new session, rather than blocking, when get is called on an empty pool.

  • Discards the returned session, rather than blocking, when put is called on a full pool.

Parameters

NameDescription
target_size int

max pool size

labels dict (str -> str) or None

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

Properties

labels

User-assigned labels for sesions 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: used to create sessions when needed.

clear

clear()

Delete all sessions in the pool.

get

get()

Check a session out from the pool.

Returns
TypeDescription
Sessionan existing session from the pool, or a newly-created session.

put

put(session)

Return a session to the pool.

Never blocks: if the pool is full, the returned session is discarded.

Parameter
NameDescription
session Session

the session being returned.

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.