summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2015-09-08 23:19:06 -0700
committerJoshua Harlow <harlowja@gmail.com>2015-09-08 23:20:26 -0700
commite501a565ae6d181b5ac0ec781300e3bbc5683302 (patch)
treeb616e042130739c56dd6e54e039ef516e4efb3d5
parent9c709ef38a1a519273cf040cb88418359a9f5310 (diff)
downloadoslo-db-e501a565ae6d181b5ac0ec781300e3bbc5683302.tar.gz
Handle case where oslo_db.tests has not been imported
It seems possible to use the connection_trace functionality without having 'oslo_db.tests' be loaded so it seems like the code here should be handling that module not being loaded and the associated key error that is raised when it fails. Change-Id: I6ef05ff83365ce0b86ec72a444e714f7a29c91c8 Closes-Bug: #1493675
-rw-r--r--oslo_db/sqlalchemy/engines.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/oslo_db/sqlalchemy/engines.py b/oslo_db/sqlalchemy/engines.py
index 84e4d12..e7681b6 100644
--- a/oslo_db/sqlalchemy/engines.py
+++ b/oslo_db/sqlalchemy/engines.py
@@ -377,9 +377,12 @@ def _add_trace_comments(engine):
os.path.dirname(sys.modules['oslo_db'].__file__),
os.path.dirname(sys.modules['sqlalchemy'].__file__)
])
- skip_paths = set([
- os.path.dirname(sys.modules['oslo_db.tests'].__file__),
- ])
+ try:
+ skip_paths = set([
+ os.path.dirname(sys.modules['oslo_db.tests'].__file__),
+ ])
+ except KeyError:
+ skip_paths = set()
@sqlalchemy.event.listens_for(engine, "before_cursor_execute", retval=True)
def before_cursor_execute(conn, cursor, statement, parameters, context,