Class BurstyPool (3.26.0)

BurstyPool(target_size=10, labels=None, database_role=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.

database_role str

(Optional) user-assigned database_role for the session.

Methods

bind

bind(database)

Associate the pool with a database.

Parameter
NameDescription
database Database

database used by the pool 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.