summaryrefslogtreecommitdiff
path: root/oslo_db/sqlalchemy/session.py
diff options
context:
space:
mode:
authorVictor Sergeyev <vsergeyev@mirantis.com>2015-01-27 19:15:50 +0200
committerVictor Sergeyev <vsergeyev@mirantis.com>2015-01-28 13:35:16 +0200
commitf4a77dc0c13f4bb9e45298412d0b36bc476b2afd (patch)
treedfb86467e44fc5602ab7a327df81b1265e7eb193 /oslo_db/sqlalchemy/session.py
parent32359046d9d135b95d3fa573f4996e8d65594cb0 (diff)
downloadoslo-db-f4a77dc0c13f4bb9e45298412d0b36bc476b2afd.tar.gz
Ensure that create_engine() close test connection
handle_connect_error() open and return a test connection, but nobody uses it in create_engine(), so (depending on Python interpreter) this connection can stay opened in the pool for some time. Co-Authored-By: Roman Podoliaka <rpodolyaka@mirantis.com> Change-Id: Ibef07f0fa1fec61aa10963c07c410a731d7758ef
Diffstat (limited to 'oslo_db/sqlalchemy/session.py')
-rw-r--r--oslo_db/sqlalchemy/session.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/oslo_db/sqlalchemy/session.py b/oslo_db/sqlalchemy/session.py
index 7e33075..57c8fc5 100644
--- a/oslo_db/sqlalchemy/session.py
+++ b/oslo_db/sqlalchemy/session.py
@@ -408,7 +408,11 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
compat.engine_connect(engine, _connect_ping_listener)
# initial connect + test
- _test_connection(engine, max_retries, retry_interval)
+ # NOTE(viktors): the current implementation of _test_connection()
+ # does nothing, if max_retries == 0, so we can skip it
+ if max_retries:
+ test_conn = _test_connection(engine, max_retries, retry_interval)
+ test_conn.close()
return engine