[PATCH 10 of 12 cubicweb] [database/pool/refactoring] try to make decision tree more explicit

Laurent Peuch cortex at worlddomination.be
Tue Jan 7 13:30:45 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1578398765 -3600
#      Tue Jan 07 13:06:05 2020 +0100
# Node ID 0b195a125db3d99f706f74241966ce0c8848e26d
# Parent  720d7b1758252ff497d6fc5b8be1a3f9104f8597
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r 0b195a125db3
[database/pool/refactoring] try to make decision tree more explicit

This introduce a small ducplicated with the quick_start part but this really
should make the last _CnxSetPool initialization way more explicit for the 3
different situations available.

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -379,11 +379,8 @@ class Repository(object):
             pool_low_load_delay = config['connections-pool-low-load-delay']
             pool_close_delay = config['connections-pool-close-delay']
         else:
-            max_pool_size = cw_init_phase_max_pool_size = None
-            min_pool_size = None
-            max_pool_timeout, min_pool_timeout = None
-            pool_low_load_delay = None
-            pool_close_delay = None
+            cw_init_phase_max_pool_size = None
+
         # 0. init a cnxset that will be used to fetch bootstrap information from
         #    the database
         self.cnxsets = _CnxSetPool(self.system_source, cw_init_phase_max_pool_size)
@@ -432,14 +429,22 @@ class Repository(object):
             self._init_system_source()
             if 'CWProperty' in self.schema:
                 self.vreg.init_properties(self.properties())
+
         # 4. close initialization connection set and reopen fresh ones for
         #    proper initialization
         self.cnxsets.close()
-        self.cnxsets = _CnxSetPool(self.system_source,
-                                   max_size=max_pool_size, min_size=min_pool_size,
-                                   max_timeout=max_pool_timeout, min_timeout=min_pool_timeout,
-                                   low_load_delay=pool_low_load_delay,
-                                   close_delay=pool_close_delay)
+
+        if config['connections-pooler-enabled']:
+            self.cnxsets = _CnxSetPool(self.system_source,
+                                       max_size=max_pool_size, min_size=min_pool_size,
+                                       max_timeout=max_pool_timeout, min_timeout=min_pool_timeout,
+                                       low_load_delay=pool_low_load_delay,
+                                       close_delay=pool_close_delay)
+        elif config.quick_start:
+            self.cnxsets = _CnxSetPool(self.system_source, max_size=cw_init_phase_max_pool_size)
+        else:
+            self.cnxsets = _CnxSetPool(self.system_source, max_size=None)
+
         # 5. call instance level initialisation hooks
         self.hm.call_hooks('server_startup', repo=self)
 



More information about the cubicweb-devel mailing list