From 2de15421cc3aef477f652e659e6b686f6445b43c Mon Sep 17 00:00:00 2001 From: Daniel Bernstein Date: Thu, 19 Dec 2024 11:57:14 -0800 Subject: [PATCH] Fixes context manager issue by removing a session commit buried in the call stack. --- src/palace/manager/sqlalchemy/model/licensing.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/palace/manager/sqlalchemy/model/licensing.py b/src/palace/manager/sqlalchemy/model/licensing.py index d19c7cdb3..056178007 100644 --- a/src/palace/manager/sqlalchemy/model/licensing.py +++ b/src/palace/manager/sqlalchemy/model/licensing.py @@ -1656,16 +1656,12 @@ def delete(self): pools = list(self.license_pools) _db.delete(self) - # TODO: We need to explicitly commit here so that - # LicensePool.delivery_mechanisms gets updated. It would be - # better if we didn't have to do this, but I haven't been able - # to get LicensePool.delivery_mechanisms to notice that it's - # out of date. - _db.commit() - - # The deletion of a LicensePoolDeliveryMechanism might affect - # the open-access status of its associated LicensePools. for pool in pools: + # We need to expire pool here otherwise the delivery_mechanisms + # will contain a stale reference to the deleted licensepooldeliverymechanism + _db.expire(pool) + # The deletion of a LicensePoolDeliveryMechanism might affect + # the open-access status of its associated LicensePools. pool.set_open_access_status() def set_rights_status(self, uri):