This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new 4febe22  Better location for default
4febe22 is described below

commit 4febe227df01eb1708f8ae9257a90b33f0321f31
Author: Sebb <[email protected]>
AuthorDate: Mon Nov 15 23:06:54 2021 +0000

    Better location for default
---
 server/main.py                  | 7 +++----
 server/plugins/configuration.py | 2 ++
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/server/main.py b/server/main.py
index 036c5c3..0b6b535 100644
--- a/server/main.py
+++ b/server/main.py
@@ -66,10 +66,9 @@ class Server(plugins.server.BaseServer):
         self.streamlock = asyncio.Lock()
 
         # Make a pool of database connections for async queries
-        try:
-            pool_size = self.config.database.pool_size
-        except AttributeError: # remove try/except to make pool_size a 
required config entry
-             pool_size = 15
+        pool_size = self.config.database.pool_size
+        if pool_size < 1:
+            raise ValueError(f"pool_size {pool_size} must be > 0")
         for _ in range(1, pool_size):
             
self.dbpool.put_nowait(plugins.database.Database(self.config.database))
 
diff --git a/server/plugins/configuration.py b/server/plugins/configuration.py
index d6c77f6..7701c0e 100644
--- a/server/plugins/configuration.py
+++ b/server/plugins/configuration.py
@@ -81,6 +81,7 @@ class DBConfig:
     db_prefix: str
     max_hits: int
     max_lists: int
+    pool_size: int
 
     def __init__(self, subyaml: dict):
         self.dburl = str(subyaml.get("dburl", ""))
@@ -91,6 +92,7 @@ class DBConfig:
         self.db_prefix = str(subyaml.get("db_prefix", "ponymail"))
         self.max_hits = int(subyaml.get("max_hits", 5000))
         self.max_lists = int(subyaml.get("max_lists", 8192))
+        self.pool_size = int(subyaml.get("pool_size", 15))
 
 
 class Configuration:

Reply via email to