# HG changeset patch # User Sylvain Thénault # Date 1278500504 -7200 # Node ID 6c0a7a881024a91e421058b1f35ae7e3b6ff9afa # Parent 2f3cf2b4ec0d1c30d5366f2628345cd1233b4ac5# Parent d40ced7532913e0518cb1af5dad242b29acce955 backport stable diff -r 2f3cf2b4ec0d -r 6c0a7a881024 pytestconf.py --- a/pytestconf.py Wed Jul 07 13:01:25 2010 +0200 +++ b/pytestconf.py Wed Jul 07 13:01:44 2010 +0200 @@ -40,7 +40,7 @@ def clean_repo_test_cls(cls): if 'repo' in cls.__dict__: - if not cls.repo._shutting_down: + if not cls.repo.shutting_down: cls.repo.shutdown() del cls.repo for clsattr in ('cnx', '_orig_cnx', 'config', '_config', 'vreg', 'schema'): diff -r 2f3cf2b4ec0d -r 6c0a7a881024 server/repository.py --- a/server/repository.py Wed Jul 07 13:01:25 2010 +0200 +++ b/server/repository.py Wed Jul 07 13:01:44 2010 +0200 @@ -125,6 +125,8 @@ # sources self.sources = [] self.sources_by_uri = {} + # shutdown flag + self.shutting_down = False # FIXME: store additional sources info in the system database ? # FIXME: sources should be ordered (add_entity priority) for uri, source_config in config.sources().items(): @@ -210,7 +212,6 @@ for i in xrange(config['connections-pool-size']): self.pools.append(pool.ConnectionsPool(self.sources)) self._available_pools.put_nowait(self.pools[-1]) - self._shutting_down = False if config.quick_start: config.init_cubes(self.get_cubes()) self.hm = hook.HooksManager(self.vreg) @@ -317,8 +318,8 @@ """called on server stop event to properly close opened sessions and connections """ - assert not self._shutting_down, 'already shutting down' - self._shutting_down = True + assert not self.shutting_down, 'already shutting down' + self.shutting_down = True self.system_source.shutdown() if isinstance(self._looping_tasks, tuple): # if tasks have been started for looptask in self._looping_tasks: @@ -794,7 +795,7 @@ def _get_session(self, sessionid, setpool=False, txid=None, checkshuttingdown=True): """return the user associated to the given session identifier""" - if checkshuttingdown and self._shutting_down: + if checkshuttingdown and self.shutting_down: raise Exception('Repository is shutting down') try: session = self._sessions[sessionid] diff -r 2f3cf2b4ec0d -r 6c0a7a881024 server/session.py --- a/server/session.py Wed Jul 07 13:01:25 2010 +0200 +++ b/server/session.py Wed Jul 07 13:01:44 2010 +0200 @@ -1025,6 +1025,14 @@ self.cnxtype = 'inmemory' self.disable_hook_categories('integrity') + @property + def pool(self): + """connections pool, set according to transaction mode for each query""" + if self.repo.shutting_down: + self.reset_pool(True) + raise Exception('repository is shutting down') + return getattr(self._threaddata, 'pool', None) + class InternalManager(object): """a manager user with all access rights used internally for task such as