From 3fac3e435be2b886f6db5f2ef55d12ed3a32cac6 Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Wed, 2 Mar 2011 14:49:47 +0100 Subject: [PATCH] Make SQLAlchemy's pool parameters configurable. Signed-off-by: Torsten Werner --- config/debian/dak.conf | 4 ++++ daklib/dbconn.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/config/debian/dak.conf b/config/debian/dak.conf index 01bd8581..bc9da6d8 100644 --- a/config/debian/dak.conf +++ b/config/debian/dak.conf @@ -454,6 +454,10 @@ DB Name "projectb"; Host ""; Port 5433; + // PoolSize should be at least ThreadCount + 1 + PoolSize 17; + // MaxOverflow shouldn't exceed postgresql.conf's max_connections - PoolSize + MaxOverflow 13; }; Archive diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 04823061..1bf44c85 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -3306,8 +3306,14 @@ class DBConn(object): connstr = "postgres:///%s" % cnf["DB::Name"] if cnf["DB::Port"] and cnf["DB::Port"] != "-1": connstr += "?port=%s" % cnf["DB::Port"] - - self.db_pg = create_engine(connstr, echo=self.debug) + if not cnf.has_key('DB::PoolSize'): + cnf['DB::PoolSize'] = '5' + if not cnf.has_key('DB::MaxOverflow'): + cnf['DB::MaxOverflow'] = '10' + + self.db_pg = create_engine(connstr, echo=self.debug, + pool_size=int(cnf['DB::PoolSize']), + max_overflow=int(cnf['DB::MaxOverflow'])) self.db_meta = MetaData() self.db_meta.bind = self.db_pg self.db_smaker = sessionmaker(bind=self.db_pg, -- 2.39.2