only log when really announcing, stop counting cached ones

This commit is contained in:
Victor Shyba 2022-03-08 18:03:29 -03:00
parent 42fd1c962e
commit 05124d41ae

View file

@ -149,9 +149,8 @@ class TrackerClient:
self.tasks.clear() self.tasks.clear()
def hash_done(self, info_hash): def hash_done(self, info_hash):
self.announced += 1
self.tasks.pop(info_hash, None) self.tasks.pop(info_hash, None)
if len(self.tasks) == 0: if len(self.tasks) == 0 and self.announced > 0:
log.info("Tracker finished announcing %d files.", self.announced) log.info("Tracker finished announcing %d files.", self.announced)
self.announced = 0 self.announced = 0
@ -178,6 +177,7 @@ class TrackerClient:
return result return result
try: try:
tracker_ip = await resolve_host(tracker_host, tracker_port, 'udp') tracker_ip = await resolve_host(tracker_host, tracker_port, 'udp')
self.announced += 1
result = await self.client.announce( result = await self.client.announce(
info_hash, self.node_id, self.announce_port, tracker_ip, tracker_port, stopped) info_hash, self.node_id, self.announce_port, tracker_ip, tracker_port, stopped)
except asyncio.TimeoutError: except asyncio.TimeoutError: