This patch changes the context manager call in the _refresh_from_db()
method from this:
with ctx.session.connection() as conn:
to this:
with db_api.api_context_manager.reader.connection.using(ctx):
This is necessary to prevent errors about using a closed connection that
surfaced when writing a functional test case that tested that deleting a
custom resource class when inventory is associated with that custom
resource class.
Change-Id: I844d00028281ccbbfa527cd77469592fe1d7c151
:param cache: ResourceClassCache object to refresh.
"""
- with ctx.session.connection() as conn:
+ with db_api.api_context_manager.reader.connection.using(ctx) as conn:
sel = sa.select([_RC_TBL.c.id, _RC_TBL.c.name])
res = conn.execute(sel).fetchall()
cache.id_cache = {r[1]: r[0] for r in res}