Skip to content

Commit c963244

Browse files
authored
Process health checks in single db session (#8274)
2 parents c8540aa + 4a1203b commit c963244

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/tribler/core/content_discovery/community.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ async def on_torrents_health(self, peer: Peer, payload: TorrentsHealthPayload) -
178178
health_list = [HealthInfo(infohash, last_check=last_check, seeders=seeders, leechers=leechers)
179179
for infohash, seeders, leechers, last_check in health_tuples]
180180

181+
to_resolve = self.process_torrents_health(health_list)
182+
181183
for health_info in health_list:
182184
# Get a single result per infohash to avoid duplicates
183-
with db_session:
184-
self.composition.metadata_store.process_torrent_health(health_info)
185-
infohash = hexlify(health_info.infohash).decode()
186-
self.send_remote_select(peer=peer, infohash=infohash, last=1)
185+
if health_info.infohash in to_resolve:
186+
infohash = hexlify(health_info.infohash).decode()
187+
self.send_remote_select(peer=peer, infohash=infohash, last=1)
187188

188189
@db_session
189190
def process_torrents_health(self, health_list: list[HealthInfo]) -> set[bytes]:

0 commit comments

Comments
 (0)