From 42242fb9ef844fa2ac56eebd02ead921c57dde93 Mon Sep 17 00:00:00 2001 From: Tobias Hagelborn Date: Fri, 23 Feb 2024 14:27:31 +0100 Subject: bitbake: hashserv: Re-enable connection pooling with psycopg 3 driver Re-enable connection pooling in case `postgresql+psygopg` driver is used. Async connection pooling is supported in psycopg 3 [psycopg] driver in SQLAlchemy. Allow the connection pool to grow to arbitrary size. (Bitbake rev: 4fe05513b5314c201725e3f8ad54f58d70c56258) Signed-off-by: Tobias Hagelborn Signed-off-by: Richard Purdie --- bitbake/lib/hashserv/sqlalchemy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bitbake') diff --git a/bitbake/lib/hashserv/sqlalchemy.py b/bitbake/lib/hashserv/sqlalchemy.py index fc3ae3d339..f7b0226a7a 100644 --- a/bitbake/lib/hashserv/sqlalchemy.py +++ b/bitbake/lib/hashserv/sqlalchemy.py @@ -129,7 +129,11 @@ class DatabaseEngine(object): return inspect(conn).has_table(name) self.logger.info("Using database %s", self.url) - self.engine = create_async_engine(self.url, poolclass=NullPool) + if self.url.drivername == 'postgresql+psycopg': + # Psygopg 3 (psygopg) driver can handle async connection pooling + self.engine = create_async_engine(self.url, max_overflow=-1) + else: + self.engine = create_async_engine(self.url, poolclass=NullPool) async with self.engine.begin() as conn: # Create tables -- cgit v1.2.3-54-g00ecf