From ea73d0082ec37d3278c1bfd7135f83cc96b5b9e6 Mon Sep 17 00:00:00 2001 From: nolash Date: Tue, 23 Feb 2021 08:46:14 +0100 Subject: [PATCH] Remove redundant postgres connections in backend resume method --- chainsyncer/backend.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/chainsyncer/backend.py b/chainsyncer/backend.py index 60d4597..0dddce1 100644 --- a/chainsyncer/backend.py +++ b/chainsyncer/backend.py @@ -199,11 +199,16 @@ class SyncerBackend: o = q.get(object_id) (highest_unsynced_block, highest_unsynced_index) = o.cursor() - for object_id in BlockchainSync.get_unsynced(session=session): + object_ids = BlockchainSync.get_unsynced(session=session) + session.close() + + for object_id in object_ids: logg.debug('block syncer resume added previously unsynced sync entry id {}'.format(object_id)) s = SyncerBackend(chain_spec, object_id) syncers.append(s) + session = SessionBase.create_session() + last_live_id = BlockchainSync.get_last(session=session) if last_live_id != None: