From b517e6f9b4450109578ac307860c12932c87714d Mon Sep 17 00:00:00 2001 From: dbernstein Date: Mon, 13 Jan 2025 13:25:34 -0800 Subject: [PATCH] [PP-2065] Address library not persistent within session errors by ensuring the (#2246) library and other objects accessed within the new transaction are attached to the session. --- src/palace/manager/celery/tasks/opds_odl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/palace/manager/celery/tasks/opds_odl.py b/src/palace/manager/celery/tasks/opds_odl.py index 03d8a1b45..ecb3db3d8 100644 --- a/src/palace/manager/celery/tasks/opds_odl.py +++ b/src/palace/manager/celery/tasks/opds_odl.py @@ -218,14 +218,14 @@ def collect_events( """ with task.session() as session: for e in events: - session.refresh(e.library) - session.refresh(e.license_pool) - session.refresh(e.patron) + library = session.merge(e.library) + license_pool = session.merge(e.license_pool) + patron = session.merge(e.patron) analytics.collect_event( event_type=e.event_type, - library=e.library, - license_pool=e.license_pool, - patron=e.patron, + library=library, + license_pool=license_pool, + patron=patron, )