Skip to content

Commit

Permalink
Fix infinite recursion while shutting down TrackerSession
Browse files Browse the repository at this point in the history
  • Loading branch information
egbertbouman committed Dec 13, 2024
1 parent 1ed1139 commit f7fa9b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/tribler/core/torrent_checker/torrentchecker_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(self, tracker_type: str, tracker_url: str, tracker_address: tuple[s
self.timeout = timeout
self.infohash_list: list[bytes] = []
self.last_contact = 0
self.cleanup_task = None

# some flags
self.is_initiated = False # you cannot add requests to a session if it has been initiated
Expand Down Expand Up @@ -102,8 +103,8 @@ def failed(self, msg: str | None = None) -> NoReturn:
:raises ValueError: always.
"""
if not self.is_failed:
self.register_anonymous_task("Cleanup", self.cleanup)
if not self.is_failed and not self.cleanup_task:
self.cleanup_task = ensure_future(self.cleanup())
self.is_failed = True
result_msg = f"{self.tracker_type} tracker failed for url {self.tracker_url}"
if msg:
Expand Down

0 comments on commit f7fa9b4

Please sign in to comment.