server/repository.py
changeset 5752 b0bb553e3be4
parent 5736 375819ec7d43
parent 5749 b4393b681f7a
child 5765 14daeb31ee67
equal deleted inserted replaced
5743:4a0600664f85 5752:b0bb553e3be4
   317         """called on server stop event to properly close opened sessions and
   317         """called on server stop event to properly close opened sessions and
   318         connections
   318         connections
   319         """
   319         """
   320         assert not self._shutting_down, 'already shutting down'
   320         assert not self._shutting_down, 'already shutting down'
   321         self._shutting_down = True
   321         self._shutting_down = True
       
   322         self.system_source.shutdown()
   322         if isinstance(self._looping_tasks, tuple): # if tasks have been started
   323         if isinstance(self._looping_tasks, tuple): # if tasks have been started
   323             for looptask in self._looping_tasks:
   324             for looptask in self._looping_tasks:
   324                 self.info('canceling task %s...', looptask.name)
   325                 self.info('canceling task %s...', looptask.name)
   325                 looptask.cancel()
   326                 looptask.cancel()
   326                 looptask.join()
   327                 looptask.join()
   342                 continue
   343                 continue
   343         if self.pyro_registered:
   344         if self.pyro_registered:
   344             pyro_unregister(self.config)
   345             pyro_unregister(self.config)
   345         hits, misses = self.querier.cache_hit, self.querier.cache_miss
   346         hits, misses = self.querier.cache_hit, self.querier.cache_miss
   346         try:
   347         try:
   347             self.info('rqlt st cache hit/miss: %s/%s (%s%% hits)', hits, misses,
   348             self.info('rql st cache hit/miss: %s/%s (%s%% hits)', hits, misses,
   348                       (hits * 100) / (hits + misses))
   349                       (hits * 100) / (hits + misses))
   349             hits, misses = self.system_source.cache_hit, self.system_source.cache_miss
   350             hits, misses = self.system_source.cache_hit, self.system_source.cache_miss
   350             self.info('sql cache hit/miss: %s/%s (%s%% hits)', hits, misses,
   351             self.info('sql cache hit/miss: %s/%s (%s%% hits)', hits, misses,
   351                       (hits * 100) / (hits + misses))
   352                       (hits * 100) / (hits + misses))
   352             nocache  = self.system_source.no_cache
   353             nocache  = self.system_source.no_cache
   495 
   496 
   496     def properties(self):
   497     def properties(self):
   497         """return a result set containing system wide properties"""
   498         """return a result set containing system wide properties"""
   498         session = self.internal_session()
   499         session = self.internal_session()
   499         try:
   500         try:
   500             return session.execute('Any K,V WHERE P is CWProperty,'
   501             # don't use session.execute, we don't want rset.req set
   501                                    'P pkey K, P value V, NOT P for_user U',
   502             return self.querier.execute(session, 'Any K,V WHERE P is CWProperty,'
   502                                    build_descr=False)
   503                                         'P pkey K, P value V, NOT P for_user U',
       
   504                                         build_descr=False)
   503         finally:
   505         finally:
   504             session.close()
   506             session.close()
   505 
   507 
   506     # XXX protect this method: anonymous should be allowed and registration
   508     # XXX protect this method: anonymous should be allowed and registration
   507     # plugged
   509     # plugged
   582           built on select queries
   584           built on select queries
   583         """
   585         """
   584         session = self._get_session(sessionid, setpool=True)
   586         session = self._get_session(sessionid, setpool=True)
   585         try:
   587         try:
   586             try:
   588             try:
   587                 return self.querier.execute(session, rqlstring, args,
   589                 rset = self.querier.execute(session, rqlstring, args,
   588                                             build_descr)
   590                                             build_descr)
       
   591                 # NOTE: the web front will (re)build it when needed
       
   592                 #       e.g in facets
       
   593                 #       Zeroed to avoid useless overhead with pyro
       
   594                 rset._rqlst = None
       
   595                 return rset
   589             except (Unauthorized, RQLSyntaxError):
   596             except (Unauthorized, RQLSyntaxError):
   590                 raise
   597                 raise
   591             except ValidationError, ex:
   598             except ValidationError, ex:
   592                 # need ValidationError normalization here so error may pass
   599                 # need ValidationError normalization here so error may pass
   593                 # through pyro
   600                 # through pyro