From 93d02ec3427108198a5fc1b179013f5f1d0f88ae Mon Sep 17 00:00:00 2001 From: Alexander Kozlovsky Date: Thu, 17 Sep 2020 23:27:01 +0200 Subject: [PATCH] Fixes #5568: DatabaseSessionIsOver: Cannot load attribute TorrentState[...].seeders --- .../community/gigachannel_community.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py b/src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py index e300d6cd732..25e4d979344 100644 --- a/src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py +++ b/src/tribler-core/tribler_core/modules/metadata_store/community/gigachannel_community.py @@ -310,17 +310,19 @@ def _process_received_blob(): self.metadata_store.disconnect_thread() return None, None + # it is incorrect to call md.simple_dict() for metadata objects from md_results + # as previous db_session is already over, so we are going to fetch them again in a new db_session + md_ids = [ + md.rowid for md, action in md_results + if md + and (md.metadata_type in [CHANNEL_TORRENT, REGULAR_TORRENT]) + and action in [UNKNOWN_CHANNEL, UNKNOWN_TORRENT, UPDATED_OUR_VERSION, UNKNOWN_COLLECTION] + ] + with db_session: + md_list = self.metadata_store.ChannelNode.select(lambda md: md.rowid in md_ids)[:] result = ( - [ - md.to_simple_dict() - for (md, action) in md_results - if ( - md - and (md.metadata_type in [CHANNEL_TORRENT, REGULAR_TORRENT]) - and action in [UNKNOWN_CHANNEL, UNKNOWN_TORRENT, UPDATED_OUR_VERSION, UNKNOWN_COLLECTION] - ) - ], + [md.to_simple_dict() for md in md_list], gen_have_newer_results_blob(md_results), ) self.metadata_store.disconnect_thread()