[repository] Fix connection-pool-size not set to 1 with quick_start enabled 3.24
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Thu, 12 Jan 2017 13:40:25 +0100
branch3.24
changeset 11908 7904fe436e82
parent 11907 3be141d6c82c
child 11909 244cd7f407b8
[repository] Fix connection-pool-size not set to 1 with quick_start enabled config.load_schema() and config.init_cube() reload configuration options from config file, so a manually set connections-pool-size (eg. when quick_start is enabled) wasn't working.
cubicweb/server/repository.py
--- a/cubicweb/server/repository.py	Thu Jan 19 11:12:35 2017 +0100
+++ b/cubicweb/server/repository.py	Thu Jan 12 13:40:25 2017 +0100
@@ -204,6 +204,10 @@
     def init_cnxset_pool(self):
         """should be called bootstrap_repository, as this is what it does"""
         config = self.config
+        # copy pool size here since config.init_cube() and config.load_schema()
+        # reload configuration from file and could reset a manually set pool
+        # size.
+        pool_size = config['connections-pool-size']
         self._cnxsets_pool = queue.Queue()
         # 0. init a cnxset that will be used to fetch bootstrap information from
         #    the database
@@ -224,7 +228,7 @@
             config.cube_appobject_path = set(('hooks', 'entities'))
             config.cubicweb_appobject_path = set(('hooks', 'entities'))
             # limit connections pool to 1
-            config['connections-pool-size'] = 1
+            pool_size = 1
         if config.quick_start or config.creating or not config.read_instance_schema:
             # load schema from the file system
             if not config.creating:
@@ -258,7 +262,7 @@
         self._get_cnxset().close(True)
         # list of available cnxsets (can't iterate on a Queue)
         self.cnxsets = []
-        for i in range(config['connections-pool-size']):
+        for i in range(pool_size):
             self.cnxsets.append(self.system_source.wrapped_connection())
             self._cnxsets_pool.put_nowait(self.cnxsets[-1])