diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-11-11 16:26:40 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-11-11 16:33:48 -0500 |
commit | 52d576437abaa55f5fd3d721280656c5f0800d80 (patch) | |
tree | b40f4fc44ad6e6ad5021323a7fd65fe8781ae007 /oslo_db/sqlalchemy/enginefacade.py | |
parent | 7cc914fc1d7cb63439361b8323bafb3ba8fcd61c (diff) | |
download | oslo-db-3.2.0.tar.gz |
Detect not-started _TransactionFactory in legacy3.2.0
When LegacyEngineFacade is passed a _TransactionFactory
that is not started, or one that fails to start, the
_start() method should be called again each time the
factory is called upon; this ensures that the failed
start either can be made to succeed, or at least re-raises
the same error as earlier, instead of falling into attribute
access for non-existent attributes.
Change-Id: I7484f837d455c1f69c448e5ccadc277d19af47e7
Closes-Bug: #1515326
Diffstat (limited to 'oslo_db/sqlalchemy/enginefacade.py')
-rw-r--r-- | oslo_db/sqlalchemy/enginefacade.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/oslo_db/sqlalchemy/enginefacade.py b/oslo_db/sqlalchemy/enginefacade.py index 111f033..7f64acc 100644 --- a/oslo_db/sqlalchemy/enginefacade.py +++ b/oslo_db/sqlalchemy/enginefacade.py @@ -952,6 +952,10 @@ class LegacyEngineFacade(object): _conf, connection=sql_connection, slave_connection=slave_connection) + def _check_factory_started(self): + if not self._factory._started: + self._factory._start() + def get_engine(self, use_slave=False): """Get the engine instance (note, that it's shared). @@ -962,6 +966,7 @@ class LegacyEngineFacade(object): :type use_slave: bool """ + self._check_factory_started() if use_slave: return self._factory._reader_engine else: @@ -982,6 +987,7 @@ class LegacyEngineFacade(object): was created). See SQLAlchemy Session docs for details. """ + self._check_factory_started() if use_slave: return self._factory._reader_maker(**kwargs) else: @@ -994,6 +1000,7 @@ class LegacyEngineFacade(object): be temporarily injected with some state such as a specific connection. """ + self._check_factory_started() if use_slave: return self._factory._reader_maker else: |