You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DatabaseSessionService uses sync DB operations - needs async variant #1005
Is your feature request related to a problem? Please describe.
DatabaseSessionService uses async method signatures but internally calls SQLAlchemy’s sync APIs
Describe the solution you'd like
Add an AsyncDatabaseSessionService that uses SQLAlchemy’s async APIs (AsyncSession, etc.).
Describe alternatives you've considered
Fix existing DatabaseSessionService implementation to use async database operations.
Additional context
n/a
Reacted by Michał Brotoń, Vasilii Novikov, Lesly Arun Franco, Yash Singh, GitMarco27, dsakhnov, Michael Jones, Emanuele Boscari, Darío Fragas and SergeySetti
I was trying to use DatabaseSessionService in an async way (passing db_url starting with postgresql+asyncpg) and there's more to that issue - I couldn't even initialize the class, because there's creation of sync engine, sync sessionmaker and tables creation (Base.metadata.create_all(self.db_engine)) which is causing: exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?
I was thinking about creating a PR with a quick fix, however I wasn't sure how to handle __init__ without introducing breaking changes to the API.
Additional notes:
It would be nice to have more control over tables creation, e.g. I want to use alembic and keep tables creation in migration files.
There's redundant line self.inspector = inspect(self.db_engine) because self.inspector is never used
@DeanChensj Hello! do we have news here? In our project we use patched version of database service like this #1316 it works, but wondering, will it be solved by ADK team in next releases?
Activity
mbroton commentedon May 29, 2025
I was trying to use
DatabaseSessionServicein an async way (passingdb_urlstarting withpostgresql+asyncpg) and there's more to that issue - I couldn't even initialize the class, because there's creation of sync engine, sync sessionmaker and tables creation (Base.metadata.create_all(self.db_engine)) which is causing:exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here. Was IO attempted in an unexpected place?I was thinking about creating a PR with a quick fix, however I wasn't sure how to handle
__init__without introducing breaking changes to the API.Additional notes:
self.inspector = inspect(self.db_engine)becauseself.inspectoris never usedcondorcet commentedon Jul 22, 2025
@DeanChensj Hello! do we have news here? In our project we use patched version of database service like this #1316 it works, but wondering, will it be solved by ADK team in next releases?
leslyarun commentedon Aug 4, 2025
@DeanChensj When will this support be added? Please priortise it
hangfei commentedon Nov 8, 2025
We are evaluating if we can merge #2889 or there is a better option.
hangfei commentedon Nov 8, 2025
Also related: #1750
feat: full async implementation of DatabaseSessionService
DeanChensj commentedon Nov 10, 2025
This is now closed by #2889
feat: full async implementation of DatabaseSessionService