Skip to content

Commit

Permalink
Process health checks in single db session (#8274)
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman authored Nov 25, 2024
2 parents c8540aa + 4a1203b commit c963244
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tribler/core/content_discovery/community.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ async def on_torrents_health(self, peer: Peer, payload: TorrentsHealthPayload) -
health_list = [HealthInfo(infohash, last_check=last_check, seeders=seeders, leechers=leechers)
for infohash, seeders, leechers, last_check in health_tuples]

to_resolve = self.process_torrents_health(health_list)

for health_info in health_list:
# Get a single result per infohash to avoid duplicates
with db_session:
self.composition.metadata_store.process_torrent_health(health_info)
infohash = hexlify(health_info.infohash).decode()
self.send_remote_select(peer=peer, infohash=infohash, last=1)
if health_info.infohash in to_resolve:
infohash = hexlify(health_info.infohash).decode()
self.send_remote_select(peer=peer, infohash=infohash, last=1)

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

0 comments on commit c963244

Please sign in to comment.