From 230066af90698a4f29a71d5f7d3b10820bd6a599 Mon Sep 17 00:00:00 2001 From: Ann Kamyshnikova Date: Fri, 12 Aug 2016 15:26:02 +0300 Subject: [PATCH] Use dispose_pool() from oslo.db Depricate dispose() in db/api.py and use context_manager.dispose_pool() instread of it. Change-Id: I6f0d108fc00cc7fcfaac1bd8f1b0468fcfbaa0dd --- neutron/db/api.py | 7 +++---- neutron/service.py | 2 +- neutron/wsgi.py | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/neutron/db/api.py b/neutron/db/api.py index d85fdcbae5a..6bc2bcfe028 100644 --- a/neutron/db/api.py +++ b/neutron/db/api.py @@ -16,6 +16,7 @@ import contextlib from debtcollector import moves +from debtcollector import removals from oslo_config import cfg from oslo_db import api as oslo_db_api from oslo_db import exception as db_exc @@ -106,11 +107,9 @@ def get_engine(): return context_manager.get_legacy_facade().get_engine() +@removals.remove(version='newton', removal_version='Ocata') def dispose(): - # TODO(akamyshnikova): Use context_manager.dispose_pool() when it is - # available in oslo.db - if context_manager._factory._started: - get_engine().pool.dispose() + context_manager.dispose_pool() #TODO(akamyshnikova): when all places in the code, which use sessions/ diff --git a/neutron/service.py b/neutron/service.py index 52dc58142b8..8455e5c91e5 100644 --- a/neutron/service.py +++ b/neutron/service.py @@ -241,7 +241,7 @@ def _start_workers(workers): # dispose the whole pool before os.fork, otherwise there will # be shared DB connections in child processes which may cause # DB errors. - session.dispose() + session.context_manager.dispose_pool() for worker in process_workers: worker_launcher.launch_service(worker, diff --git a/neutron/wsgi.py b/neutron/wsgi.py index 4040d5d0cc8..12ce4bb2854 100644 --- a/neutron/wsgi.py +++ b/neutron/wsgi.py @@ -203,7 +203,7 @@ class Server(object): # dispose the whole pool before os.fork, otherwise there will # be shared DB connections in child processes which may cause # DB errors. - api.dispose() + api.context_manager.dispose_pool() # The API service runs in a number of child processes. # Minimize the cost of checking for child exit by extending the # wait interval past the default of 0.01s.