server/repository.py
branchstable
changeset 1883 011e13d74cfc
parent 1880 293fe4b49e28
child 1939 67e7379edd96
equal deleted inserted replaced
1882:ce662160bb46 1883:011e13d74cfc
   215         # close initialization pool and reopen fresh ones for proper
   215         # close initialization pool and reopen fresh ones for proper
   216         # initialization now that we know cubes
   216         # initialization now that we know cubes
   217         self._get_pool().close(True)
   217         self._get_pool().close(True)
   218         for i in xrange(config['connections-pool-size']):
   218         for i in xrange(config['connections-pool-size']):
   219             self._available_pools.put_nowait(ConnectionsPool(self.sources))
   219             self._available_pools.put_nowait(ConnectionsPool(self.sources))
   220         self._shuting_down = False
   220         self._shutting_down = False
   221 
   221 
   222     # internals ###############################################################
   222     # internals ###############################################################
   223 
   223 
   224     def get_source(self, uri, source_config):
   224     def get_source(self, uri, source_config):
   225         source_config['uri'] = uri
   225         source_config['uri'] = uri
   348                                 threading.currentThread())
   348                                 threading.currentThread())
   349     def shutdown(self):
   349     def shutdown(self):
   350         """called on server stop event to properly close opened sessions and
   350         """called on server stop event to properly close opened sessions and
   351         connections
   351         connections
   352         """
   352         """
   353         self._shuting_down = True
   353         self._shutting_down = True
   354         if isinstance(self._looping_tasks, tuple): # if tasks have been started
   354         if isinstance(self._looping_tasks, tuple): # if tasks have been started
   355             for looptask in self._looping_tasks:
   355             for looptask in self._looping_tasks:
   356                 self.info('canceling task %s...', looptask.name)
   356                 self.info('canceling task %s...', looptask.name)
   357                 looptask.cancel()
   357                 looptask.cancel()
   358                 looptask.join()
   358                 looptask.join()
   720         session.set_pool()
   720         session.set_pool()
   721         return session
   721         return session
   722 
   722 
   723     def _get_session(self, sessionid, setpool=False):
   723     def _get_session(self, sessionid, setpool=False):
   724         """return the user associated to the given session identifier"""
   724         """return the user associated to the given session identifier"""
   725         if self._shuting_down:
   725         if self._shutting_down:
   726             raise Exception('Repository is shuting down')
   726             raise Exception('Repository is shutting down')
   727         try:
   727         try:
   728             session = self._sessions[sessionid]
   728             session = self._sessions[sessionid]
   729         except KeyError:
   729         except KeyError:
   730             raise BadConnectionId('No such session %s' % sessionid)
   730             raise BadConnectionId('No such session %s' % sessionid)
   731         if setpool:
   731         if setpool: