summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-06-10 09:52:28 +0000
committerGerrit Code Review <review@openstack.org>2014-06-10 09:52:28 +0000
commitcd801bc47eec5e005246f887ba70902670b2f12c (patch)
treefed4a2cad25a7b4b90fa12de15e91a1a12de43a5
parent0ecd6a63a80b3d8c66bb0411b12e1c55ea73ca98 (diff)
parentb07e1de6f675466301cf9893136187bef9c747bc (diff)
downloadoslo-db-cd801bc47eec5e005246f887ba70902670b2f12c.tar.gz
Merge "Allow for skipping thread_yielding"
-rw-r--r--oslo/db/sqlalchemy/session.py14
-rw-r--r--tests/sqlalchemy/test_sqlalchemy.py1
2 files changed, 11 insertions, 4 deletions
diff --git a/oslo/db/sqlalchemy/session.py b/oslo/db/sqlalchemy/session.py
index a47f65b..cfda412 100644
--- a/oslo/db/sqlalchemy/session.py
+++ b/oslo/db/sqlalchemy/session.py
@@ -606,7 +606,8 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
idle_timeout=3600,
connection_debug=0, max_pool_size=None, max_overflow=None,
pool_timeout=None, sqlite_synchronous=True,
- connection_trace=False, max_retries=10, retry_interval=10):
+ connection_trace=False, max_retries=10, retry_interval=10,
+ thread_checkin=True):
"""Return a new SQLAlchemy engine."""
connection_dict = sqlalchemy.engine.url.make_url(sql_connection)
@@ -644,7 +645,8 @@ def create_engine(sql_connection, sqlite_fk=False, mysql_sql_mode=None,
engine = sqlalchemy.create_engine(sql_connection, **engine_args)
- sqlalchemy.event.listen(engine, 'checkin', _thread_yield)
+ if thread_checkin:
+ sqlalchemy.event.listen(engine, 'checkin', _thread_yield)
if engine.name in ('ibm_db_sa', 'mysql', 'postgresql'):
ping_callback = functools.partial(_ping_listener, engine)
@@ -829,7 +831,10 @@ class EngineFacade(object):
(defaults to 10)
:keyword retry_interval: interval between retries of opening a sql
connection (defaults to 10)
-
+ :keyword thread_checkin: boolean that indicates that between each
+ engine checkin event a sleep(0) will occur to
+ allow other greenthreads to run (defaults to
+ True)
"""
super(EngineFacade, self).__init__()
@@ -846,7 +851,8 @@ class EngineFacade(object):
sqlite_synchronous=kwargs.get('sqlite_synchronous', True),
connection_trace=kwargs.get('connection_trace', False),
max_retries=kwargs.get('max_retries', 10),
- retry_interval=kwargs.get('retry_interval', 10))
+ retry_interval=kwargs.get('retry_interval', 10),
+ thread_checkin=kwargs.get('thread_checkin', True))
self._session_maker = get_maker(
engine=self._engine,
autocommit=autocommit,
diff --git a/tests/sqlalchemy/test_sqlalchemy.py b/tests/sqlalchemy/test_sqlalchemy.py
index 70a2388..a6f097b 100644
--- a/tests/sqlalchemy/test_sqlalchemy.py
+++ b/tests/sqlalchemy/test_sqlalchemy.py
@@ -377,6 +377,7 @@ class EngineFacadeTestCase(oslo_test.BaseTestCase):
connection_trace=mock.ANY,
sqlite_synchronous=mock.ANY,
pool_timeout=mock.ANY,
+ thread_checkin=mock.ANY,
)
get_maker.assert_called_once_with(engine=create_engine(),
autocommit=False,