mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
fix: Enable pool_pre_ping by default for non-SQLite database engines
This change sets `pool_pre_ping=True` in SQLAlchemy engine kwargs for database backends other than SQLite. This helps ensure that connections from the pool are still valid before being used, preventing issues with stale or disconnected connections. Tests are added to verify the default behavior and that explicit overrides are respected Close #4211 Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 864886767
This commit is contained in:
committed by
Copybara-Service
parent
125bc85ac5
commit
da73e718ef
@@ -113,6 +113,8 @@ class DatabaseSessionService(BaseSessionService):
|
||||
connect_args = dict(engine_kwargs.get("connect_args", {}))
|
||||
connect_args.setdefault("check_same_thread", False)
|
||||
engine_kwargs["connect_args"] = connect_args
|
||||
elif url.get_backend_name() != "sqlite":
|
||||
engine_kwargs.setdefault("pool_pre_ping", True)
|
||||
|
||||
db_engine = create_async_engine(db_url, **engine_kwargs)
|
||||
if db_engine.dialect.name == "sqlite":
|
||||
|
||||
Reference in New Issue
Block a user