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 ae9d446  Make pool count configurable
ae9d446 is described below

commit ae9d446050870b0f25f7cf09702350777e605c3f
Author: Sebb <[email protected]>
AuthorDate: Mon Nov 15 17:52:03 2021 +0000

    Make pool count configurable
    
    This fixes #61
---
 server/main.py               | 8 ++++++--
 server/ponymail.yaml.example | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/server/main.py b/server/main.py
index 87e09c9..036c5c3 100644
--- a/server/main.py
+++ b/server/main.py
@@ -65,8 +65,12 @@ class Server(plugins.server.BaseServer):
         self.server = None
         self.streamlock = asyncio.Lock()
 
-        # Make a pool of 15 database connections for async queries
-        for _ in range(1, 15):
+        # 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
+        for _ in range(1, pool_size):
             
self.dbpool.put_nowait(plugins.database.Database(self.config.database))
 
         # Load each URL endpoint
diff --git a/server/ponymail.yaml.example b/server/ponymail.yaml.example
index 2b8c962..eecdd56 100644
--- a/server/ponymail.yaml.example
+++ b/server/ponymail.yaml.example
@@ -7,6 +7,7 @@ database:
   dburl:     http://localhost:9200/   # The URL of the ElasticSearch database
   db_prefix: ponymail                 # DB prefix, usually 'ponymail'
   max_hits: 15000                     # Maximum number of emails to process in 
a search
+  pool_size: 15                       # number of connections for async queries
 
 tasks:
   refresh_rate:  150                  # Background indexer run interval, in 
seconds

Reply via email to