Class BurstyPool (1.13.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

Name Description
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
Type Description
dict (str -> str) labels assigned by the user

Methods

bind

bind(database)

Associate the pool with a database.

Parameter
Name Description
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
Type Description
Session an 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
Name Description
session Session

the session being returned.

session

session(**kwargs)

Check out a session from the pool.

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

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年12月16日 UTC.