cubicweb/server/repository.py
branch3.24
changeset 11908 7904fe436e82
parent 11821 7534b32c45e3
child 11931 ad7796dabeaa
equal deleted inserted replaced
11907:3be141d6c82c 11908:7904fe436e82
   202                     session.user.__class__ = usercls
   202                     session.user.__class__ = usercls
   203 
   203 
   204     def init_cnxset_pool(self):
   204     def init_cnxset_pool(self):
   205         """should be called bootstrap_repository, as this is what it does"""
   205         """should be called bootstrap_repository, as this is what it does"""
   206         config = self.config
   206         config = self.config
       
   207         # copy pool size here since config.init_cube() and config.load_schema()
       
   208         # reload configuration from file and could reset a manually set pool
       
   209         # size.
       
   210         pool_size = config['connections-pool-size']
   207         self._cnxsets_pool = queue.Queue()
   211         self._cnxsets_pool = queue.Queue()
   208         # 0. init a cnxset that will be used to fetch bootstrap information from
   212         # 0. init a cnxset that will be used to fetch bootstrap information from
   209         #    the database
   213         #    the database
   210         self._cnxsets_pool.put_nowait(self.system_source.wrapped_connection())
   214         self._cnxsets_pool.put_nowait(self.system_source.wrapped_connection())
   211         # 1. set used cubes
   215         # 1. set used cubes
   222             # restrict appobject_path to only load hooks and entity classes in
   226             # restrict appobject_path to only load hooks and entity classes in
   223             # the registry
   227             # the registry
   224             config.cube_appobject_path = set(('hooks', 'entities'))
   228             config.cube_appobject_path = set(('hooks', 'entities'))
   225             config.cubicweb_appobject_path = set(('hooks', 'entities'))
   229             config.cubicweb_appobject_path = set(('hooks', 'entities'))
   226             # limit connections pool to 1
   230             # limit connections pool to 1
   227             config['connections-pool-size'] = 1
   231             pool_size = 1
   228         if config.quick_start or config.creating or not config.read_instance_schema:
   232         if config.quick_start or config.creating or not config.read_instance_schema:
   229             # load schema from the file system
   233             # load schema from the file system
   230             if not config.creating:
   234             if not config.creating:
   231                 self.info("set fs instance'schema")
   235                 self.info("set fs instance'schema")
   232             self.set_schema(config.load_schema(expand_cubes=True))
   236             self.set_schema(config.load_schema(expand_cubes=True))
   256         # 4. close initialization connection set and reopen fresh ones for
   260         # 4. close initialization connection set and reopen fresh ones for
   257         #    proper initialization
   261         #    proper initialization
   258         self._get_cnxset().close(True)
   262         self._get_cnxset().close(True)
   259         # list of available cnxsets (can't iterate on a Queue)
   263         # list of available cnxsets (can't iterate on a Queue)
   260         self.cnxsets = []
   264         self.cnxsets = []
   261         for i in range(config['connections-pool-size']):
   265         for i in range(pool_size):
   262             self.cnxsets.append(self.system_source.wrapped_connection())
   266             self.cnxsets.append(self.system_source.wrapped_connection())
   263             self._cnxsets_pool.put_nowait(self.cnxsets[-1])
   267             self._cnxsets_pool.put_nowait(self.cnxsets[-1])
   264 
   268 
   265     # internals ###############################################################
   269     # internals ###############################################################
   266 
   270