aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hashserv
diff options
context:
space:
mode:
authorTobias Hagelborn <tobias.hagelborn@axis.com>2024-02-23 14:27:31 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-23 14:32:19 +0000
commit4fe05513b5314c201725e3f8ad54f58d70c56258 (patch)
tree317753915dca0a3ed2deda5ad9976da8db0c9db7 /lib/hashserv
parentfeef5cd12e877f42ffcace168d44b0e6eb80a907 (diff)
downloadbitbake-4fe05513b5314c201725e3f8ad54f58d70c56258.tar.gz
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. Signed-off-by: Tobias Hagelborn <tobiasha@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/hashserv')
-rw-r--r--lib/hashserv/sqlalchemy.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/hashserv/sqlalchemy.py b/lib/hashserv/sqlalchemy.py
index fc3ae3d33..f7b0226a7 100644
--- a/lib/hashserv/sqlalchemy.py
+++ b/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