]> git.decadent.org.uk Git - dak.git/commitdiff
Make SQLAlchemy's pool parameters configurable.
authorTorsten Werner <twerner@debian.org>
Wed, 2 Mar 2011 13:49:47 +0000 (14:49 +0100)
committerTorsten Werner <twerner@debian.org>
Wed, 2 Mar 2011 13:49:47 +0000 (14:49 +0100)
Signed-off-by: Torsten Werner <twerner@debian.org>
config/debian/dak.conf
daklib/dbconn.py

index 01bd8581d209b2bddc2ec75a7ad9f96da73d960a..bc9da6d8d64548b8adfb6a8fd574b48d58f8469b 100644 (file)
@@ -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
index 04823061814912e5da33d084acaeb5cc1ecdf45f..1bf44c858650951be219bfdeb1a5b8c360709dec 100755 (executable)
@@ -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,