diff options
author | Dirk Mueller <dirk@dmllr.de> | 2014-04-08 11:56:17 +0200 |
---|---|---|
committer | Dirk Mueller <dirk@dmllr.de> | 2014-05-08 18:20:06 +0200 |
commit | f74c34e19874a2a11891fe14bb2bf546dfea7d9c (patch) | |
tree | ed7421ded3518aedfdfdd2de1ece721570ec4976 | |
parent | 4c738572b2773a822639de9a757e982204360774 (diff) | |
download | oslo-incubator-f74c34e19874a2a11891fe14bb2bf546dfea7d9c.tar.gz |
Start ping listener also for postgresql
We can make use of the automatic connection disposal
for PostgreSQL as well.
Closes-Bug: #1298310
Change-Id: Ifb498b64f6a4305c6639afaeed246394043decd1
(cherry picked from commit 4a591eaafe035fa3fd508c910f057bfa8ff51005)
-rw-r--r-- | openstack/common/db/sqlalchemy/session.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/openstack/common/db/sqlalchemy/session.py b/openstack/common/db/sqlalchemy/session.py index ba426165..7ec799c3 100644 --- a/openstack/common/db/sqlalchemy/session.py +++ b/openstack/common/db/sqlalchemy/session.py @@ -367,7 +367,7 @@ def _raise_if_duplicate_entry_error(integrity_error, engine_name): return [columns] return columns[len(uniqbase):].split("0")[1:] - if engine_name not in ["ibm_db_sa", "mysql", "sqlite", "postgresql"]: + if engine_name not in ("ibm_db_sa", "mysql", "sqlite", "postgresql"): return # FIXME(johannes): The usage of the .message attribute has been @@ -489,7 +489,7 @@ def _thread_yield(dbapi_con, con_record): def _ping_listener(engine, dbapi_conn, connection_rec, connection_proxy): - """Ensures that MySQL and DB2 connections are alive. + """Ensures that MySQL, PostgreSQL or DB2 connections are alive. Borrowed from: http://groups.google.com/group/sqlalchemy/msg/a4ce563d802c929f @@ -645,7 +645,7 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None, sqlalchemy.event.listen(engine, 'checkin', _thread_yield) - if engine.name in ['mysql', 'ibm_db_sa']: + if engine.name in ('ibm_db_sa', 'mysql', 'postgresql'): ping_callback = functools.partial(_ping_listener, engine) sqlalchemy.event.listen(engine, 'checkout', ping_callback) if engine.name == 'mysql': |