[dak/master 3/5] Make SQLAlchemy's pool parameters configurable.
Signed-off-by: Torsten Werner <twerner@debian.org>
---
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 01bd858..bc9da6d 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 0482306..1bf44c8 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,
--
1.7.2.3
Reply to: