Ensure is_backend_avail() doesn't leave open connections

is_backend_avail() helper function calls _ensure_backenv_available()
method,which creates a SQLAlchemy engine and opens a test connection,
but doesn't call engine.dispose(). Depending on Python interpreter
version used, the connection in the pool may remain open for some
time (even though, we don't store a reference to an Engine instance).

Closes-Bug: #1393633

Co-Authored-By: Victor Sergeyev <vsergeyev@mirantis.com>
Change-Id: I0297af709ed18fed52308500c13054cb49adf401
This commit is contained in:
Roman Podoliaka
2014-11-18 15:00:51 +02:00
parent 58cfd8262e
commit 7f755bf6fe

View File

@@ -683,7 +683,8 @@ def is_backend_avail(backend, database, user=None, passwd=None):
user=user,
passwd=passwd)
try:
provision.Backend._ensure_backend_available(connect_uri)
eng = provision.Backend._ensure_backend_available(connect_uri)
eng.dispose()
except exception.BackendNotAvailable:
return False
else: